/* ═══════════════════════════════════════════════════════════════════
   Dice Word List — second-edition site
   The sidebar is the book: the cover's warm-black world, constant
   across themes. The main column is the interior — warm paper in
   light mode, warm black in dark — following the OS theme unless
   manually overridden.
   Fonts: system UI for now; swap --font-display/--font-body for
   Taurus Grotesk when the webfont is ready.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", sans-serif;

  --sidebar-w: 340px;

  /* light = the book's interior: warm paper, black ink */
  --bg: #faf6f0;
  --surface: #fffcf7;
  --ink: #231a10;
  --muted: #6e6154;
  --hairline: #e6dcca;
  --link: #c2410c;
  --accent: #e8590c;
  --btn-ink: #231a10;

  /* the cover world (constant across themes — used by the sidebar) */
  --cover-bg: #140d08;
  --cover-title: #ffd8a8;
  --cover-accent: #ff922b;
  --cover-body: #e9d7bf;
  --cover-muted: #b39a7c;
  --cover-line: rgb(255 216 168 / 0.16);

  /* chart series — the book's inks (validated on this surface) */
  --c5: #e8590c;
  --c6: #7b2cbf;
  --c7: #2f9e44;
  --chart-grid: #ece1cf;
  --chart-text: #8a7a68;
  --chart-surface: #fffcf7;

  /* dice-digit ramp, hsl(280°) light→dark by value — from the book interior */
  --die-1: hsl(280 58% 55%);
  --die-2: hsl(280 58% 47.6%);
  --die-3: hsl(280 58% 40.2%);
  --die-4: hsl(280 58% 32.8%);
  --die-5: hsl(280 58% 25.4%);
  --die-6: hsl(280 58% 18%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171009;
    --surface: #211812;
    --ink: #f3e9db;
    --muted: #b7a794;
    --hairline: #33261a;
    --link: #ff922b;
    --accent: #ff922b;
    --btn-ink: #1d1207;

    --c5: #e8590c;
    --c6: #9061e8;
    --c7: #2f9e44;
    --chart-grid: #2e2115;
    --chart-text: #a4937f;
    --chart-surface: #211812;

    --die-1: hsl(280 58% 74%);
    --die-2: hsl(280 58% 68%);
    --die-3: hsl(280 58% 62%);
    --die-4: hsl(280 58% 56%);
    --die-5: hsl(280 58% 50%);
    --die-6: hsl(280 58% 44%);
  }
}

:root[data-theme="dark"] {
  --bg: #171009;
  --surface: #211812;
  --ink: #f3e9db;
  --muted: #b7a794;
  --hairline: #33261a;
  --link: #ff922b;
  --accent: #ff922b;
  --btn-ink: #1d1207;

  --c5: #e8590c;
  --c6: #9061e8;
  --c7: #2f9e44;
  --chart-grid: #2e2115;
  --chart-text: #a4937f;
  --chart-surface: #211812;

  --die-1: hsl(280 58% 74%);
  --die-2: hsl(280 58% 68%);
  --die-3: hsl(280 58% 62%);
  --die-4: hsl(280 58% 56%);
  --die-5: hsl(280 58% 50%);
  --die-6: hsl(280 58% 44%);
}

/* ── reset & base ─────────────────────────────────────────────── */

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

strong { font-weight: 650; }
sup { font-size: 0.7em; }

button { font-family: inherit; }

/* ── layout ───────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--cover-bg);
  color: var(--cover-body);
  overflow: hidden;
}

main {
  margin-left: var(--sidebar-w);
  display: block;
}

/* ── sidebar: the cover's world ───────────────────────────────── */

.filaments {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.sidebar-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  padding: 1.4rem 1.3rem 1.1rem;
  overflow-y: auto;
}

.sidebar a { color: var(--cover-accent); }

.side-head .eyebrow {
  color: var(--cover-accent);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.side-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--cover-title);
  text-shadow: 0 1px 14px rgb(20 13 8 / 0.6);
}

.side-sub {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--cover-body);
  margin-top: 0.45rem;
  text-shadow: 0 1px 10px rgb(20 13 8 / 0.7);
}

/* page samples */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.photo-thumb {
  aspect-ratio: 1;
  border: 1px solid var(--cover-line);
  border-radius: 7px;
  overflow: hidden;
  padding: 0;
  background: #241812;
  cursor: zoom-in;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.photo-thumb:hover { transform: scale(1.05); border-color: var(--cover-accent); }
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photos-hint {
  font-size: 0.7rem;
  color: var(--cover-muted);
  text-align: center;
  margin-top: 0.45rem;
}

/* buy panel */
.side-buy {
  border: 1px solid rgb(255 146 43 / 0.28);
  border-radius: 11px;
  padding: 0.85rem 0.95rem;
  background: linear-gradient(135deg, rgb(255 146 43 / 0.14), rgb(255 146 43 / 0.03));
}

.buy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.buy-price {
  font-size: 1.55rem;
  font-weight: 750;
  color: var(--cover-title);
  line-height: 1;
}
.buy-price span { font-size: 0.95rem; font-weight: 400; opacity: 0.7; }

.buy-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--cover-body);
  border: 1px solid var(--cover-line);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.sidebar a.buy-button {
  display: block;
  text-align: center;
  background: var(--cover-accent);
  color: #1d1207;
  font-weight: 650;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: 7px;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.buy-button:hover { opacity: 0.9; }
.buy-button:active { transform: scale(0.98); }

.buy-note {
  font-size: 0.7rem;
  color: var(--cover-muted);
  text-align: center;
  margin-top: 0.45rem;
}

/* question nav */
.side-nav { display: flex; flex-direction: column; gap: 2px; }

.side-nav-label {
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cover-muted);
  margin: 0 0 0.4rem 0.75rem;
}

.side-nav a {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--cover-body);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}
.side-nav a:hover { background: rgb(255 216 168 / 0.08); color: var(--cover-title); }
.side-nav a.active {
  background: rgb(255 146 43 / 0.16);
  color: var(--cover-title);
  font-weight: 650;
}

/* sidebar footer */
.side-foot { margin-top: auto; padding-top: 0.5rem; }

.theme-switch {
  display: flex;
  border: 1px solid var(--cover-line);
  border-radius: 7px;
  overflow: hidden;
  font-size: 0.75rem;
}
.theme-switch button {
  flex: 1;
  font-weight: 550;
  color: var(--cover-muted);
  background: transparent;
  border: none;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
}
.theme-switch button + button { border-left: 1px solid var(--cover-line); }
.theme-switch button[aria-pressed="true"] {
  background: rgb(255 146 43 / 0.18);
  color: var(--cover-title);
}

.side-credit {
  font-size: 0.7rem;
  color: var(--cover-muted);
  text-align: center;
  margin-top: 0.6rem;
}

/* ── main column ──────────────────────────────────────────────── */

.section {
  max-width: 700px;
  margin: 0 auto;
  padding: clamp(2.6rem, 6vh, 4rem) 2.25rem 0;
}
.section:last-of-type { padding-bottom: clamp(2.6rem, 6vh, 4rem); }

.section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 1.1rem;
}

.section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.section p { margin-bottom: 1.1rem; }

.lede { font-size: 1.15rem; }

.fine-print, .aside-link { font-size: 0.875rem; color: var(--muted); }

/* steps — a real sequence, so it gets real numbers */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 1.8rem 0;
  display: grid;
  gap: 1.4rem;
}
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 3.1rem;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 2.1rem;
  height: 2.1rem;
  border: 1.5px solid var(--accent);
  border-radius: 7px;            /* a die face */
  color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
}
.steps p { margin-bottom: 0.5rem; }
.steps p:last-child { margin-bottom: 0; }

/* the dice-roll demo, in the book's purple digit ramp */
.roll-demo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 0.7rem 0 0.9rem;
}
.die-row { display: inline-flex; gap: 0.35rem; }
.die-row svg { display: block; }
.die-row .v1 { color: var(--die-1); }
.die-row .v2 { color: var(--die-2); }
.die-row .v3 { color: var(--die-3); }
.die-row .v4 { color: var(--die-4); }
.die-row .v5 { color: var(--die-5); }
.die-row .v6 { color: var(--die-6); }
.roll-arrow { color: var(--muted); }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.code .dg-1 { color: var(--die-1); }
.code .dg-2 { color: var(--die-2); }
.code .dg-3 { color: var(--die-3); }
.code .dg-4 { color: var(--die-4); }
.code .dg-5 { color: var(--die-5); }
.code .dg-6 { color: var(--die-6); }
.roll-word { font-weight: 700; font-size: 1.15rem; }

.phrase-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.phrase-demo span {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 0.15rem 0.55rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}

/* insight aside */
.insight {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  padding: 0.9rem 1.2rem;
  margin: 1.4rem 0;
}
.insight p { margin: 0; }

/* ── chart — breaks out of the text column ────────────────────── */

.chart-card {
  /* widen beyond the 700px column, up to the space the sidebar leaves */
  --break-w: clamp(100%, calc(100vw - var(--sidebar-w) - 4.5rem), 1080px);
  width: var(--break-w);
  margin-left: calc((100% - var(--break-w)) / 2);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 1.3rem 1.4rem 1rem;
  margin-top: 1.8rem;
  margin-bottom: 1.8rem;
}

.chart-head { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.7rem; }
.chart-title { font-weight: 700; font-size: 1.05rem; }
.chart-sub { font-size: 0.85rem; color: var(--muted); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.lk { display: inline-flex; align-items: center; gap: 0.4rem; }
.lk svg line { stroke-width: 2.5; stroke-linecap: round; }
.lk-5 { stroke: var(--c5); }
.lk-6 { stroke: var(--c6); }
.lk-7 { stroke: var(--c7); }
.lk-dash { stroke-dasharray: 6 4; }

.chart-wrap { position: relative; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; min-width: 600px; height: auto; }

.chart-wrap .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-wrap .axis-text { fill: var(--chart-text); font-size: 13px; font-family: var(--font-body); }
.chart-wrap .axis-text.num { font-variant-numeric: tabular-nums; }
.chart-wrap .anno-text { fill: var(--chart-text); font-size: 12.5px; font-family: var(--font-body); }
.chart-wrap .end-label { fill: var(--ink); font-size: 13.5px; font-weight: 600; font-family: var(--font-body); }

.chart-wrap .series { fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.chart-wrap .s5 { stroke: var(--c5); }
.chart-wrap .s6 { stroke: var(--c6); }
.chart-wrap .s7 { stroke: var(--c7); }
.chart-wrap .proj { stroke-dasharray: 0.1 7; }
.chart-wrap .online { stroke-dasharray: 7 5; stroke-width: 1.8; }

.chart-wrap .dot { stroke: var(--chart-surface); stroke-width: 2; }
.chart-wrap .dot.f5 { fill: var(--c5); }
.chart-wrap .dot.f6 { fill: var(--c6); }
.chart-wrap .dot.f7 { fill: var(--c7); }

.chart-wrap .crosshair { stroke: var(--chart-text); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgb(0 0 0 / 0.14);
  padding: 0.55rem 0.7rem;
  font-size: 0.82rem;
  line-height: 1.45;
  min-width: 12.5rem;
  z-index: 5;
}
.chart-tip[hidden] { display: none; }
.chart-tip .tip-title { font-weight: 700; font-size: 0.87rem; }
.chart-tip .tip-rig { color: var(--muted); margin-bottom: 0.3rem; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 0.45rem; }
.chart-tip .tip-key { width: 14px; height: 0; border-top: 2.5px solid; border-radius: 2px; flex: none; }
.chart-tip .tip-key.dashed { border-top-style: dashed; }
.chart-tip .tip-val { font-weight: 650; }
.chart-tip .tip-name { color: var(--muted); }

.chart-note { font-size: 0.82rem; color: var(--muted); margin: 0.8rem 0 0.4rem; }
.chart-note strong { color: var(--ink); }

.chart-table summary {
  font-size: 0.84rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem 0;
}
.chart-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin: 0.5rem 0 0.4rem;
  font-variant-numeric: tabular-nums;
}
.chart-table th, .chart-table td {
  text-align: left;
  padding: 0.35rem 0.6rem 0.35rem 0;
  border-bottom: 1px solid var(--hairline);
}
.chart-table th { color: var(--muted); font-weight: 600; }

/* inline figures tied to chart series: ink text, series-colored underline
   whose dash pattern matches the line style in the chart (the book's trick) */
.fig { font-weight: 650; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-line: underline; }
.fig-5 { text-decoration-color: var(--c5); }
.fig-6 { text-decoration-color: var(--c6); }
.fig-7 { text-decoration-color: var(--c7); }
.fig-dash { text-decoration-style: dashed; }
.fig-dot { text-decoration-style: dotted; }

/* ── the book & dice sections ─────────────────────────────────── */

.features { list-style: none; display: grid; gap: 1.1rem; margin: 1.4rem 0; }
.features p { margin: 0; color: var(--muted); }

.edition-meta { font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--hairline); padding-top: 0.9rem; }

.cta-inline { margin: 1.4rem 0; }

.btn {
  display: inline-block;
  font-weight: 650;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.65rem 1.3rem;
  border-radius: 7px;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--btn-ink); }
.btn-primary:hover { opacity: 0.9; }

/* ── FAQ ──────────────────────────────────────────────────────── */

.faq-item { border-bottom: 1px solid var(--hairline); }
.faq-item:first-of-type { border-top: 1px solid var(--hairline); }
.faq-item summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.9rem 0.2rem;
  list-style-position: outside;
}
.faq-item summary:hover { color: var(--link); }
.faq-item p { padding: 0 0.2rem 1rem; color: var(--muted); margin: 0; }
.faq-item p + p { padding-top: 0; margin-top: 0.6rem; }

/* ── footer ───────────────────────────────────────────────────── */

.site-foot {
  border-top: 1px solid var(--hairline);
  max-width: 700px;
  margin: clamp(2.6rem, 6vh, 4rem) auto 0;
  padding: 1.8rem 2.25rem 3rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-foot p { margin-bottom: 0.4rem; }

/* ── lightbox ─────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(14 9 5 / 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.5);
}
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 20px;
  background: none;
  border: none;
  color: rgb(255 216 168 / 0.75);
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { color: var(--cover-title); }

/* ── responsive ───────────────────────────────────────────────── */

@media (max-width: 940px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    position: relative;   /* keeps the filament canvas contained */
    inset: auto;
    width: auto;
    height: auto;
    overflow: hidden;
  }
  .sidebar-inner {
    height: auto;
    overflow-y: visible;
    max-width: 560px;
    margin: 0 auto;
  }
  .side-foot { margin-top: 0.4rem; }

  main { margin-left: 0; }
  .section { padding-inline: 1.25rem; }
  .site-foot { padding-inline: 1.25rem; }
  .chart-card { --break-w: 100%; }
}
