/* The design site's own shell. Loads after app/app.css, so the app's tokens
   (--ink, --surface, --accent…) are the site's tokens too. Every class here is
   prefixed ds- so it never collides with the app's components. */

:root {
  --ds-side: 264px;
  --ds-gutter: clamp(16px, 4vw, 56px);
  --ds-max: 1120px;
  --ds-radius: 18px;
  --ds-hair: var(--line-2);
  --ds-code-bg: var(--field-bg);
  --ds-stage: var(--board);
  --ds-font: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* The app locks html/body for a full-screen editor; the docs scroll. */
html,
body {
  height: auto;
  min-height: 100%;
  overflow: visible;
}
html {
  scroll-padding-top: 24px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
body.ds {
  font-family: var(--ds-font);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.ds a:where(:not(.ds-stage *)) {
  color: var(--accent);
  text-decoration: none;
}
.ds a:hover:where(:not(.ds-stage *)) {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ds p:where(:not(.ds-stage *)) {
  margin: 0 0 12px;
  max-width: 68ch;
  text-wrap: pretty;
}
.ds ::selection {
  background: var(--accent-soft);
}

/* ── Shell ───────────────────────────────────────────── */
.ds-shell {
  display: grid;
  grid-template-columns: var(--ds-side) minmax(0, 1fr);
  min-height: 100dvh;
}
.ds-side {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 14px 28px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  scrollbar-width: thin;
}
.ds-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 18px;
  color: var(--ink) !important;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none !important;
}
.ds-brand .brand-mark {
  width: 28px;
  height: 28px;
}
.ds-brand small {
  font-weight: 500;
  color: var(--ink-3);
  margin-left: -4px;
}
.ds-search {
  position: relative;
  margin: 0 0 14px;
}
.ds-search input {
  width: 100%;
  height: 36px;
  padding: 0 40px 0 34px;
  border: 0;
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: box-shadow 0.15s var(--ease);
}
.ds-search input:focus {
  box-shadow: 0 0 0 2px var(--accent);
}
.ds-search > svg {
  position: absolute;
  left: 10px;
  top: 50%;
  translate: 0 -50%;
  color: var(--ink-3);
  pointer-events: none;
}
.ds-search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  translate: 0 -50%;
}
.ds-results {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: min(420px, 60vh);
  overflow-y: auto;
  padding: 6px;
  border-radius: 14px;
  background: var(--menu);
  box-shadow: var(--pop-shadow), 0 0 0 1px var(--line-2);
  animation: pop-up 0.18s var(--ease);
}
.ds-results[hidden] {
  display: none;
}
.ds-results a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--ink) !important;
  font-size: 14px;
  text-decoration: none !important;
}
.ds-results a small {
  color: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
}
.ds-results a[aria-selected="true"],
.ds-results a:hover {
  background: var(--accent);
  color: var(--on-accent) !important;
}
.ds-results a[aria-selected="true"] small,
.ds-results a:hover small {
  color: oklch(1 0 0 / 0.75);
}
.ds-results p {
  margin: 0;
  padding: 10px;
  color: var(--ink-3);
  font-size: 13px;
}
.ds-nav {
  display: grid;
  gap: 2px;
}
.ds-nav > a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  color: var(--ink-2) !important;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
}
.ds-nav > a .ds-num {
  width: 18px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
.ds-nav > a:hover {
  background: var(--field-bg);
  color: var(--ink) !important;
}
.ds-nav > a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink) !important;
  box-shadow: var(--card-shadow), 0 0 0 1px var(--line);
}
.ds-sub {
  display: grid;
  gap: 1px;
  margin: 4px 0 10px 28px;
  padding-left: 10px;
  border-left: 1px solid var(--line-2);
}
.ds-sub a {
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--ink-3) !important;
  font-size: 13px;
  text-decoration: none !important;
  transition: color 0.15s, background 0.15s;
}
.ds-sub a:hover {
  color: var(--ink) !important;
}
.ds-sub a.on {
  color: var(--accent) !important;
  background: var(--accent-soft);
}
.ds-side-foot {
  margin-top: 22px;
  padding: 14px 10px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.5;
}

/* Theme switch: system, light, dark. */
.ds-theme {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 10px;
  background: var(--field-bg);
}
.ds-theme button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border-radius: 8px;
  color: var(--ink-3);
  transition: background 0.2s var(--ease), color 0.2s;
}
.ds-theme button:hover {
  color: var(--ink);
}
.ds-theme button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.12), 0 0 0 0.5px var(--line-2);
}

.ds-scrim {
  display: none;
}

/* ── Main column ─────────────────────────────────────── */
.ds-main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: 0 var(--ds-gutter) 120px;
}
.ds-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 calc(var(--ds-gutter) * -1);
  padding: 12px var(--ds-gutter);
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.ds-topbar .ds-crumb {
  margin-right: auto;
  color: var(--ink-3);
  font-size: 13px;
}
.ds-menu-btn {
  display: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--ink);
  background: var(--field-bg);
}
.ds-inner {
  max-width: var(--ds-max);
  margin: 0 auto;
}
.ds-hero {
  padding: 40px 0 28px;
}
.ds-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.ds-hero h1 {
  margin: 0 0 14px;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.ds-lede {
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 62ch;
}
.ds-section {
  padding: 48px 0 8px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}
.ds-section:first-of-type {
  border-top: 0;
  margin-top: 0;
}
.ds h2:where(:not(.ds-stage *)) {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.ds h3:where(:not(.ds-stage *)) {
  margin: 36px 0 6px;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.012em;
}
.ds h4:where(:not(.ds-stage *)) {
  margin: 20px 0 6px;
  font-size: 14px;
  font-weight: 600;
}
.ds-sub-lede {
  color: var(--ink-2);
  margin-bottom: 22px !important;
}
.ds :target {
  scroll-margin-top: 72px;
}
.ds h2[id],
.ds h3[id],
.ds [data-search] {
  scroll-margin-top: 72px;
}

/* ── Building blocks ─────────────────────────────────── */
.ds-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 240px)), 1fr));
}
.ds-card {
  background: var(--surface);
  border-radius: var(--ds-radius);
  box-shadow: var(--card-shadow), 0 0 0 1px var(--line);
  overflow: hidden;
}
.ds-card-pad {
  padding: 18px 20px;
}
/* A specimen: the live component on a stage, its name and notes below. */
.ds-spec {
  display: grid;
  background: var(--surface);
  border-radius: var(--ds-radius);
  box-shadow: var(--card-shadow), 0 0 0 1px var(--line);
  overflow: hidden;
  min-width: 0;
}
.ds-stage {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 160px;
  padding: 28px 24px;
  background-color: var(--ds-stage);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 16px 16px;
  font-size: 13px;
  line-height: normal;
  /* Fixed-position overlays (modals, toasts, palettes) stay inside. */
  transform: translateZ(0);
  overflow: hidden;
}
.ds-stage.plain {
  background-image: none;
}
.ds-stage.left {
  justify-content: flex-start;
}
.ds-stage.col {
  flex-direction: column;
  align-items: stretch;
}
.ds-stage.tall {
  min-height: 360px;
}
.ds-meta {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
}
.ds-meta strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.ds-meta p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.ds-meta code,
.ds-code {
  font-family: var(--mono);
  font-size: 12px;
}
.ds-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ds-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 99px;
  background: var(--field-bg);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.ds-tag.accent {
  background: var(--accent-soft);
  color: var(--accent);
}
/* A labelled row of states: default, hover, active… */
.ds-states {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr));
  gap: 18px 14px;
  width: 100%;
  align-items: end;
}
.ds-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 0;
}
.ds-state > small {
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 500;
}
.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ds-table th,
.ds-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.ds-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.ds-table code {
  white-space: nowrap;
}
.ds-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.ds-note {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
}
.ds-note strong {
  color: var(--accent);
}
kbd,
.ds-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2);
  font: 600 11px/1 var(--ds-font);
}
.ds-pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 99px;
  background: var(--field-bg);
  color: var(--ink) !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.15s;
}
.ds-pill-link:hover {
  background: var(--line-2);
}

/* ── Scaled frames: a full screen (iframe) shrunk to the column ─── */
.ds-frame {
  margin: 0;
  min-width: 0;
}
.ds-frame-box {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--card-shadow), 0 0 0 1px var(--line-2);
  aspect-ratio: var(--fw, 1440) / var(--fh, 900);
}
.ds-frame-box iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--fw, 1440) * 1px);
  height: calc(var(--fh, 900) * 1px);
  border: 0;
  transform-origin: 0 0;
  transform: scale(var(--s, 0.5));
  background: var(--bg);
}
.ds-frame figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 0;
  font-size: 13px;
  color: var(--ink-2);
}
.ds-frame figcaption strong {
  color: var(--ink);
  font-weight: 600;
}
.ds-frame figcaption a {
  white-space: nowrap;
  font-size: 13px;
}
.ds-frames {
  display: grid;
  gap: 28px 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 460px)), 1fr));
}

/* ── Flows: numbered steps in a row ─────────────────── */
.ds-flow {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(min(84vw, 340px), 1fr);
  gap: 16px;
  overflow-x: auto;
  padding: 4px 2px 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.ds-step {
  scroll-snap-align: start;
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}
.ds-step-n {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
}
.ds-step h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
}
.ds-step p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

/* ── Forced states for specimens (site.js clones :hover etc.) ── */
.ds-stage .is-static,
.ds-stage .is-static * {
  pointer-events: none;
}

/* ── Phone ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .ds-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .ds-side {
    position: fixed;
    z-index: 60;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    translate: -102% 0;
    transition: translate 0.35s var(--ease);
    box-shadow: var(--pop-shadow);
  }
  .ds-open .ds-side {
    translate: 0 0;
  }
  .ds-main {
    grid-column: 1;
  }
  .ds-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: oklch(0 0 0 / 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .ds-open .ds-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .ds-menu-btn {
    display: grid;
  }
  .ds-hero {
    padding-top: 20px;
  }
  .ds-stage {
    padding: 22px 16px;
  }
  .ds-table th,
  .ds-table td {
    padding: 8px;
  }
}
