/* ==========================================================================
   Bottou — Systems Atlas Project
   Tokens transcribed from Theme.swift. Sage, papery, calm.
   ========================================================================== */

:root {
  /* Surfaces & text — light */
  --bg:       #E9EDE6;
  --surface:  #F4F7F2;
  --ink:      #2C332B;
  --subtle:   #6E7A6B;
  --hairline: #D4DBCE;
  --accent:   #4F6F52;
  --on-accent: #FFFFFF;

  /* Focus rating scale — light */
  --r1: #B45A49;
  --r2: #CC8A4F;
  --r3: #B3AA66;
  --r4: #71926D;
  --r5: #376043;

  --shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
  --glow: 0 0 12px rgba(79, 111, 82, 0.25);

  /* Type */
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype",
           Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand",
             system-ui, sans-serif;

  /* Shape & measure */
  --radius: 18px;
  --measure: 36rem;
  --wide: 64rem;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #131611;
    --surface:  #1E231B;
    --ink:      #EAEFE8;
    --subtle:   #93A08F;
    --hairline: #2C332A;
    --accent:   #7BA37D;
    --on-accent: #131611;

    --r1: #C46A57;
    --r2: #D99D60;
    --r3: #C2BB76;
    --r4: #84A880;
    --r5: #5A8C65;

    --shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
    --glow: 0 0 12px rgba(123, 163, 125, 0.25);
  }
}

/* Reset ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.97rem + 0.15vw, 1.06rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Layout ----------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.measure { max-width: var(--measure); }

.band { padding-block: clamp(3rem, 7vw, 5rem); }

/* Type roles ------------------------------------------------------------- */

/* Sentence case, medium weight, subtle. Never shouty uppercase. */
.label {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--subtle);
  margin: 0 0 0.9rem;
}

.display {
  font-family: var(--serif);
  font-size: clamp(2.3rem, 1.4rem + 4vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 400;
  text-wrap: balance;
}

.h2 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2.05rem);
  line-height: 1.18;
  letter-spacing: -0.012em;
  font-weight: 400;
  margin: 0 0 0.9rem;
  text-wrap: balance;
}

.h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.3;
  margin: 0 0 0.35rem;
}

.lede {
  font-size: clamp(1.05rem, 1rem + 0.45vw, 1.22rem);
  line-height: 1.5;
  color: var(--subtle);
  max-width: 34rem;
}

.prose { color: var(--subtle); }
.prose p + p { margin-top: 0.9rem; }
.prose strong { color: var(--ink); font-weight: 600; }

.jp { font-size: 1.02em; }

/* Card ------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* Masthead --------------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1.4rem;
}

.masthead__mark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.masthead__icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.masthead__origin {
  font-size: 0.88rem;
  color: var(--subtle);
  text-decoration: none;
}

.masthead__origin:hover { color: var(--ink); }

/* Hero ------------------------------------------------------------------- */

.hero { padding-block: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 3vw, 2.5rem); }

.hero__display { margin-bottom: 1.2rem; max-width: 15ch; }

.hero__meta {
  color: var(--subtle);
  font-size: 0.9rem;
  margin-top: 1.75rem;
}

/* Signature: the day strip ------------------------------------------------ */

.strip { margin-top: clamp(2rem, 5vw, 3rem); }

.strip__scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
}

.strip__scroll::-webkit-scrollbar { display: none; }

.strip__svg {
  width: 100%;
  min-width: 42rem;
  height: auto;
}

@media (min-width: 48rem) {
  .strip__scroll { overflow: visible; margin-inline: 0; padding-inline: 0; }
  .strip__svg { min-width: 0; }
}

.strip__axis { stroke: var(--hairline); stroke-width: 1; }
.strip__tick { fill: var(--subtle); font-family: var(--sans); font-size: 12px; }
.strip__dur {
  fill: var(--ink);
  font-family: var(--rounded);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.strip__why { fill: var(--subtle); font-family: var(--sans); font-size: 12.5px; }

.strip__caption {
  color: var(--subtle);
  font-size: 0.92rem;
  margin-top: 1.1rem;
  max-width: 40rem;
}

/* Loop ------------------------------------------------------------------- */

.loop {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1.75rem;
}

.loop__step {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  display: block;
  margin-bottom: 0.5rem;
}

.loop p { color: var(--subtle); font-size: 0.96rem; }

@media (min-width: 44rem) {
  .loop { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
}

/* Stop reasons ----------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.chip {
  border: 0.5px solid var(--hairline);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
}

/* Focus scale ------------------------------------------------------------ */

.scale { margin-top: 1rem; }

.scale__row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 0.7rem;
  padding-block: 0.7rem;
  border-bottom: 0.5px solid var(--hairline);
}

.scale__row:last-child { border-bottom: 0; }

.scale__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  align-self: center;
}

.scale__dot--1 { background: var(--r1); }
.scale__dot--2 { background: var(--r2); }
.scale__dot--3 { background: var(--r3); }
.scale__dot--4 { background: var(--r4); }
.scale__dot--5 { background: var(--r5); }

.scale__n {
  font-family: var(--rounded);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--subtle);
  font-size: 0.9rem;
}

.scale__name { font-weight: 600; }
.scale__desc { color: var(--subtle); }

@media (min-width: 34rem) {
  .scale__row { grid-template-columns: auto auto 8rem 1fr; }
}

/* Heatmap ---------------------------------------------------------------- */

.heat { margin-top: 1.5rem; }

.heat__grid {
  display: grid;
  grid-template-columns: 2.6rem repeat(9, 1fr);
  gap: 4px;
  align-items: center;
}

.heat__daylabel,
.heat__timelabel {
  font-size: 0.76rem;
  color: var(--subtle);
}

.heat__timelabel { text-align: center; padding-top: 0.4rem; }

.heat__cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--hairline);
}

.heat__cell[data-r="0"] { background: var(--hairline); opacity: 0.45; }
.heat__cell[data-r="1"] { background: var(--r1); }
.heat__cell[data-r="2"] { background: var(--r2); }
.heat__cell[data-r="3"] { background: var(--r3); }
.heat__cell[data-r="4"] { background: var(--r4); }
.heat__cell[data-r="5"] { background: var(--r5); }

.heat__key {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
  font-size: 0.82rem;
  color: var(--subtle);
}

.heat__key span {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.heat__key span:nth-child(1) { background: var(--r1); }
.heat__key span:nth-child(2) { background: var(--r2); }
.heat__key span:nth-child(3) { background: var(--r3); }
.heat__key span:nth-child(4) { background: var(--r4); }
.heat__key span:nth-child(5) { background: var(--r5); }

/* Deltas ----------------------------------------------------------------- */

.deltas {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, 1fr);
  margin-top: 1.5rem;
}

.delta__k { color: var(--subtle); font-size: 0.85rem; }

.delta__v {
  font-family: var(--rounded);
  font-size: 1.7rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin: 0.15rem 0;
}

.delta__d { font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.delta__d--up { color: var(--r5); }
.delta__d--down { color: var(--r1); }

@media (min-width: 44rem) {
  .deltas { grid-template-columns: repeat(4, 1fr); }
}

/* Tabs / features -------------------------------------------------------- */

.tabs {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-top: 1.75rem;
}

.tabs p { color: var(--subtle); font-size: 0.96rem; }

@media (min-width: 44rem) {
  .tabs { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
}

/* Absent ----------------------------------------------------------------- */

.absent {
  display: grid;
  gap: 0.7rem 2rem;
  margin-top: 1.5rem;
  grid-template-columns: 1fr;
}

.absent li {
  display: flex;
  gap: 0.65rem;
  align-items: baseline;
  color: var(--subtle);
}

.absent li::before { content: "—"; color: var(--accent); flex: none; }

@media (min-width: 40rem) { .absent { grid-template-columns: 1fr 1fr; } }

/* Name ------------------------------------------------------------------- */

.glyphs {
  display: flex;
  gap: 0.9rem;
  margin: 0 0 1.75rem;
}

.glyph { min-width: 7rem; }

.glyph__char {
  font-family: var(--serif);
  font-size: 2.5rem;
  line-height: 1;
  display: block;
  margin-bottom: 0.5rem;
}

.glyph__gloss { font-size: 0.8rem; color: var(--subtle); line-height: 1.45; }

/* Family ----------------------------------------------------------------- */

.family { margin-top: 2rem; }

.family__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem 1.25rem;
  padding-block: 0.9rem;
  border-bottom: 0.5px solid var(--hairline);
  align-items: baseline;
  text-decoration: none;
}

.family__row:last-child { border-bottom: 0; }
.family__row + .family__row { margin-top: 0.6rem; }

.family__name { font-family: var(--serif); font-size: 1.08rem; }
.family__name .jp { color: var(--subtle); margin-left: 0.4rem; font-size: 0.88em; }
.family__gloss { color: var(--subtle); font-size: 0.94rem; }
.family__link { font-size: 0.85rem; color: var(--subtle); }

a.family__row:hover .family__name,
a.family__row:hover .family__link { color: var(--accent); }

@media (min-width: 44rem) {
  .family__row { grid-template-columns: 11rem 1fr auto; }
}

/* CTA -------------------------------------------------------------------- */

.cta__status {
  display: inline-block;
  border: 0.5px solid var(--hairline);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-block;
  border-radius: 999px;
  padding: 0.8rem 1.6rem;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--glow);
}

.cta__platforms { color: var(--subtle); font-size: 0.9rem; margin-top: 1.25rem; }

/* Spacing utilities ------------------------------------------------------ */

.mt-section { margin-top: 2.75rem; }
.mt-para { margin-top: 1.5rem; }

/* Footer ----------------------------------------------------------------- */

.footer {
  border-top: 0.5px solid var(--hairline);
  padding-block: 2rem 3rem;
  margin-top: 1rem;
}

.footer__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: baseline;
}

.footer__nav { display: flex; flex-wrap: wrap; gap: 1.1rem; }

.footer__nav a,
.footer__colophon a {
  font-size: 0.88rem;
  color: var(--subtle);
  text-decoration: none;
}

.footer__nav a:hover,
.footer__colophon a:hover { color: var(--accent); }

.footer__colophon { font-size: 0.88rem; color: var(--subtle); }

/* Document pages --------------------------------------------------------- */

.doc { padding-block: clamp(1.5rem, 4vw, 3rem) 4rem; }
.doc .measure { max-width: 38rem; }

.doc h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  margin: 2.4rem 0 0.6rem;
}

.doc h2:first-of-type { margin-top: 1.8rem; }
.doc p { color: var(--subtle); margin-bottom: 0.85rem; }
.doc ul { margin: 0 0 1.1rem; }

.doc ul li {
  color: var(--subtle);
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.doc ul li::before { content: "—"; color: var(--accent); flex: none; }
.doc a { color: var(--accent); text-underline-offset: 3px; }
.doc__updated { color: var(--subtle); font-size: 0.85rem; margin-top: 0.4rem; }

/* Motion ----------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .strip__block {
    transform-box: fill-box;
    transform-origin: left center;
    transform: scaleX(0);
    animation: grow 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: var(--delay, 0s);
  }
  .strip__fade {
    opacity: 0;
    animation: fade 0.4s ease forwards;
    animation-delay: var(--delay, 0s);
  }
}

/* Orchestration for the hero strip. Kept here, not inline, so the page works
   under a Content-Security-Policy without 'unsafe-inline'. */
.b1 { --delay: 0.1s; }
.b2 { --delay: 0.25s; }
.b3 { --delay: 0.4s; }
.b4 { --delay: 0.55s; }
.b5 { --delay: 0.7s; }
.f1 { --delay: 0.9s; }
.f2 { --delay: 1s; }
.f3 { --delay: 1.1s; }

@keyframes grow { to { transform: scaleX(1); } }
@keyframes fade { to { opacity: 1; } }