/* Closing the Ring. Anomander documents, read on screen: a dark band with the
   ring, then one ~68ch text column beside a sticky ring rail that tracks the
   arcs as you read. Every color comes from tokens.css; .dark-scope keeps the
   band and code blocks dark in both themes. */

/* bundle.css loads Inter upright only; the arc ledes need its true italic, not a synthesized slant. */
@import url("https://fonts.googleapis.com/css2?family=Inter:ital,wght@1,400&display=swap");

:root {
  --measure: 68ch;
  --rail: 248px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --t-hero: clamp(40px, 6.4vw, 66px);
  --t-h1: clamp(32px, 4.6vw, 46px);
  --t-h2: 26px;
  --t-h3: 20px;
  --t-lede: 18px;
  --t-body: 16px;
  --t-small: 14px;
  --t-label: 12.5px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* One tone per week: the hero ring, the week cards and the week bands share them.
   Declared on .dark-scope too, so the band resolves them against the dark palette. */
:root, .dark-scope {
  --tone-1: var(--accent-fill);
  --tone-2: var(--teal);
  --tone-3: var(--rose);
  --tone-4: var(--ink);
}

/* site.js sets .smooth on the reader's first input, so in-page links glide but
   the browser's own restore on Back lands at once instead of gliding from the top. */
@media (prefers-reduced-motion: no-preference) { html.smooth { scroll-behavior: smooth; } }

body {
  font-size: var(--t-body); line-height: 1.65; background: var(--surface); color: var(--ink);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--surface);
}

.wrap { max-width: 1120px; margin: 0 auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); box-sizing: border-box; }

a { color: var(--link); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: var(--stroke-focus) solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm);
}
p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }

.kicker, .label {
  margin: 0; font-family: var(--font-mono); font-size: var(--t-label); font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--teal);
}

/* ---------- Band ---------- */
.band { background: var(--band); border-bottom: var(--stroke-focus) solid var(--focus); color: var(--text); }
.band .wrap { padding-block: 18px 48px; }

.topnav {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 24px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .1em; text-transform: uppercase;
}
.topnav a { color: var(--mist); text-decoration: none; }
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--accent); }
.topnav .home { font-weight: 700; }
.weeks-nav { display: flex; gap: 18px; }

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 48px; align-items: center; margin-top: 40px;
}
.hero-text { display: grid; gap: 16px; min-width: 0; }
.hero .label { color: var(--teal); font-weight: 400; }
.hero h1 { margin: 0; font-size: var(--t-hero); line-height: 1.02; font-weight: 700; color: var(--ink); }
.week-hero h1 { font-size: var(--t-h1); line-height: 1.08; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-lede { font-size: var(--t-lede); line-height: 1.6; color: var(--text); max-width: 58ch; }
.hero .meta { font-family: var(--font-mono); font-size: 13px; color: var(--mist); }
.hero-ring-wrap { width: 300px; max-width: 100%; display: grid; gap: 18px; }
.ring-legend {
  list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: 6px 24px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}
.ring-legend a { display: inline-flex; align-items: center; gap: 7px; color: var(--mist); text-decoration: none; }
.ring-legend a:hover { color: var(--ink); }
.swatch { width: 14px; height: 4px; border-radius: 1px; }
.swatch.tone-1 { background: var(--tone-1); } .swatch.tone-2 { background: var(--tone-2); }
.swatch.tone-3 { background: var(--tone-3); } .swatch.tone-4 { background: var(--tone-4); }
.week-hero .hero-ring-wrap { width: 168px; }

/* ---------- The ring ---------- */
.ring { display: block; width: 100%; height: auto; overflow: visible; }
.ring a { outline: none; }
.ring-num {
  font-family: var(--font-mono); font-size: 10.5px; fill: var(--mist); text-anchor: middle; dominant-baseline: central;
}
.ring .closure { fill: none; stroke: var(--focus); stroke-width: var(--stroke-focus); vector-effect: non-scaling-stroke; }

.hero-ring .track { fill: none; stroke: var(--line); stroke-width: 18; }
.hero-ring .draw { fill: none; stroke: var(--accent-fill); stroke-width: 18; stroke-dasharray: 1 1; transition: stroke-width .15s; }
.hero-ring .draw.tone-1 { stroke: var(--tone-1); } .hero-ring .draw.tone-2 { stroke: var(--tone-2); }
.hero-ring .draw.tone-3 { stroke: var(--tone-3); } .hero-ring .draw.tone-4 { stroke: var(--tone-4); }
.hero-ring a:hover .draw, .hero-ring a:focus-visible .draw { stroke-width: 22; }
.hero-ring a:focus-visible .track { stroke: var(--focus); stroke-width: 22; }
@media (prefers-reduced-motion: no-preference) {
  .hero-ring .draw { animation: ring-draw .42s cubic-bezier(.3, .6, .3, 1) both; animation-delay: calc(.2s + var(--i) * .15s); }
  .hero-ring .closure { animation: ring-close .5s ease-out 1.75s both; }
}
@keyframes ring-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ring-close { from { opacity: 0; } to { opacity: 1; } }

.seg { fill: transparent; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill .25s, stroke .25s; }
.seg.is-prev { fill: var(--mist); fill-opacity: .35; stroke: none; }
.seg.is-on, .seg.is-read { fill: var(--accent-fill); stroke: var(--accent-fill); }
.seg.is-on.tone-1 { fill: var(--tone-1); stroke: var(--tone-1); } .seg.is-on.tone-2 { fill: var(--tone-2); stroke: var(--tone-2); }
.seg.is-on.tone-3 { fill: var(--tone-3); stroke: var(--tone-3); } .seg.is-on.tone-4 { fill: var(--tone-4); stroke: var(--tone-4); }
.kicker.tone-1 { color: var(--accent); } .kicker.tone-2 { color: var(--teal); }
.kicker.tone-3 { color: var(--rose); } .kicker.tone-4 { color: var(--ink); }
.seg.is-current { fill: var(--accent); stroke: var(--focus); stroke-width: var(--stroke-focus); }
.live-ring .closure { opacity: 0; transition: opacity .3s; }
.live-ring.is-closed .closure { opacity: 1; }
.live-ring a:hover .seg:not(.is-current) { stroke: var(--accent); }
.ring-big { font-family: var(--font-mono); font-size: 30px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.ring-small { font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; fill: var(--mist); text-anchor: middle; }
@media (prefers-reduced-motion: reduce) { .seg, .live-ring .closure { transition: none; } }

/* ---------- Page layout ---------- */
.page { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: 56px; padding-block: 56px 72px; }
.week-page { grid-template-columns: minmax(0, 1fr); }
.flow { display: grid; gap: 64px; min-width: 0; max-width: var(--measure); }
.week-page .flow { max-width: 820px; }

.rail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 28px); align-self: start; display: grid; gap: 20px; }
.arc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: var(--t-small); }
.arc-list a { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 3px 0; color: var(--mist); text-decoration: none; }
.arc-list .n { font-family: var(--font-mono); }
.arc-list a:hover, .arc-list .is-read a { color: var(--ink); }
.arc-list .is-current a { color: var(--accent); font-weight: 700; }

.phonebar { display: none; }

.sec { display: grid; gap: 16px; min-width: 0; }
.sec h2, .arc h2 { margin: 0; font-size: var(--t-h2); line-height: 1.2; font-weight: 700; color: var(--accent); }
.sec ul, .sec ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
/* Each arc opens on a scene; italic in the softer text tone sets it apart from the explanation. */
.lede { font-size: var(--t-lede); line-height: 1.6; font-style: italic; color: var(--text); }
.intro { display: grid; gap: 16px; font-size: var(--t-lede); line-height: 1.6; }

/* Arcs */
.arcs { display: grid; gap: 80px; }
.arc { display: grid; gap: 16px; scroll-margin-top: 28px; min-width: 0; }
.arc .kicker { margin-bottom: -8px; }
.arc-ref { white-space: nowrap; }

.without { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 8px; padding-block: 14px; }
.without .mini-ring { width: 44px; margin-top: 2px; }
.without-text { display: grid; gap: 4px; }
.without-text span { line-height: 1.6; }

/* Tables keep the system's look; a little more air on screen. */
.ano-table { font-size: 15px; }
.ano-table td { vertical-align: top; line-height: 1.5; }
.ano-table td:first-child { color: var(--ink); font-weight: 700; padding-right: 18px; }
.ano-table-wrap { min-width: 0; }

/* One ticket: a real sequence, so it keeps its numbers. */
.steps { list-style: none; counter-reset: step; padding: 0 !important; gap: 14px !important; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; }
.steps li::before {
  content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 1px;
  font-family: var(--font-mono); font-size: 14px; color: var(--teal);
}

/* Week cards on the index */
.week-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 8px; }
.week-card {
  display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 16px; align-items: center;
  padding: 18px 18px 18px 20px; border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface-raised); color: var(--ink); text-decoration: none;
}
.week-card:hover { border-color: var(--accent-fill); }
.week-card-text { display: grid; gap: 4px; min-width: 0; }
.week-card-title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.week-card-arcs { font-family: var(--font-mono); font-size: 13px; color: var(--mist); }

/* ---------- Week pages ---------- */
.cards { display: grid; gap: 24px; margin-top: 8px; }
.card {
  display: grid; gap: 18px; padding: 24px; min-width: 0;
  background: var(--surface-raised); border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-lg);
  scroll-margin-top: 24px;
}
.card-head { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 20px; align-items: start; }
.card-title { display: grid; gap: 6px; min-width: 0; }
.card-title h3 { margin: 0; font-size: var(--t-h3); line-height: 1.3; font-weight: 700; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.chip {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; text-decoration: none;
  color: var(--teal); border: var(--stroke-hairline) solid currentColor; border-radius: var(--radius-md); padding: 1px 8px;
}
.chip:hover { color: var(--accent); }
.chip-note { font-family: var(--font-mono); font-size: 13px; color: var(--mist); }
.card-body { display: grid; gap: 14px; min-width: 0; }
.card-body ul, .card-body ol { margin: 0; }
.enforce {
  font-family: var(--font-mono); font-size: var(--t-label); letter-spacing: .1em; text-transform: uppercase; color: var(--mist);
}
.layers { list-style: none; counter-reset: layer; padding: 0 !important; display: grid; gap: 10px; }
.layers li { counter-increment: layer; position: relative; padding-left: 30px; }
.layers li::before {
  content: counter(layer); position: absolute; left: 0; top: 2px; width: 20px; height: 20px; box-sizing: border-box;
  display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; color: var(--teal);
  border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-sm);
}

/* Code: dark in both themes, with a copy button. */
.code { min-width: 0; background: var(--code-bg); border-left: var(--stroke-focus) solid var(--focus); border-radius: var(--radius-md); }
.code-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px 0 18px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--mist);
}
.code .ano-code { border-left: 0; border-radius: 0 0 var(--radius-md) 0; background: transparent; padding-top: 8px; }
.copy, .check-clear {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; cursor: pointer;
  color: var(--text); background: transparent; border: var(--stroke-hairline) solid var(--line);
  border-radius: var(--radius-md); padding: 4px 10px;
}
.copy:hover, .check-clear:hover { color: var(--ink); border-color: var(--mist); }
.copy.is-done { color: var(--teal); border-color: var(--teal); }
.prompt .code .ano-code { max-height: none; }

/* Checklist: per-viewer ticks */
.check-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.check-count { font-family: var(--font-mono); font-size: 13px; color: var(--mist); }
.checklist { list-style: none; padding: 0 !important; display: grid; gap: 8px; }
.checklist label {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; align-items: start; cursor: pointer;
  padding: 12px 14px; background: var(--surface-raised); border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-md);
}
.checklist input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--teal); }
.checklist input:checked + span { color: var(--mist); }
.check-note { font-family: var(--font-mono); font-size: 12.5px; color: var(--faint); }

.ready { list-style: none; padding: 0 !important; gap: 10px !important; }
.ready li { position: relative; padding-left: 26px; }
.ready li::before { content: ""; position: absolute; left: 0; top: .8em; width: 12px; height: 2px; background: var(--teal); }

.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pager a {
  display: grid; gap: 4px; padding: 16px 18px; text-decoration: none; color: var(--ink); font-size: 17px; font-weight: 700;
  border: var(--stroke-hairline) solid var(--line); border-radius: var(--radius-lg);
}
.pager a:hover { border-color: var(--accent-fill); }
.pager .pager-next { text-align: right; }
.pager .kicker { color: var(--mist); font-weight: 400; }

/* ---------- Footer ---------- */
.foot { border-top: var(--stroke-hairline) solid var(--line); }
.foot .wrap {
  display: flex; justify-content: space-between; gap: 16px; padding-block: 20px 28px;
  font-family: var(--font-mono); font-size: var(--t-label); color: var(--faint);
}

/* ---------- Narrow ---------- */
@media (max-width: 920px) {
  .page { grid-template-columns: minmax(0, 1fr); padding-block: 40px 56px; }
  .flow { max-width: none; }
  .rail { display: none; }
  .phonebar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
    margin: 0 calc(-1 * var(--gutter-r)) -40px calc(-1 * var(--gutter-l));
    padding: 8px var(--gutter-r) 8px var(--gutter-l);
    background: var(--surface); border-bottom: var(--stroke-hairline) solid var(--line);
  }
  .phonebar .live-ring { width: 40px; flex: none; }
  .phonebar .ring-big, .phonebar .ring-small { display: none; }
  .phonebar-label { font-family: var(--font-mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--mist); }
  .arc { scroll-margin-top: 72px; }
}
@media (max-width: 720px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 28px; }
  .hero-ring-wrap { width: 180px; }
  .week-hero .hero-ring-wrap { width: 120px; grid-row: 1; }
  .week-cards, .pager { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px 16px; }
  .card-head { grid-template-columns: minmax(0, 1fr) 44px; }
  .arcs { gap: 64px; }
  .flow { gap: 52px; }
}
