/* ============================================================
   Contour — design-system documentation chrome
   Docs-only styles. The system itself lives in style.css;
   everything here is prefixed ds- and consumes those tokens.
   ============================================================ */

:root {
  --ds-side-w: 264px;
  --ds-rail-w: 200px;
  --ds-good: #3e9c62;
  --ds-bad: #d96a5f;
  --ds-code-bg: #0b1014;
}
[data-theme="light"] {
  --ds-good: #2c7a4b;
  --ds-bad: #b03a30;
}

html[data-page="ds"] { scroll-padding-top: calc(var(--nav-h) + 16px); }
[data-page="ds"] body { background: var(--bg); }

/* ---------- Shell ---------- */
.ds-shell {
  display: grid;
  grid-template-columns: var(--ds-side-w) minmax(0, 1fr);
  max-width: 1560px;
  margin: 0 auto;
}

/* ---------- Top bar ---------- */
.ds-topbar {
  position: sticky; top: 0; z-index: 90;
  display: flex; align-items: center; gap: 1rem;
  height: var(--nav-h);
  padding: 0 clamp(1rem, 2.5vw, 2rem);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.ds-topbar__brand {
  display: inline-flex; align-items: center; gap: 0.7rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  color: var(--text); text-decoration: none;
}
.ds-topbar__brand .logo-img { width: 30px; height: 30px; }
.ds-topbar__sys { color: var(--text-dim); font-weight: 500; }
.ds-topbar__ver {
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.08em; padding: 0.28rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-dim);
}
.ds-topbar__spacer { flex: 1; }
.ds-topbar__back {
  font-size: 0.88rem; color: var(--text-dim); text-decoration: none;
  transition: color 0.25s ease;
}
.ds-topbar__back:hover { color: var(--text); }

/* ---------- Sidebar ---------- */
.ds-side {
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(1.25rem, 3vh, 2rem) 1.1rem 3rem clamp(1rem, 2.5vw, 2rem);
  border-right: 1px solid var(--line);
}
.ds-side__group { margin-bottom: 1.6rem; }
.ds-side__label {
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.ds-side__list { list-style: none; }
.ds-side__list a {
  display: block; padding: 0.42rem 0.7rem; margin-left: -0.7rem;
  border-radius: 8px; font-size: 0.92rem; color: var(--text-dim);
  text-decoration: none; transition: color 0.2s ease, background-color 0.2s ease;
}
.ds-side__list a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.ds-side__list a[aria-current="page"],
.ds-side__list a.is-active {
  color: var(--text); font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* ---------- Main column ---------- */
.ds-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--ds-rail-w);
  gap: clamp(1.5rem, 3vw, 3.5rem);
  padding: clamp(1.5rem, 4vh, 3rem) clamp(1.25rem, 3.5vw, 3.5rem) 4rem;
}
.ds-content { min-width: 0; max-width: 860px; }

/* ---------- Right rail ---------- */
.ds-rail { position: relative; }
.ds-rail__inner { position: sticky; top: calc(var(--nav-h) + 24px); font-size: 0.84rem; }
.ds-rail__label {
  font-family: var(--font-display); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 0.6rem;
}
.ds-rail ol { list-style: none; border-left: 1px solid var(--line); }
.ds-rail li a {
  display: block; padding: 0.3rem 0 0.3rem 0.9rem; margin-left: -1px;
  color: var(--text-dim); text-decoration: none; border-left: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.ds-rail li a:hover { color: var(--text); }
.ds-rail li a.is-active { color: var(--text); border-left-color: var(--accent); }

/* ---------- Typography ---------- */
.ds-crumbs { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 1rem; }
.ds-crumbs a { color: inherit; text-decoration: none; }
.ds-crumbs a:hover { color: var(--text); }
.ds-content h1 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em;
  font-size: clamp(2.1rem, 4.5vw, 3.2rem); line-height: 1.05; color: var(--text);
}
.ds-lede {
  margin-top: 0.9rem; font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  line-height: 1.65; color: var(--text-dim); max-width: 62ch;
}
.ds-section { margin-top: clamp(2.6rem, 6vh, 4rem); scroll-margin-top: calc(var(--nav-h) + 20px); }
.ds-section > h2 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.015em;
  font-size: clamp(1.45rem, 2.4vw, 1.9rem); color: var(--text);
  padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem;
}
.ds-section h3 {
  font-family: var(--font-display); font-weight: 600; font-size: 1.12rem;
  color: var(--text); margin: 1.8rem 0 0.6rem;
}
.ds-anchor { color: var(--text-dim); text-decoration: none; opacity: 0; margin-left: 0.4rem; font-weight: 400; }
.ds-section > h2:hover .ds-anchor, .ds-section h3:hover .ds-anchor { opacity: 1; }
.ds-content p { line-height: 1.7; color: var(--text-dim); max-width: 68ch; margin-bottom: 0.9rem; }
.ds-content p strong, .ds-content li strong { color: var(--text); font-weight: 600; }
.ds-content ul:not([class]), .ds-content ol:not([class]) { margin: 0 0 1rem 1.2rem; color: var(--text-dim); line-height: 1.7; }
.ds-content li { margin-bottom: 0.35rem; }
.ds-content code:not(pre code) {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.86em;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.08em 0.35em;
  color: var(--text);
}

/* ---------- Specimen frames ---------- */
.ds-spec { margin: 1.2rem 0 1.6rem; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ds-spec__bar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.ds-spec__title { font-family: var(--font-display); font-size: 0.82rem; font-weight: 600; color: var(--text-dim); }
.ds-spec__spacer { flex: 1; }
.ds-spec__themes { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.ds-spec__themes button {
  border: 0; background: none; padding: 0.3rem 0.75rem; cursor: pointer;
  font-family: var(--font-display); font-size: 0.74rem; font-weight: 600;
  color: var(--text-dim); transition: background-color 0.2s ease, color 0.2s ease;
}
.ds-spec__themes button + button { border-left: 1px solid var(--line); }
.ds-spec__themes button.is-on { background: var(--accent); color: var(--accent-contrast); }
.ds-stage {
  padding: clamp(1.5rem, 3.5vw, 2.75rem);
  background: var(--bg);
  display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem;
  transition: background-color 0.3s ease;
}
.ds-stage--elev { background: var(--bg-elev); }
.ds-stage--col { flex-direction: column; align-items: stretch; }
.ds-stage--center { justify-content: center; }
.ds-spec details { border-top: 1px solid var(--line); }
.ds-spec summary {
  padding: 0.6rem 0.9rem; cursor: pointer; list-style: none;
  font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; color: var(--text-dim);
  display: flex; align-items: center; gap: 0.5rem;
}
.ds-spec summary::before { content: "‹›"; letter-spacing: -0.1em; color: var(--accent-strong); font-weight: 700; }
.ds-spec summary:hover { color: var(--text); }

/* ---------- Code blocks ---------- */
.ds-code { position: relative; }
.ds-code pre {
  margin: 0; padding: 1rem 1.1rem; overflow-x: auto;
  background: var(--ds-code-bg); color: #dbe7ec;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem; line-height: 1.6; tab-size: 2;
}
[data-theme="light"] .ds-code pre { background: #101b21; }
.ds-code__copy {
  position: absolute; top: 0.55rem; right: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); color: #dbe7ec;
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 600;
  padding: 0.3rem 0.65rem; cursor: pointer; transition: background-color 0.2s ease;
}
.ds-code__copy:hover { background: rgba(255, 255, 255, 0.14); }

/* ---------- Token tables ---------- */
.ds-table-wrap { overflow-x: auto; margin: 1.2rem 0 1.6rem; border: 1px solid var(--line); border-radius: 14px; }
.ds-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ds-table th {
  text-align: left; font-family: var(--font-display); font-size: 0.74rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim);
  padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); background: var(--bg-elev);
  white-space: nowrap;
}
.ds-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); color: var(--text-dim); vertical-align: middle; }
.ds-table tr:last-child td { border-bottom: 0; }
.ds-table td:first-child { white-space: nowrap; }
.ds-table code { white-space: nowrap; }
.ds-swatch {
  display: inline-block; width: 38px; height: 26px; border-radius: 7px;
  border: 1px solid var(--line); vertical-align: middle;
}
.ds-badge {
  display: inline-block; font-family: var(--font-display); font-size: 0.68rem;
  font-weight: 700; letter-spacing: 0.06em; padding: 0.18rem 0.5rem;
  border-radius: 999px; white-space: nowrap;
}
.ds-badge--aaa { background: color-mix(in srgb, var(--ds-good) 18%, transparent); color: var(--ds-good); }
.ds-badge--aa { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent-strong); }
/* badge text needs extra depth on the tinted chips in light mode */
[data-theme="light"] .ds-badge--aaa { color: #1e5c37; }
[data-theme="light"] .ds-badge--aa { color: #1f5a60; }
.ds-badge--note { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-dim); }

/* ---------- Do / Don't ---------- */
.ds-dodont { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 1.2rem 0 1.6rem; }
.ds-dodont__card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ds-dodont__head {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.9rem;
  font-family: var(--font-display); font-weight: 700; font-size: 0.82rem;
}
.ds-dodont__card--do .ds-dodont__head { color: var(--ds-good); border-bottom: 2px solid var(--ds-good); }
.ds-dodont__card--dont .ds-dodont__head { color: var(--ds-bad); border-bottom: 2px solid var(--ds-bad); }
.ds-dodont__body { padding: 0.9rem; font-size: 0.9rem; line-height: 1.6; color: var(--text-dim); }
.ds-dodont__body ul { margin: 0 0 0 1.1rem; }

/* ---------- Callouts ---------- */
.ds-callout {
  display: grid; grid-template-columns: auto 1fr; gap: 0.7rem;
  border: 1px solid var(--line); border-left: 3px solid var(--accent-strong);
  border-radius: 12px; padding: 0.9rem 1rem; margin: 1.2rem 0;
  font-size: 0.92rem; line-height: 1.6; color: var(--text-dim); background: var(--bg-elev);
}
.ds-callout strong { color: var(--text); }
.ds-callout__icon { color: var(--accent-strong); font-size: 1rem; line-height: 1.5; }

/* ---------- Keyboard keys ---------- */
.ds-kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.78em;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 0.1em 0.45em; background: var(--bg-elev); color: var(--text);
}

/* ---------- Foundations visuals ---------- */
.ds-type-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1rem 1.5rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.ds-type-row:last-child { border-bottom: 0; }
.ds-type-row__sample { flex: 1 1 340px; min-width: 0; color: var(--text); overflow-wrap: break-word; }
.ds-type-row__meta { font-size: 0.78rem; color: var(--text-dim); font-family: ui-monospace, "SF Mono", Menlo, monospace; white-space: nowrap; }
.ds-radius-demo { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.ds-radius-demo figure { text-align: center; }
.ds-radius-demo .chip { width: 92px; height: 64px; background: var(--bg-elev); border: 1px solid var(--line); }
.ds-radius-demo figcaption { margin-top: 0.5rem; font-size: 0.76rem; color: var(--text-dim); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.ds-space-demo { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; }
.ds-space-demo .bar { height: 22px; background: color-mix(in srgb, var(--accent) 30%, transparent); border: 1px solid var(--accent-strong); border-radius: 5px; }
.ds-motion-demo { display: flex; flex-wrap: wrap; gap: 1.25rem; width: 100%; }
.ds-motion-demo figure { flex: 1 1 180px; text-align: center; }
.ds-motion-demo .puck {
  width: 46px; height: 46px; border-radius: 12px; background: var(--accent);
  margin: 0 auto;
}
.ds-motion-demo figure:hover .puck { transform: translateX(56px); }
.ds-motion-demo figcaption { margin-top: 0.6rem; font-size: 0.76rem; color: var(--text-dim); font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- Index page cards ---------- */
.ds-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1.4rem 0; }
.ds-card {
  display: block; border: 1px solid var(--line); border-radius: 16px;
  padding: 1.3rem 1.2rem 1.4rem; background: var(--bg-elev); text-decoration: none;
  transition: transform 0.35s var(--ease-out), border-color 0.3s ease;
}
.ds-card:hover { transform: translateY(-4px); border-color: var(--accent-strong); }
.ds-card__kicker { font-family: var(--font-display); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-strong); }
.ds-card__title { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--text); margin: 0.45rem 0 0.4rem; }
.ds-card__desc { font-size: 0.88rem; line-height: 1.6; color: var(--text-dim); }
.ds-principles { counter-reset: dsp; list-style: none; margin: 1.2rem 0 0 !important; display: grid; gap: 0.9rem; }
.ds-principles li {
  counter-increment: dsp; border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1.1rem 1rem 3.4rem; position: relative; line-height: 1.65;
}
.ds-principles li::before {
  content: "0" counter(dsp); position: absolute; left: 1.1rem; top: 1.05rem;
  font-family: var(--font-display); font-weight: 700; color: var(--accent-strong);
}

/* ---------- Prev / next pagination ---------- */
.ds-pagenav { display: flex; gap: 1rem; margin-top: clamp(2.5rem, 6vh, 4rem); }
.ds-pagenav a {
  flex: 1; border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1.1rem;
  text-decoration: none; transition: border-color 0.25s ease, transform 0.3s var(--ease-out);
}
.ds-pagenav a:hover { border-color: var(--accent-strong); transform: translateY(-2px); }
.ds-pagenav a span { display: block; font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); font-family: var(--font-display); font-weight: 600; }
.ds-pagenav a strong { font-family: var(--font-display); color: var(--text); font-size: 1.02rem; }
.ds-pagenav__next { text-align: right; }

/* ---------- Docs footer ---------- */
.ds-foot { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.ds-foot a { color: inherit; }

/* ---------- Specimen helpers ---------- */
.ds-stage .nav { position: static; width: 100%; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; }
.ds-stage .footer { width: 100%; }
.ds-stage .work__list { width: 100%; }
.ds-stage .skip-link { position: static; transform: none; display: inline-block; }
.ds-stage .loader { position: static; inset: auto; width: 100%; min-height: 200px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 1; visibility: visible; }
.ds-stage .ab-lightbox { position: static; inset: auto; width: 100%; min-height: 380px; opacity: 1; visibility: visible; border-radius: 10px; }
.ds-stage .cursor { position: static; opacity: 1; transform: none; }
.ds-stage .cursor .cursor__ring { position: static; }
.ds-stage .cursor .cursor__dot { position: static; }
.ds-stage .lab-card { position: static; transform: none; opacity: 1; visibility: visible; }
/* photography wall tokens for the framed-print specimen (page-scoped on the real site) */
.ds-stage--pgwall { --pg-wall: #16120c; --pg-mat: #f2eadc; --pg-frame: #0b0906; background: var(--pg-wall); }
[data-theme="light"] .ds-stage--pgwall { --pg-wall: #e6dfd0; --pg-mat: #ffffff; --pg-frame: #2a2620; }
.ds-stage--pgwall[data-theme="dark"] { --pg-wall: #16120c; --pg-mat: #f2eadc; --pg-frame: #0b0906; }
.ds-stage--pgwall[data-theme="light"] { --pg-wall: #e6dfd0; --pg-mat: #ffffff; --pg-frame: #2a2620; }
.ds-stage .passgate { position: static; inset: auto; width: 100%; min-height: 480px; border-radius: 10px; overflow: hidden; }
.ds-stage .gal-art { margin: 1.5rem auto; }

/* ---------- Responsive ---------- */
.ds-menu-btn {
  display: none; border: 1px solid var(--line); background: none; color: var(--text);
  border-radius: 10px; padding: 0.45rem 0.8rem; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 0.85rem;
}
@media (max-width: 1220px) {
  .ds-main { grid-template-columns: 1fr; }
  .ds-rail { display: none; }
}
@media (max-width: 900px) {
  .ds-shell { grid-template-columns: 1fr; }
  .ds-menu-btn { display: inline-block; }
  .ds-side {
    position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0; z-index: 80;
    background: var(--bg); border-right: 0; display: none;
  }
  .ds-side.is-open { display: block; }
  .ds-topbar__back { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ds-card, .ds-pagenav a, .ds-motion-demo .puck { transition: none !important; }
}
