/* =========================================================
   doc.css: reading template (privacy, case studies, blogs).
   Markup: main.doc[data-toc] > .doc__grid > article.doc__body (opt-in "on this page": aside.dnav + .djump pill, built by js/doc.js)
   Inside the body: .doc__crumbs, h1.doc__title, p.doc__lead, p.doc__meta,
   .doc__callout, h2[id], h3, p, ul, ol, .doc__table > table (td[data-label] for phones),
   figure.doc__figure > img + figcaption, blockquote,
   dl.doc__facts > div > dt + dd, .doc__stats > .doc__stat > b + span.
   ========================================================= */
.doc { --doc-w: 640px; padding: 128px var(--gutter) 96px; }
.doc__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(var(--doc-w), 100%) minmax(0, 1fr);
  column-gap: 56px;
}
.doc__body {
  grid-column: 2; min-width: 0;
  font-family: var(--font-body); font-size: 16px; line-height: 26px; color: var(--text-2);
}

/* header */
.doc__crumbs { display: flex; gap: 8px; margin: 0 0 20px; font-size: 13px; line-height: 20px; color: var(--text-3); }
.doc__crumbs a { color: var(--text-3); text-decoration: none; transition: color 150ms; }
.doc__crumbs a:hover, .doc__crumbs a:focus-visible { color: var(--text); }
.doc__crumbs [aria-current] { color: var(--text-2); }
.doc__title {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: clamp(2.25rem, 1.9rem + 1.2vw, 3rem); line-height: 1.05; letter-spacing: -0.01em; color: var(--text);
}
.doc__body > .doc__lead { margin: 20px 0 0; max-width: 36em; font-size: 18px; line-height: 28px; color: var(--text-2); }
.doc__body > .doc__meta { margin: 12px 0 0; font-size: 13px; line-height: 20px; color: var(--text-3); }
.doc__meta span + span::before { content: "·"; margin: 0 8px; }

/* text */
.doc__body > h2 {
  margin: 56px 0 12px; scroll-margin-top: 110px;
  font-family: var(--font-body); font-weight: 500; font-size: 22px; line-height: 30px; letter-spacing: -0.01em; color: var(--text);
}
.doc__body > h3 {
  margin: 32px 0 8px; scroll-margin-top: 110px;
  font-family: var(--font-body); font-weight: 500; font-size: 18px; line-height: 26px; color: var(--text);
}
.doc__body > p { margin: 0 0 16px; }
.doc__body strong { font-weight: 500; color: var(--text); }
.doc__body :is(p, li, td, figcaption, blockquote) a {
  color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: var(--border-strong); transition: text-decoration-color 150ms;
}
.doc__body :is(p, li, td, figcaption, blockquote) a:hover,
.doc__body :is(p, li, td, figcaption, blockquote) a:focus-visible { text-decoration-color: var(--accent); }
.doc__body > ul, .doc__body > ol { margin: 0 0 16px; padding: 0; }
.doc__body > ul { list-style: none; }
.doc__body > ul > li { position: relative; padding-left: 22px; margin: 0 0 8px; }
.doc__body > ul > li::before { content: ""; position: absolute; left: 4px; top: 11px; width: 5px; height: 5px; background: var(--text-3); }
.doc__body > ol { padding-left: 22px; }
.doc__body > ol > li { margin: 0 0 8px; padding-left: 4px; }
.doc__body > ol > li::marker { color: var(--text-3); }
.doc__body > blockquote {
  margin: 24px 0; padding: 2px 0 2px 18px; border-left: 2px solid var(--accent);
  font-size: 18px; line-height: 28px; color: var(--text);
}

/* callout */
.doc__callout {
  margin: 40px 0 0; padding: 18px 20px; border: 1px solid var(--border-strong); border-radius: 12px;
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.doc__callout p { margin: 0; color: var(--text); }
.doc__callout .doc__k { margin: 0 0 6px; font-family: var(--font-display); font-size: 15px; line-height: 20px; color: var(--accent-text); }

/* table */
.doc__table { margin: 4px 0 16px; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; }
.doc__table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 22px; }
.doc__table th {
  padding: 10px 16px; text-align: left; font-weight: 500; font-size: 12px; letter-spacing: .02em; color: var(--text-3);
  background: color-mix(in srgb, var(--text) 3%, transparent); border-bottom: 1px solid var(--border-strong);
}
.doc__table td { padding: 14px 16px; vertical-align: top; color: var(--text-2); border-bottom: 1px solid var(--border); }
.doc__table tr:last-child td { border-bottom: 0; }
.doc__table td:first-child { width: 34%; font-weight: 500; color: var(--text); }
.doc__table td small { display: block; margin-top: 2px; font-size: 13px; line-height: 20px; font-weight: 400; color: var(--text-3); }

/* figure (case studies) */
.doc__figure { margin: 32px 0; }
.doc__figure img { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--border); }
.doc__figure figcaption { margin-top: 10px; font-size: 13px; line-height: 20px; color: var(--text-3); }

@media (max-width: 47.99rem) {
  .doc { padding-top: 104px; }
  .doc__grid { display: block; }
  .doc__table thead { display: none; }
  .doc__table tr { display: block; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .doc__table tr:last-child { border-bottom: 0; }
  .doc__table td { display: block; width: auto; padding: 0; border: 0; }
  .doc__table td + td { margin-top: 10px; }
  .doc__table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 12px; line-height: 16px; color: var(--text-3); }
}

/* ---------- On this page: game-menu panel (opt-in: main.doc[data-toc], built by js/doc.js) ---------- */
/* ---- desktop panel ---- */
.dnav {
  grid-area: 1 / 1; place-self: start end;
  position: sticky; top: 120px;
  width: 264px; margin-right: 32px;
  max-height: calc(100vh - 152px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: 16px 8px 8px;
  border: 1px solid var(--border-strong); border-radius: 16px;
  background: color-mix(in srgb, var(--text) 3%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 6%, transparent);
}
.dnav::-webkit-scrollbar { display: none; }
.dnav__head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 10px; }
.dnav__label { font-family: var(--font-display); font-size: 16px; line-height: 20px; color: var(--text); text-transform: lowercase; }
.dnav__count { font-family: var(--font-display); font-size: 14px; line-height: 20px; letter-spacing: .04em; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* XP bar: one track, accent fill, 2px pixel notches every 8px */
.dnav__bar { position: relative; height: 6px; margin: 0 10px 14px; background: color-mix(in srgb, var(--text) 8%, transparent); }
.dnav__bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--p, 0) * 100%); background: var(--accent); transition: width 200ms steps(4); }
.dnav__bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 6px, color-mix(in srgb, var(--bg) 70%, transparent) 6px 8px); }

.dnav ol { list-style: none; margin: 0; padding: 0; }
.dnav a {
  position: relative; display: flex; align-items: center;
  min-height: 38px; padding: 8px 12px 8px 46px; border-radius: 8px;
  font-size: 15px; line-height: 22px; color: var(--text-2); text-decoration: none;
  transition: color 120ms, background 120ms;
}
/* level number */
.dnav a::before {
  content: attr(data-n); content: attr(data-n) / "";
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-display); font-size: 13px; line-height: 16px; letter-spacing: .04em;
  color: var(--text-3);
}
.dnav a.done::before, .dnav a.is-parent::before { color: color-mix(in srgb, var(--accent) 75%, var(--text-3)); }
.dnav a.is-parent { color: var(--text); }

/* sub-items: indented under a 1px guide line */
.dnav a.sub { min-height: 34px; padding-left: 60px; font-size: 14px; line-height: 20px; color: var(--text-3); }
.dnav a.sub::before { content: ""; left: 50px; top: 0; bottom: 0; width: 1px; transform: none; background: var(--border-strong); }
.dnav a.sub.done::before { background: color-mix(in srgb, var(--accent) 45%, transparent); }

.dnav a:hover, .dnav a:focus-visible { color: var(--text); background: color-mix(in srgb, var(--text) 4%, transparent); }
.dnav a.is-active { color: var(--text); font-weight: 500; background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* current level: pixel arrow replaces the number */
.dnav a.is-active:not(.sub)::before {
  content: ""; left: 18px; width: 5px; height: 8px; transform: translateY(-50%);
  background: var(--accent);
  clip-path: polygon(0 0,20% 0,20% 12.5%,40% 12.5%,40% 25%,60% 25%,60% 37.5%,80% 37.5%,80% 62.5%,60% 62.5%,60% 75%,40% 75%,40% 87.5%,20% 87.5%,20% 100%,0 100%);
}
/* current sub: guide line becomes a 3px accent bar */
.dnav a.sub.is-active::before { left: 49px; width: 3px; background: var(--accent); }

[data-theme="light"] .dnav a.done::before,
[data-theme="light"] .dnav a.is-parent::before { color: color-mix(in srgb, var(--accent) 55%, var(--text)); }

.doc--toc .doc__body { grid-column: 2; grid-row: 1; }
/* 1024–1439: two columns, centred (fixes the 1250–1439 clipping) */
@media (min-width: 1024px) and (max-width: 1439px) {
  .doc--toc .doc__grid { grid-template-columns: 248px min(var(--doc-w), 100%); justify-content: center; column-gap: 56px; }
  .doc--toc .dnav { width: 248px; margin-right: 0; }
}

/* ---- phone / tablet: bar beside the dock ---- */
.djump { display: none; }
@media (max-width: 1023px) {
  .doc--toc .doc__grid { display: block; }
  .doc--toc .doc__grid > .dnav { display: none; }

  .djump {
    display: block; position: fixed; z-index: 60;
    left: var(--dock-edge); right: calc(var(--dock-edge) + 54px + 8px); bottom: var(--dock-edge);
  }
  .djump__btn {
    position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 12px;
    width: 100%; height: 54px; padding: 0 16px 0 8px;
    border: 1px solid var(--dock-border); border-radius: 12px;
    background: var(--dock-bg);
    -webkit-backdrop-filter: blur(var(--dock-blur)) saturate(var(--bar-sat));
    backdrop-filter: blur(var(--dock-blur)) saturate(var(--bar-sat));
    box-shadow: var(--dock-shadow);
    font: inherit; color: var(--text); cursor: pointer; text-align: left;
  }
  .djump__num {
    flex: 0 0 auto; display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    font-family: var(--font-display); font-size: 18px; line-height: 1; color: var(--accent);
  }
  [data-theme="light"] .djump__num { color: color-mix(in srgb, var(--accent) 55%, var(--text)); }
  .djump__txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
  .djump__kicker { font-family: var(--font-display); font-size: 12px; line-height: 14px; color: var(--text-3); text-transform: lowercase; }
  .djump__name { max-width: 100%; font-size: 15px; line-height: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* pixel caret: up when closed, down when open */
  .djump__caret {
    flex: 0 0 auto; width: 10px; height: 6px; background: var(--text-2);
    clip-path: polygon(40% 0,60% 0,60% 16.6%,80% 16.6%,80% 50%,100% 50%,100% 100%,80% 100%,80% 83.3%,60% 83.3%,60% 50%,40% 50%,40% 83.3%,20% 83.3%,20% 100%,0 100%,0 50%,20% 50%,20% 16.6%,40% 16.6%);
  }
  .djump__btn[aria-expanded="true"] .djump__caret { transform: scaleY(-1); }
  /* progress line along the bottom edge (clipped by the radius) */
  .djump__bar { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p, 0) * 100%); background: var(--accent); transition: width 200ms steps(4); }

  /* the opened panel: same width as the bar, 8px above it */
  .djump .dnav {
    position: absolute; left: 0; right: auto; bottom: 62px; top: auto;
    width: 100%; margin: 0; max-height: 60vh;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    box-shadow: 0 18px 40px -16px rgb(0 0 0 / .7);
  }
  .djump .dnav[hidden] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dnav__bar::before, .djump__bar { transition: none; }
}

/* ---------- case-study pieces ---------- */
.doc__facts {
  display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 8px; padding: 16px 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.doc__facts div { padding-right: 12px; }
.doc__facts dt { font-size: 12px; line-height: 16px; color: var(--text-3); }
.doc__facts dd { margin: 4px 0 0; font-size: 14px; line-height: 20px; color: var(--text); }
.doc__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 8px 0 24px; }
.doc__stat { padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: 12px; }
.doc__stat b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 36px; color: var(--text); }
.doc__stat span { display: block; margin-top: 4px; font-size: 13px; line-height: 20px; color: var(--text-3); }
@media (max-width: 47.99rem) {
  .doc__facts { grid-template-columns: repeat(2, 1fr); row-gap: 16px; }
  .doc__stats { grid-template-columns: 1fr; }
}
