/* ==========================================================================
   AI PLAYGROUND — BASE
   Reset, typography, and the editorial layout primitives every page composes
   from: hairline rules, a numbered section head, wide margins, a grid.
   ========================================================================== */

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

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-16);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  letter-spacing: var(--tr-none);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color var(--dur-3) var(--ease),
              color var(--dur-3) var(--ease);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
}
img, video { height: auto; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button { background: none; border: none; cursor: pointer; }

a { color: inherit; text-decoration: none; }

ul, ol { list-style: none; }

table { border-collapse: collapse; width: 100%; }

hr {
  border: none;
  border-top: var(--rule) solid var(--line);
}

/* --- Focus ---------------------------------------------------------------
   Visible, high contrast, and never removed. Uses :focus-visible so pointer
   users are not shown rings on click.
   ------------------------------------------------------------------------ */
:focus { outline: none; }
:focus-visible {
  outline: var(--rule-thick) solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--r-1);
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  z-index: var(--z-toast);
  padding: var(--sp-3) var(--sp-5);
  background: var(--ink);
  color: var(--ink-inverse);
  font-size: var(--t-14);
  font-weight: var(--fw-medium);
}
.skip-link:focus { top: var(--sp-4); }

/* Screen-reader-only, but focusable when it needs to be */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.sr-only-focusable:focus,
.sr-only-focusable:focus-within {
  position: static;
  width: auto; height: auto;
  overflow: visible;
  clip: auto; clip-path: none;
  white-space: normal;
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

.display-1,
.display-2,
.display-3,
.display-4 {
  font-family: var(--font-display);
  font-weight: var(--fw-regular);
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
  text-wrap: balance;
}
.display-1 { font-size: var(--t-display-1); }
.display-2 { font-size: var(--t-display-2); }
.display-3 { font-size: var(--t-display-3); line-height: var(--lh-tight); }
.display-4 {
  font-size: var(--t-display-4);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
}

.display-1 em,
.display-2 em,
.display-3 em,
.display-4 em {
  font-style: italic;
  color: var(--accent-ink);
}

/* Sans headings, for UI and dense areas where the serif would be too loud */
.h1, .h2, .h3, .h4, .h5 {
  font-family: var(--font-sans);
  font-weight: var(--fw-semi);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
  text-wrap: balance;
}
.h1 { font-size: var(--t-42); }
.h2 { font-size: var(--t-32); }
.h3 { font-size: var(--t-24); letter-spacing: var(--tr-mid); }
.h4 { font-size: var(--t-18); letter-spacing: var(--tr-mid); }
.h5 { font-size: var(--t-16); letter-spacing: var(--tr-none); }

/* Lede — the paragraph directly under a display headline */
.lede {
  font-size: clamp(var(--t-18), 1.6vw, var(--t-24));
  line-height: var(--lh-prose);
  letter-spacing: var(--tr-mid);
  color: var(--ink-secondary);
  max-width: var(--measure);
  text-wrap: pretty;
}

.prose {
  max-width: var(--measure);
  line-height: var(--lh-prose);
  color: var(--ink-secondary);
  text-wrap: pretty;
}
.prose > * + * { margin-top: var(--sp-4); }
.prose strong { color: var(--ink); font-weight: var(--fw-semi); }
.prose a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
.prose a:hover { text-decoration-thickness: 2px; }

.text-serif {
  font-family: var(--font-display);
  font-size: var(--t-21);
  line-height: var(--lh-serif);
  letter-spacing: var(--tr-none);
}

/* --- Labels and metadata -------------------------------------------------
   Mono, uppercase, wide tracking. Used for section numbers, field labels,
   category tags and any small technical annotation.
   ------------------------------------------------------------------------ */
.label {
  font-family: var(--font-mono);
  font-size: var(--t-11);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
  line-height: 1;
}
.label--ink { color: var(--ink); }
.label--accent { color: var(--accent-ink); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--t-11);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
  line-height: 1;
}
.eyebrow::before {
  content: "";
  width: 1.75rem;
  height: var(--rule);
  background: var(--accent);
  flex: none;
}
.eyebrow--bare::before { display: none; }

.mono {
  font-family: var(--font-mono);
  font-size: var(--t-12);
  letter-spacing: var(--tr-none);
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }

/* ==========================================================================
   LAYOUT PRIMITIVES
   ========================================================================== */

.shell {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.shell--narrow { max-width: 64rem; }

.rule {
  border: none;
  border-top: var(--rule) solid var(--line);
  width: 100%;
}
.rule--ink { border-top-color: var(--line-ink); }
.rule--accent { border-top-color: var(--accent); }
.rule--thick { border-top-width: var(--rule-thick); }

.section {
  padding-block: var(--section-y);
  position: relative;
}
.section--tight { padding-block: clamp(2.5rem, 5vw, 5rem); }
.section--warm { background: var(--paper-warm); }
.section--sunk { background: var(--paper-sunk); }
.section--inverse {
  background: var(--paper-inverse);
  color: var(--paper);
}
.section--inverse .lede,
.section--inverse .prose { color: rgba(255, 255, 255, 0.72); }
[data-theme="dark"] .section--inverse .lede,
[data-theme="dark"] .section--inverse .prose { color: rgba(0, 0, 0, 0.7); }

/* --- Section head --------------------------------------------------------
   The signature move of the reference layout: a hairline rule, then a small
   section number in a narrow left column, the title beside it, and the
   supporting copy set apart in a third column.
   ------------------------------------------------------------------------ */
.section-head {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: var(--sp-5) var(--sp-6);
  padding-top: var(--sp-5);
  border-top: var(--rule) solid var(--line-ink);
  margin-bottom: var(--sp-9);
}
.section-head__num {
  font-family: var(--font-mono);
  font-size: var(--t-12);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tr-label);
  color: var(--ink);
  line-height: 1.4;
}
.section-head__body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--sp-5) var(--sp-8);
  align-items: start;
}
.section-head__title {
  font-family: var(--font-display);
  font-size: var(--t-display-3);
  font-weight: var(--fw-regular);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
  text-wrap: balance;
}
.section-head__title em { font-style: italic; color: var(--accent-ink); }
.section-head__kicker {
  font-family: var(--font-mono);
  font-size: var(--t-11);
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-3);
  display: block;
}
.section-head__note {
  font-size: var(--t-16);
  line-height: var(--lh-prose);
  color: var(--ink-secondary);
  max-width: var(--measure);
  text-wrap: pretty;
  padding-top: var(--sp-2);
}

@media (max-width: 900px) {
  .section-head {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
    margin-bottom: var(--sp-7);
  }
  .section-head__body { grid-template-columns: 1fr; gap: var(--sp-4); }
}

/* --- Grids --------------------------------------------------------------- */
.grid { display: grid; gap: var(--sp-6); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--auto {
  grid-template-columns: repeat(auto-fill, minmax(min(19rem, 100%), 1fr));
}

@media (max-width: 1100px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; }
.stack-1 > * + * { margin-top: var(--sp-1); }
.stack-2 > * + * { margin-top: var(--sp-2); }
.stack-3 > * + * { margin-top: var(--sp-3); }
.stack-4 > * + * { margin-top: var(--sp-4); }
.stack-5 > * + * { margin-top: var(--sp-5); }
.stack-6 > * + * { margin-top: var(--sp-6); }
.stack-8 > * + * { margin-top: var(--sp-8); }

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--top { align-items: flex-start; }
.row--baseline { align-items: baseline; }
.row--tight { gap: var(--sp-2); }
.row--wide { gap: var(--sp-5); }

.spacer { flex: 1 1 auto; }

/* ==========================================================================
   MOTION
   Entrances are opt-in via .reveal and driven by IntersectionObserver, so
   nothing depends on animation to become readable.
   ========================================================================== */
.reveal {
  opacity: 0;
  transform: translateY(1.25rem);
  transition: opacity var(--dur-4) var(--ease),
              transform var(--dur-4) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(0.75rem); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
@keyframes sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(300%); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Reduced motion ------------------------------------------------------
   Everything decorative stops. Content that was hidden pending an entrance
   animation is forced visible so nothing is lost.
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

/* The same, but user-triggered from the interface rather than the OS */
[data-motion="off"] *,
[data-motion="off"] *::before,
[data-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
[data-motion="off"] .reveal { opacity: 1; transform: none; }

/* ==========================================================================
   PRINT
   ========================================================================== */
@media print {
  .site-nav, .site-footer, .drawer, .journey, .toast-stack { display: none; }
  body { background: #fff; color: #000; }
  .section { padding-block: 1.5rem; }
}
