/* /how-far-back — a year of backups on a ruler, thinned out by the retention
   rules. Builds on styles.css (tokens, nav, sections, FAQ list).

   The ruler's marks are graduations: the longer the mark, the longer the
   rule keeping that backup holds on to it (month > week > day > newest).
   Height carries the meaning, so colour never has to: kept marks are the
   accent, pinned ones the pin colour, thinned-out ones faint dots. */

body {
  --pin: #F2C14E;
  --pin-soft: color-mix(in oklab, var(--pin) 16%, transparent);
  --ghost: color-mix(in oklab, var(--text3) 55%, transparent);
  --mark: var(--accent);
}
body.light {
  --pin: #A06A00;
  --mark: #1F8F84;
}

.rt-hero { padding-bottom: 48px; }
.rt-section { padding-top: 24px; }
.rt-lede { max-width: 660px; }

/* ---------- The lab ---------- */

.rt-lab {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg2);
  padding: 26px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rt-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 18px 32px;
}
.rt-controls .rt-field:first-child { grid-column: 1 / -1; }

.rt-field { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.rt-field-label { font-size: 13px; font-weight: 600; color: var(--text2); }

.rt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rt-chip {
  font: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  color: var(--text);
  cursor: pointer;
}
.rt-chip:hover { border-color: color-mix(in oklab, var(--accent) 50%, var(--line)); }
.rt-chip[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.rt-chip small { font-size: 11.5px; color: var(--text3); font-weight: 400; margin-left: 4px; }
.rt-chip[aria-checked="true"] small { color: inherit; opacity: .8; }

.rt-tiers { display: flex; flex-wrap: wrap; gap: 8px; }
.rt-tier {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px 4px 3px 12px;
  font-size: 13.5px;
}
.rt-tier span { color: var(--text2); min-width: 52px; }
.rt-tier output {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  min-width: 2.4ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rt-tier button {
  font: inherit;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 0;
  background: none;
  color: var(--text2);
  cursor: pointer;
}
.rt-tier button:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.rt-tier button:disabled { opacity: .35; cursor: default; }
.rt-tiers.off .rt-tier { opacity: .45; }

.rt-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text2); cursor: pointer; }
.rt-check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

/* ---------- The ruler ---------- */

.rt-ruler-wrap { position: relative; }
.rt-ruler {
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line2);
  padding: 12px 14px 4px;
  touch-action: pan-y;
}
.rt-ruler svg { display: block; width: 100%; overflow: visible; }
.rt-ruler .seg-title { font-size: 12px; fill: var(--text2); font-weight: 600; }
.rt-ruler .seg-count { font-size: 12px; fill: var(--text3); }
.rt-ruler .axis { stroke: var(--line); stroke-width: 1; }
.rt-ruler .axis-label { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; fill: var(--text3); }
.rt-ruler .axis-tick { stroke: var(--line); }
.rt-ruler .empty { font-size: 12px; fill: var(--text3); font-style: italic; }
.rt-ruler .made { fill: var(--ghost); }
.rt-ruler .made-band { stroke: var(--ghost); stroke-width: 3; stroke-linecap: round; }
.rt-ruler .mark { stroke: var(--mark); stroke-width: 2; stroke-linecap: round; fill: none; }
.rt-ruler .mark-pin { stroke: var(--pin); stroke-width: 2; stroke-linecap: round; fill: none; }
.rt-ruler .pin-head { fill: var(--pin); stroke: var(--bg); stroke-width: 2; }
.rt-ruler .hover-line { stroke: var(--text2); stroke-width: 1; stroke-dasharray: 2 3; }
.rt-ruler .hit { fill: transparent; cursor: pointer; }

.rt-tip {
  position: absolute;
  z-index: 5;
  top: 0;
  pointer-events: none;
  max-width: 260px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  font-size: 13px;
  line-height: 1.45;
  transform: translate(-50%, -100%);
}
.rt-tip b { display: block; font-weight: 600; }
.rt-tip span { color: var(--text2); }
.rt-tip em { display: block; font-style: normal; color: var(--text3); font-size: 12px; margin-top: 2px; }

.rt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 12.5px;
  color: var(--text2);
  margin-top: -8px;
}
.rt-legend span { display: inline-flex; align-items: flex-end; gap: 7px; }
.lg { display: inline-block; width: 2px; border-radius: 1px; background: var(--mark); }
.lg-monthly { height: 18px; }
.lg-weekly { height: 13px; }
.lg-daily { height: 9px; }
.lg-last { height: 6px; }
.lg-pinned { height: 18px; background: var(--pin); position: relative; }
.lg-pinned::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pin);
}
.lg-made { width: 4px; height: 4px; border-radius: 50%; background: var(--ghost); margin-bottom: 1px; }

/* ---------- Transport + pins ---------- */

.rt-transport { display: flex; align-items: center; gap: 14px; }
.rt-play {
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: var(--btn-ink);
  cursor: pointer;
  white-space: nowrap;
  min-width: 132px;
}
.rt-play:hover { filter: brightness(1.08); }
.rt-transport input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.rt-transport output {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text2);
  min-width: 13ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rt-pins { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: -8px; }
.rt-pin-btn {
  font: inherit;
  font-size: 13.5px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--pin) 55%, var(--line));
  background: var(--pin-soft);
  color: var(--text);
  cursor: pointer;
}
.rt-pin-btn:hover { border-color: var(--pin); }
.rt-pin-hint { font-size: 13px; color: var(--text3); }

/* ---------- Numbers ---------- */

.rt-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rt-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg3);
}
.rt-tile-label { font-size: 12.5px; color: var(--text2); }
.rt-tile b {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.rt-tile small { font-size: 13px; color: var(--text3); }

.rt-trend { margin: 0; }
.rt-trend figcaption { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.rt-trend-plot { position: relative; height: 96px; }
.rt-trend-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.rt-trend .line { fill: none; stroke: var(--mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rt-trend .line-future { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; }
.rt-trend .grid { stroke: var(--line2); }
.rt-trend .label { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; fill: var(--text3); }
.rt-trend .dot { fill: var(--mark); stroke: var(--bg2); stroke-width: 2; }

.rt-list summary { cursor: pointer; font-size: 14px; color: var(--text2); }
.rt-list ul {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  columns: 2 280px;
  column-gap: 28px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text2);
}
.rt-list li { break-inside: avoid; padding: 2px 0; }
.rt-list li b { color: var(--text); font-weight: 500; margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ---------- Rules, table ---------- */

.rt-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 26px 32px;
}
.rt-rule h3 { font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 600; margin: 0 0 8px; letter-spacing: -0.01em; }
.rt-rule p { color: var(--text2); font-size: 15px; line-height: 1.6; margin: 0; text-wrap: pretty; }

.rt-table-wrap { overflow-x: auto; }
.rt-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.rt-table th, .rt-table td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.rt-table thead th { font-size: 13px; font-weight: 600; color: var(--text2); border-bottom-color: var(--line); }
.rt-table tbody th { font-weight: 600; white-space: nowrap; }
.rt-table td { color: var(--text2); line-height: 1.5; }
.rt-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rt-table td.num { color: var(--text); }
.rt-default {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .rt-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .rt-lab { padding: 18px 14px 16px; border-radius: 16px; }
  .rt-controls { grid-template-columns: minmax(0, 1fr); }
  .rt-ruler { padding: 10px 8px 6px; }
  .rt-tiles { grid-template-columns: minmax(0, 1fr); }
  .rt-tile { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
  .rt-tile-label { flex-basis: 100%; }
  .rt-tile b { font-size: 24px; }
  .rt-rules { grid-template-columns: minmax(0, 1fr); }
  .rt-transport { flex-wrap: wrap; gap: 10px 14px; }
  .rt-transport input[type="range"] { order: 3; flex-basis: 100%; }
  .rt-transport output { min-width: 0; }
  .rt-play { min-width: 0; }
  .rt-table thead { display: none; }
  .rt-table, .rt-table tbody, .rt-table tr { display: block; }
  .rt-table tr { padding: 14px 0; border-bottom: 1px solid var(--line2); }
  .rt-table th, .rt-table td { display: inline; padding: 0; border: 0; }
  .rt-table tbody th { display: block; margin-bottom: 4px; }
  .rt-table td:nth-child(2) { display: block; margin-bottom: 6px; }
  .rt-table td.num::after { content: " kept, "; color: var(--text2); }
  .rt-table td:last-child::after { content: " back"; }
}

@media (prefers-reduced-motion: reduce) {
  .rt-hero * { animation: none !important; }
}
