/* XFINALE — THE WEB OF TIME. One wide loom: time runs left to right, the
   board's worlds run as threads top to bottom, every string is a stitch. */
:root {
  --void: #0a0604; --deep: #150c05; --panel: #1f1308; --line: #3a2510; --line-hi: #5f451f;
  --amber: #ffb020; --amber-soft: #ffd8a0; --ember: #ff5030; --brass: #c87830;
  --ink: #f4e6c6; --ink-dim: #cbb488; --ink-faint: #ab8b5c;
  --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, "Courier New", monospace;
}
* { box-sizing: border-box; }
html { background: var(--void); }
body { margin: 0; min-height: 100vh; background: var(--void); color: var(--ink); font-family: var(--display); line-height: 1.5; }
a { color: var(--amber-soft); }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: linear-gradient(180deg, rgba(10, 6, 4, 0.96) 60%, transparent); }
.brand { font-family: "Bowlby One", var(--display); color: var(--amber); text-decoration: none; font-size: 17px; letter-spacing: 0.04em; }
.brand small { font-family: var(--mono); font-size: 9px; letter-spacing: 0.3em; color: var(--ink-faint); display: block; margin-top: 1px; }
.bar nav { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.bar nav a { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); text-decoration: none; padding: 6px 2px; }
.bar nav a:hover, .bar nav a:focus-visible { color: var(--amber-soft); outline: none; }

.eyebrow { margin: 0; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-faint); }
.top { padding-block: 1.6rem 0.6rem; display: grid; gap: 0.5rem; }
h1 { font-weight: 700; font-size: clamp(2.2rem, 1.4rem + 4vw, 4.6rem); line-height: 0.95; letter-spacing: 0.06em; margin: 0; text-transform: uppercase; text-wrap: balance; }
h1 span { color: var(--amber); text-shadow: 0 0 18px rgba(255, 176, 32, 0.45); }
.lede { color: var(--ink-dim); max-width: 64ch; margin: 0; font-size: 1.05rem; }

.controls { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; padding-block: 1rem 0.6rem; }
button, input { font: inherit; }
.btn { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; background: var(--panel); color: var(--amber);
  border: 1px solid var(--line-hi); border-radius: 4px; padding: 0.5rem 0.85rem; min-height: 40px; cursor: pointer; }
.btn:hover { border-color: var(--amber); }
.btn.primary { background: var(--amber); color: var(--void); border-color: var(--amber); font-weight: 700; }
.btn:focus-visible, input:focus-visible, .chip:focus-visible, .stitch:focus-visible { outline: 2px solid var(--amber-soft); outline-offset: 2px; }
.chip { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--line-hi); border-radius: 999px;
  padding: 0.3rem 0.7rem; min-height: 32px; background: transparent; color: var(--ink-dim); cursor: pointer; display: inline-flex; gap: 0.4rem; align-items: center; }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink-dim); }
.chip i { width: 10px; height: 2px; display: inline-block; }
.chip[aria-pressed="false"] i { opacity: 0.25; }
.k-rec { background: var(--amber); } .k-pat { background: var(--ember); } .k-vis { background: var(--brass); }
#q { flex: 1 1 220px; min-width: 0; min-height: 40px; background: var(--deep); border: 1px solid var(--line-hi); color: var(--ink); border-radius: 4px; padding: 0.5rem 0.7rem; font-family: var(--mono); font-size: 0.85rem; }
#q::placeholder { color: var(--ink-faint); }
.clock { font-family: var(--mono); font-size: 0.9rem; color: var(--amber); min-width: 8ch; font-variant-numeric: tabular-nums; }

.loom-box { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px;
  background: radial-gradient(120% 80% at 70% 0%, rgba(255, 176, 32, 0.07), transparent 60%), var(--deep); }
svg#loom { display: block; min-width: 960px; width: 100%; height: auto; }
.lane-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; fill: var(--ink-faint); text-transform: uppercase; }
.lane { stroke: var(--line); stroke-width: 1; }
.tick { stroke: var(--line); stroke-dasharray: 2 4; }
.tick-label { font-family: var(--mono); font-size: 10px; fill: var(--ink-faint); }
.era-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; fill: var(--line-hi); }
.shelf-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; fill: var(--ink-faint); }
.stitch { cursor: pointer; transition: opacity 0.25s; }
.stitch line, .stitch circle.ring { fill: none; stroke-width: 1.6; }
.stitch.recorded line, .stitch.recorded circle.ring { stroke: var(--amber); }
.stitch.pattern line, .stitch.pattern circle.ring { stroke: var(--ember); stroke-dasharray: 3 3; }
.stitch.visual line, .stitch.visual circle.ring { stroke: var(--brass); stroke-dasharray: 1 3; }
.stitch circle.end { stroke: none; }
.stitch.recorded circle.end { fill: var(--amber); }
.stitch.pattern circle.end { fill: var(--ember); }
.stitch.visual circle.end { fill: var(--brass); }
/* the wide click target stays invisible whatever layer colours the stitch */
.stitch .hit { fill: transparent !important; stroke: transparent !important; filter: none !important; }
.stitch line.hit { stroke-width: 10px !important; stroke-dasharray: none; }
.stitch.future { opacity: 0; pointer-events: none; }
.stitch.dim { opacity: 0.09; }
.stitch.fresh line, .stitch.fresh circle.ring { filter: drop-shadow(0 0 4px var(--amber)); stroke-width: 2.4; }
.stitch.picked line:not(.hit), .stitch.picked circle.ring { stroke: var(--ink); stroke-width: 2.6; }
.stitch.picked circle.end { fill: var(--ink); }
.cursor { stroke: var(--amber); stroke-width: 1; opacity: 0.6; }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin: 0; padding-block: 0.6rem; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }

.read { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.2rem; padding-block: 1rem 2rem; }
@media (max-width: 760px) { .read { grid-template-columns: minmax(0, 1fr); } }
.card { border: 1px solid var(--line-hi); background: var(--panel); border-radius: 6px; padding: 1rem 1.1rem; min-width: 0; }
.card h3 { margin: 0.3rem 0 0.4rem; font-size: 1.35rem; line-height: 1.2; text-wrap: balance; }
.card h3 em { font-style: normal; color: var(--amber); }
.card p { margin: 0.3rem 0; color: var(--ink-dim); }
.card .meta { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-faint); letter-spacing: 0.06em; }
.card a { word-break: break-word; }
.thread { list-style: none; margin: 0.4rem 0 0; padding: 0; display: grid; gap: 0.25rem; max-height: 340px; overflow-y: auto; }
.thread .hint { color: var(--ink-faint); font-family: var(--mono); font-size: 0.8rem; }
.thread button { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 7.5ch minmax(0, 1fr); gap: 0.6rem; padding: 0.35rem 0.4rem; border-radius: 3px; font-size: 0.9rem; color: var(--ink-dim); }
.thread button:hover, .thread button:focus-visible { background: var(--deep); color: var(--ink); outline: 1px solid var(--line-hi); }
.thread .yr { font-family: var(--mono); color: var(--amber); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.foot { padding-block: 0 3rem; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }
.foot p { max-width: 80ch; margin: 0; }
@media (prefers-reduced-motion: reduce) { .stitch { transition: none; } }

/* the lenses: the Loom, the Sky (was /graph), the Dragon (was /dragon) */
.lenses { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding-block: 1rem 0.2rem; }
@media (max-width: 900px) { .lens span { display: none; } }
@media (max-width: 640px) { .lenses { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lens { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 56px; padding: 10px 14px 10px 16px; border-radius: 10px; cursor: pointer; text-align: left;
  color: var(--ink-dim); background: var(--deep); border: 1px solid var(--line-hi); box-shadow: inset 3px 0 0 var(--line-hi); transition: border-color 0.15s, box-shadow 0.15s, color 0.15s; }
.lens b { font-weight: 700; font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.lens span { font-family: var(--mono); font-size: 0.68rem; color: var(--ink-faint); }
.lens:hover, .lens:focus-visible { outline: none; border-color: var(--amber); }
.lens[aria-pressed="true"] { border-color: var(--amber); box-shadow: inset 3px 0 0 var(--amber), 0 0 22px -8px rgba(255, 176, 32, 0.6); }
.lens[aria-pressed="true"] b { color: var(--amber); }
@media (max-width: 520px) { .lenses { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lens span { display: none; } .lens { min-height: 48px; padding: 8px 10px; } .lens b { font-size: 0.82rem; } }
.lens-view { margin-top: 0.8rem; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #000; }
.lens-view[hidden] { display: none; }
#lens-frame { display: block; width: 100%; height: clamp(520px, 78vh, 900px); border: 0; }
#loom-view[hidden] { display: none; }
