/* By Your Age — a timetable board at dusk: deep green field, chalk text, one marigold seam. */
@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --field: #0e3b3a;
  --field-deep: #0a2f2e;
  --field-raise: #134847;
  --chalk: #f3efe4;
  --chalk-dim: #a9d6cc;
  --rail: #5f8a85;
  --rail-faint: #2a5a57;
  --seam: #f5b83d;
  --seam-ink: #1d1404;
  --danger: #ffb4a6;
  --focus: #f5b83d;
  --sans: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --step--1: clamp(0.84rem, 0.8rem + 0.15vw, 0.92rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.45vw, 1.45rem);
  --step-2: clamp(1.5rem, 1.25rem + 1.1vw, 2.2rem);
  --step-3: clamp(2.1rem, 1.5rem + 3vw, 4.2rem);
  --space: clamp(1rem, 0.8rem + 1vw, 1.5rem);
  --radius: 10px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--field);
  color: var(--chalk);
  font: 400 var(--step-0)/1.6 var(--sans);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
::selection { background: var(--seam); color: var(--seam-ink); }
a { color: var(--chalk); text-decoration-color: var(--seam); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.1; text-wrap: balance; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }

.wrap { width: min(100% - 2 * var(--space), 72rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; background: var(--seam); color: var(--seam-ink); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }

/* header */
.top { display: flex; justify-content: space-between; align-items: center; padding-block: 1.25rem; gap: 1rem; }
.mark { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 750; letter-spacing: -0.01em; text-decoration: none; font-size: var(--step-0); }
.mark-seam { width: 3px; height: 1.4em; background: var(--seam); border-radius: 2px; }
.top nav a { color: var(--chalk-dim); font-size: var(--step--1); }

/* intro */
.intro { padding-block: clamp(2rem, 6vw, 5rem) clamp(2rem, 4vw, 3rem); max-width: 50rem; }
h1 { font-size: var(--step-3); font-weight: 800; letter-spacing: -0.03em; font-stretch: 95%; }
h1 em { font-style: normal; color: var(--seam); }
.lede { margin-top: 1.25rem; color: var(--chalk-dim); font-size: var(--step-1); line-height: 1.45; max-width: 40rem; }

.bday { margin-top: 2.25rem; display: grid; gap: 0.5rem; max-width: 34rem; }
.bday label { font-weight: 650; }
.bday-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.bday input {
  flex: 1 1 12rem; min-width: 0; min-height: 3rem; padding: 0.6rem 0.9rem;
  font: inherit; font-size: var(--step-1); color: var(--chalk); caret-color: var(--seam);
  background: var(--field-deep); border: 2px solid var(--rail); border-radius: var(--radius);
}
.bday input:hover { border-color: var(--chalk-dim); }
.bday input[aria-invalid="true"] { border-color: var(--danger); }
.bday input::-webkit-calendar-picker-indicator { filter: invert(0.9); cursor: pointer; }
.hint { color: var(--chalk-dim); font-size: var(--step--1); }
.error { color: var(--danger); font-weight: 600; }

/* buttons */
.btn {
  min-height: 2.75rem; padding: 0.55rem 1.1rem; font: inherit; font-weight: 650; cursor: pointer;
  color: var(--chalk); background: transparent; border: 2px solid var(--rail); border-radius: 999px;
  transition: background-color 160ms ease-out, border-color 160ms ease-out;
}
.btn:hover { border-color: var(--chalk); background: var(--field-raise); }
.btn-primary { min-height: 3rem; padding-inline: 1.5rem; background: var(--seam); color: var(--seam-ink); border-color: var(--seam); }
.btn-primary:hover { background: #ffc95e; border-color: #ffc95e; }
.btn-quiet { border-color: transparent; text-decoration: underline; text-decoration-color: var(--rail); text-underline-offset: 0.25em; }

/* result */
.result { position: relative; padding-block: 1rem 4rem; border-top: 1px solid var(--rail-faint); }
.age-block { padding-top: 2rem; }
#result-title { font-size: var(--step-2); font-weight: 600; letter-spacing: -0.01em; }
#result-title:focus { outline: none; }
#result-title:focus-visible { outline: 3px solid var(--focus); }
.days { color: var(--seam); font-weight: 800; font-size: 1.35em; letter-spacing: -0.02em; white-space: nowrap; }
.age-sub { margin-top: 0.5rem; color: var(--chalk-dim); font-size: var(--step-1); }
.example-tag {
  display: inline-block; vertical-align: 0.2em; margin-right: 0.4rem; padding: 0.15rem 0.6rem;
  font-size: var(--step--1); font-weight: 700; letter-spacing: 0.02em;
  color: var(--chalk); border: 1px dashed var(--chalk-dim); border-radius: 999px;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem; }
.status { min-height: 1.6em; margin-top: 0.75rem; color: var(--chalk-dim); font-size: var(--step--1); }
.copy-fallback { width: 100%; min-height: 10rem; margin-top: 0.5rem; padding: 0.75rem; font: inherit; font-size: var(--step--1); color: var(--chalk); background: var(--field-deep); border: 2px solid var(--seam); border-radius: var(--radius); }
.notice { margin-top: 1rem; padding: 1rem 1.25rem; background: var(--field-raise); border-radius: var(--radius); max-width: 46rem; }
.load-error { margin-top: 2rem; display: grid; gap: 1rem; justify-items: start; }

/* legend: says what the drawing means before the first strip */
.legend { margin-top: 2rem; display: grid; gap: 0.75rem; max-width: 52rem; font-size: var(--step--1); color: var(--chalk-dim); }
.legend-how { color: var(--chalk); max-width: 60ch; }
.legend-keys { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.legend-keys li { display: inline-flex; align-items: center; gap: 0.5rem; }
.key-range { display: inline-block; width: 2.25rem; height: 0.9rem; border: 2px solid var(--chalk-dim); border-radius: 999px; }
.key-seam { display: inline-block; width: 3px; height: 1.3rem; background: var(--seam); border-radius: 2px; }

/* the shared axis stays pinned while the strips scroll under it */
.axis, .track { --x: 0%; }
.axis {
  position: sticky; top: 0; z-index: 5; height: 3.5rem; margin-top: 1.25rem;
  font-size: 0.78rem; color: var(--chalk-dim); background: var(--field);
}
.axis-line { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--rail); }
.tick { position: absolute; left: var(--x); bottom: 0.3rem; transform: translateX(-50%); white-space: nowrap; }
.tick::after { content: ""; position: absolute; left: 50%; bottom: -0.3rem; width: 1px; height: 0.25rem; background: var(--rail); }
.tick.is-first { transform: none; }
.tick.is-first::after { left: 0; }
.tick.is-last { transform: translateX(-100%); }
.tick.is-last::after { left: auto; right: 0; }
@media (max-width: 40rem) { .tick.is-minor, .tick .unit, .you-d { display: none; } }
.you {
  position: absolute; left: clamp(4rem, var(--at), calc(100% - 4rem)); top: 0.2rem; transform: translateX(-50%);
  padding: 0.1rem 0.55rem; background: var(--seam); color: var(--seam-ink); font-weight: 750; border-radius: 999px; white-space: nowrap;
}
.you-k { font-weight: 600; }

.lives { list-style: none; margin: 0; padding: 0; }
.life { display: grid; gap: 0.75rem; padding-block: 1.25rem 1.5rem; border-bottom: 1px solid var(--rail-faint); }
.life-head h3 { font-size: var(--step-1); font-weight: 750; letter-spacing: -0.01em; }
.life-meta { color: var(--chalk-dim); font-size: var(--step--1); }
.life-meta::first-letter { text-transform: uppercase; }

.track {
  --rail-y: 1rem; --lane-h: 1.6rem; --dot: 1.375rem;
  position: relative; min-height: calc(var(--rail-y) * 2 + (var(--lanes, 1) - 1) * var(--lane-h));
}
.track::before { /* the seam segment; identical x on every strip */
  content: ""; position: absolute; top: -0.75rem; bottom: -0.75rem; left: var(--at); width: 3px; margin-left: -1.5px;
  background: var(--seam); border-radius: 2px; transform-origin: top; z-index: 1;
}
.rail {
  position: absolute; left: 0; top: var(--rail-y); height: 4px; width: var(--w); margin-top: -2px; border-radius: 2px;
  background: linear-gradient(to right, var(--chalk-dim) 0 var(--cut), var(--rail) var(--cut) 100%);
}
.rail.is-living { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }

.dot, .dot-like {
  display: inline-grid; place-items: center; width: var(--dot, 1.375rem); height: var(--dot, 1.375rem); flex: none;
  font-size: 0.72rem; font-weight: 800; line-height: 1; border-radius: 999px;
  background: var(--chalk); color: var(--field); border: 2px solid var(--chalk);
}
.dot.is-ahead, .dot-like.is-ahead { background: var(--field); color: var(--chalk); }
.dot.is-uncertain, .dot-like.is-uncertain { background: var(--field); color: var(--chalk); border: 2px dashed var(--seam); }
.dot.is-exact, .dot-like.is-exact { background: var(--seam); border-color: var(--seam); color: var(--seam-ink); }
.dot {
  position: absolute; left: var(--x); top: calc(var(--rail-y) + var(--lane) * var(--lane-h));
  width: max(var(--dot), var(--w)); margin: calc(var(--dot) / -2) 0 0 calc(var(--dot) / -2); z-index: 2;
  transition: transform 140ms ease-out, box-shadow 140ms ease-out;
}
.dot.is-range { margin-left: 0; justify-items: start; padding-left: 0.35rem; }
.dot.is-exact { box-shadow: 0 0 0 3px var(--field), 0 0 0 5px var(--seam); }
.dot::before { /* stem back to the rail for stacked markers */
  content: ""; position: absolute; left: calc(50% - 1px); bottom: 100%; width: 2px;
  height: max(0px, calc(var(--lane) * var(--lane-h) - var(--dot) + 2px)); background: var(--rail);
}
.dot.is-range::before { left: 0.55rem; }
.dot.is-hot { transform: scale(1.2); box-shadow: 0 0 0 3px var(--field), 0 0 0 5px var(--seam); z-index: 3; }

.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.fact { display: grid; grid-template-columns: 1.375rem 1fr; column-gap: 0.75rem; align-items: start; }
.fact-num { margin-top: 0.15rem; }
.fact-text { max-width: 62ch; }
.fact-lead { font-weight: 750; }
.fact.is-ahead .fact-lead { color: var(--chalk); }
.fact.is-already .fact-lead { color: var(--seam); }
.fact.is-uncertain .fact-lead { color: var(--chalk-dim); font-style: italic; }
.badge { display: inline-block; padding: 0 0.55rem; background: var(--seam); color: var(--seam-ink); font-size: var(--step--1); font-weight: 750; border-radius: 999px; }
.src-toggle {
  margin-top: 0.25rem; padding: 0.35rem 0; min-height: 2.25rem; font: inherit; font-size: var(--step--1); font-weight: 600;
  color: var(--chalk-dim); background: none; border: 0; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--rail); text-underline-offset: 0.25em;
}
.src-toggle:hover { color: var(--chalk); }
.src-toggle::after { content: " +"; }
.src-toggle[aria-expanded="true"]::after { content: " −"; }
.drawer { margin-top: 0.5rem; padding: 1rem 1.25rem; background: var(--field-deep); border-radius: var(--radius); font-size: var(--step--1); max-width: 46rem; }
.drawer dl { margin: 0; display: grid; grid-template-columns: minmax(6.5rem, max-content) 1fr; gap: 0.4rem 1rem; }
.drawer dt { color: var(--chalk-dim); font-weight: 600; }
.drawer dd { margin: 0; }
@media (max-width: 30rem) { .drawer dl { grid-template-columns: 1fr; } .drawer dd { margin-bottom: 0.4rem; } }

.is-example .lives { opacity: 0.92; }

/* desktop: names and facts on the left, strips in one shared right-hand column */
@media (min-width: 60rem) {
  .axis { margin-left: calc(45% + 2rem); }
  .life { grid-template-columns: 45% 1fr; column-gap: 2rem; padding-block: 0; border-bottom: 0; }
  .life-head { grid-column: 1; padding-top: 1.5rem; border-top: 1px solid var(--rail-faint); }
  .facts { grid-column: 1; padding-bottom: 1.5rem; }
  .track { grid-column: 2; grid-row: 1 / span 2; --rail-y: 2.4rem; border-top: 1px solid var(--rail-faint); }
  .track::before { top: 0; bottom: 0; }
}

/* the one authored moment: the seam drops through the lives when a result appears */
@media (prefers-reduced-motion: no-preference) {
  .revealed .track::before { animation: seam-drop 700ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .revealed .life:nth-child(2) .track::before { animation-delay: 60ms; }
  .revealed .life:nth-child(3) .track::before { animation-delay: 120ms; }
  .revealed .life:nth-child(4) .track::before { animation-delay: 180ms; }
  .revealed .life:nth-child(5) .track::before { animation-delay: 240ms; }
  .revealed .life:nth-child(6) .track::before { animation-delay: 300ms; }
  @keyframes seam-drop { from { transform: scaleY(0); } to { transform: scaleY(1); } }
}

/* about page */
.prose { max-width: 42rem; padding-block: clamp(2rem, 5vw, 4rem) 4rem; }
.prose h1 { font-size: var(--step-2); }
.prose h2 { font-size: var(--step-1); margin-top: 2.5rem; }
.prose p, .prose ul { margin-top: 1rem; }
.prose li { margin-top: 0.4rem; }

.foot { padding-block: 2rem 3rem; border-top: 1px solid var(--rail-faint); color: var(--chalk-dim); font-size: var(--step--1); }
.foot a { color: var(--chalk-dim); }
