/* ==========================================================
   DESIGN SYSTEM PAGE
   Page-specific pieces only. Everything else comes from the live
   site styles, system.css, and home.css, so the page is built from the system
   it documents.
========================================================== */

/* ---------- page header ---------- */

.ds-top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
}

.ds-top .ds-back {
  margin-right: auto;
}

.ds-hero {
  padding: 72px 0 56px;
}

.ds-hero h1 {
  max-width: 14ch;
  margin: 0 0 24px;
  font-family: "Gloock", Georgia, serif;
  font-size: clamp(2.6rem, 5vw, 4.25rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.ds-dek {
  max-width: 640px;
  margin: 0 0 40px;
  color: var(--muted);
  font-size: clamp(1rem, 1.15vw, 1.1rem);
  line-height: 1.6;
}

html[data-theme="dark"] .ds-hero h1 {
  color: var(--headline);
}

html[data-theme="dark"] .ds-dek {
  color: #dcdfe0;
}

.ds-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  max-width: 920px;
  margin: 0;
}

.ds-facts dt,
.ds-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ds-facts dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- system-at-a-glance board ---------- */

.ds-board {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.2fr 1fr;
  gap: 1px;
  margin-top: 48px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.ds-board__cell {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  min-height: 180px;
  padding: 20px;
  background: color-mix(in srgb, var(--background) 88%, transparent);
}

.ds-board__aa {
  font-family: "Gloock", Georgia, serif;
  font-size: 4.5rem;
  line-height: 0.9;
}

html[data-theme="dark"] .ds-board__aa {
  color: var(--headline);
}

.ds-board__portrait {
  align-items: flex-start;
}

.ds-board__photo {
  width: auto;
  height: 112px;
}

html[data-theme="dark"] .ds-only-light,
html:not([data-theme="dark"]) .ds-only-dark {
  display: none;
}

.ds-board__chips {
  flex-flow: row wrap;
  align-content: space-between;
  gap: 8px;
}

.ds-board__chip {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.4);
}

.ds-board__chips .ds-label {
  flex-basis: 100%;
  margin: 0;
}

.ds-board__card {
  width: 120px;
  height: 90px;
  border-radius: 2px;
  background: var(--surface-secondary);
  box-shadow: -8px 6px 0 var(--accent);
  transform: translate(4px, -4px);
}

.ds-board .ds-label {
  margin: 0;
}

/* ---------- links and code ---------- */

.ds-link {
  color: var(--accent-text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ds-code {
  margin: 32px 0 0;
  padding: 20px 24px;
  overflow-x: auto;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: 0.8rem/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace;
}

html:not([data-theme="dark"]) .ds-code {
  background: rgba(0, 0, 0, 0.05);
}

/* ---------- part divider ---------- */

.ds-part {
  margin-top: 24px;
  padding: 56px 0 52px;
  background: rgba(0, 0, 0, 0.15);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.15);
  clip-path: inset(0 -100vmax);
}

html:not([data-theme="dark"]) .ds-part {
  background: rgba(190, 112, 62, 0.12);
  box-shadow: 0 0 0 100vmax rgba(190, 112, 62, 0.12);
}

.ds-part h2 {
  margin: 0 0 12px;
  font-family: "Gloock", Georgia, serif;
  font-size: clamp(2.2rem, 4vw, 3.25rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

html[data-theme="dark"] .ds-part h2 {
  color: var(--headline);
}

.ds-part p {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.rw-section--first {
  border-top: 0;
}

/* ---------- prose ---------- */

.ds-prose {
  max-width: 68ch;
}

.ds-prose p,
.ds-prose li {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.7;
}

.ds-prose p strong,
.ds-prose li strong {
  color: var(--text);
  font-weight: 600;
}

.ds-prose ul {
  margin: 0 0 1em;
  padding-left: 1.2em;
}

.ds-sub {
  margin: 40px 0 16px;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
}

html[data-theme="dark"] .ds-sub,
html[data-theme="dark"] .ds-card h3,
html[data-theme="dark"] .ds-step h3 {
  color: var(--headline);
}

/* ---------- process steps ---------- */

.ds-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px;
  margin: 32px 0 8px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.ds-step {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.ds-step h3,
.ds-card h3 {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

.ds-step p,
.ds-card p,
.ds-card li {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---------- two-column cards (human / AI, do / don't) ---------- */

.ds-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 48px;
}

.ds-card {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.ds-card ul {
  margin: 12px 0 0;
  padding-left: 1.1em;
}

.ds-card li + li {
  margin-top: 8px;
}

.ds-card--do h3::before,
.ds-card--dont h3::before {
  display: inline-block;
  width: 1.2em;
  content: "✓";
  color: var(--accent-text);
}

.ds-card--dont h3::before {
  content: "✕";
  color: var(--muted);
}

/* ---------- decision log ---------- */

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.55;
}

.ds-table th {
  padding: 0 16px 10px 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.ds-table td {
  padding: 14px 16px 14px 0;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.ds-table td:first-child {
  width: 30%;
  font-weight: 600;
}

.ds-table td + td {
  color: var(--muted);
}

.ds-table .ds-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ds-table .ds-pass {
  color: var(--accent-text);
  font-weight: 600;
}

.ds-table .ds-fail {
  color: #f5946f;
  font-weight: 600;
}

html:not([data-theme="dark"]) .ds-table .ds-fail {
  color: #ad4500;
}

/* ---------- colour swatches ---------- */

.ds-themes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
}

/* Each theme panel shows its own palette regardless of the page theme. */
.ds-theme {
  padding: 24px;
  border-radius: 4px;
}

.ds-theme--dark {
  background: #2a2d30;
  color: #eceeee;
}

.ds-theme--light {
  background: #f3f2ee;
  color: #171717;
  box-shadow: inset 0 0 0 1px rgba(23, 23, 23, 0.14);
}

.ds-theme__name {
  margin: 0 0 20px;
  font-family: "Gloock", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
}

.ds-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 16px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ds-swatch__chip {
  height: 52px;
  margin-bottom: 8px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.35);
}

.ds-swatch b {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
}

.ds-swatch code,
.ds-swatch span {
  display: block;
  font-size: 0.7rem;
  line-height: 1.45;
  opacity: 0.75;
}

.ds-swatch code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* ---------- type specimens ---------- */

.ds-specimen {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 8px 32px;
  align-items: baseline;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.ds-specimen__meta {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.ds-specimen__meta b {
  display: block;
  color: var(--text);
  font-size: 0.78rem;
}

.ds-specimen__sample {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ds-s-display {
  font-family: "Gloock", Georgia, serif;
  font-size: clamp(3rem, 5vw, 4.25rem);
  line-height: 1;
}

.ds-s-h2 {
  font-family: "Gloock", Georgia, serif;
  font-size: 1.65rem;
  line-height: 1.15;
}

.ds-s-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
}

.ds-s-lede {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.2rem;
  font-style: italic;
}

.ds-s-pagetitle {
  font-family: "Gloock", Georgia, serif;
  font-size: clamp(2.6rem, 5vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.ds-s-longform {
  max-width: 60ch;
  font-size: 1rem;
  line-height: 1.7;
}

.ds-s-body {
  max-width: 60ch;
  font-size: 1rem;
  line-height: 1.6;
}

.ds-s-label {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ds-s-nav {
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

html[data-theme="dark"] .ds-s-pagetitle,
html[data-theme="dark"] .ds-s-display,
html[data-theme="dark"] .ds-s-h2,
html[data-theme="dark"] .ds-s-title,
html[data-theme="dark"] .ds-s-lede {
  color: var(--headline);
}

/* ---------- spacing + layout rows ---------- */

/* Shared row list: key column + description, same size as card body. */
.ds-rows {
  display: grid;
  gap: 12px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.ds-rows li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 16px;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.ds-rows--wide li {
  grid-template-columns: 80px 1fr;
}

.ds-rows__key {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Fixed 72px slot for the bar (the largest step), so every
   description starts on the same line. */
.ds-scale__bar {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 16px;
  align-items: center;
}

.ds-scale__bar::before {
  width: var(--w);
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

/* ---------- live demos ---------- */

.ds-demo {
  padding: 32px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
}

.ds-demo + .ds-caption {
  margin-top: 10px;
}

.ds-caption {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.ds-demo .shot {
  max-width: 340px;
}

.ds-demo .case-list {
  grid-template-columns: 1fr;
}

.ds-demo .filter-bar {
  justify-content: flex-start;
}

.ds-demo .bookshelf__list {
  columns: 1;
  max-width: 420px;
}

.ds-band-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 18px 20px;
  background: rgba(0, 0, 0, 0.15);
}

html:not([data-theme="dark"]) .ds-band-demo {
  background: rgba(190, 112, 62, 0.12);
}

.ds-band-demo span {
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ds-band-demo span:last-child {
  color: #f5946f;
}

html:not([data-theme="dark"]) .ds-band-demo span:last-child {
  color: var(--muted);
}

.ds-components {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 48px;
}

/* ---------- tray, collapse, project demos ---------- */

.ds-tray-demo {
  position: relative;
  padding: 0 0 60px;
  overflow: hidden;
}

.ds-tray-demo__tray {
  display: grid;
  padding: 12px 20px;
  background: var(--accent);
}

.ds-tray-demo__tray span,
.ds-tray-demo__tab {
  display: flex;
  align-items: center;
  min-height: 40px;
  color: #141414;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ds-tray-demo__toggle {
  margin-top: 6px;
  border-top: 1px solid rgba(20, 20, 20, 0.2);
  opacity: 0.75;
}

.ds-tray-demo__tab {
  position: absolute;
  right: 20px;
  gap: 10px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 0 0 10px 10px;
  background: var(--accent);
}

.ds-tray-demo__tab i,
.ds-collapse-demo i {
  display: block;
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(225deg);
}

.ds-collapse-demo {
  padding-top: 8px;
  padding-bottom: 8px;
}

.ds-collapse-demo div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border-top: 1px solid var(--border);
  font-family: "Gloock", Georgia, serif;
  font-size: 1.15rem;
}

.ds-collapse-demo div:first-child {
  border-top: 0;
}

.ds-collapse-demo i {
  flex: none;
  margin: -4px 4px 0 16px;
  border-width: 2px;
  color: var(--accent-text);
  transform: rotate(45deg);
}

.ds-collapse-demo .is-open i {
  margin-top: 6px;
  transform: rotate(225deg);
}

html[data-theme="dark"] .ds-collapse-demo div {
  color: var(--headline);
}

.ds-project-demo .ds-s-pagetitle {
  margin: 0 0 16px;
  font-size: 2rem;
}

.ds-project-demo dl {
  display: flex;
  gap: 32px;
  margin: 0 0 24px;
}

.ds-project-demo dt {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ds-project-demo dd {
  margin: 4px 0 0;
  font-size: 0.85rem;
  font-weight: 500;
}

.ds-project-demo__section {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.ds-project-demo__section p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.ds-project-demo__section .ds-s-h2 {
  color: var(--text);
  font-size: 1.25rem;
}

html[data-theme="dark"] .ds-project-demo__section .ds-s-h2 {
  color: var(--headline);
}

/* Room for the menu tab above the title on phones. */
@media (max-width: 760px) {
  .ds-hero {
    padding-top: 96px;
  }
}

/* ---------- texture stack diagram ---------- */

.ds-stack {
  display: grid;
  gap: 8px;
  max-width: 560px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ds-stack li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface) 40%, transparent);
}

.ds-stack__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.72rem;
  font-weight: 600;
}

.ds-stack b {
  display: block;
  font-size: 0.86rem;
}

.ds-stack span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ---------- pull quote ---------- */

.ds-prose .ds-quote {
  max-width: 30ch;
  margin: 32px 0 0;
  color: var(--text);
  font-family: "Gloock", Georgia, serif;
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  line-height: 1.25;
}

html[data-theme="dark"] .ds-prose .ds-quote {
  color: var(--headline);
}

/* ---------- responsive ---------- */

@media (max-width: 1050px) {
  .ds-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ds-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ds-themes,
  .ds-components {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .ds-hero {
    padding: 48px 0 40px;
  }

  .ds-facts,
  .ds-pair,
  .ds-steps {
    grid-template-columns: 1fr 1fr;
  }

  .ds-pair {
    grid-template-columns: 1fr;
  }

  .ds-specimen {
    grid-template-columns: 1fr;
  }

  .ds-table td:first-child {
    width: auto;
  }

  .ds-table--stack thead {
    display: none;
  }

  .ds-table--stack td {
    display: block;
    padding: 4px 0;
    border-top: 0;
  }

  .ds-table--stack tr {
    display: block;
    padding: 12px 0;
    border-top: 1px solid var(--border);
  }

  .ds-theme,
  .ds-demo {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .ds-facts,
  .ds-steps {
    grid-template-columns: 1fr;
  }
}
