/* =========================================================================
   THE SYSTEM — base tokens + preset overrides
   -------------------------------------------------------------------------
   `.system-root` is the sandbox where specimens live. Changing
   [data-preset] on it re-skins every specimen without touching markup.
   ========================================================================= */

.system-root {
  /* ---------- BASE (universal) — not brand-swappable ---------- */

  /* Spacing scale — 4px base, hybrid. Even steps are "layout" rhythm. */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;

  /* Type scale — hand-tuned. Body on 1.2 (minor third), display on 1.333 from H3. */
  --fs-caption: 12px;
  --fs-small: 14px;
  --fs-body: 17px;            /* reading body */
  --fs-body-ui: 15px;          /* UI body */
  --fs-lede: 20px;
  --fs-h4: 22px;
  --fs-h3: 28px;               /* hinge: 1.2 above → 1.333 from here up */
  --fs-h2: 38px;
  --fs-h1: 52px;
  --fs-display: 72px;

  /* Line heights — tight for display, loose for reading */
  --lh-display: 1.02;
  --lh-heading: 1.12;
  --lh-ui: 1.35;
  --lh-body: 1.65;              /* 28px on 17px */
  --lh-body-tight: 1.5;

  /* Measure — line-length cap for body text */
  --measure: 65ch;              /* mobile/default */
  --measure-wide: 72ch;         /* desktop long-form */

  /* Breakpoints (reference values — for JS media queries if needed) */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-2xl: 1440px;

  /* Grid — 12 col desktop, 4 col mobile */
  --grid-cols: 12;
  --grid-gutter: 24px;
  --grid-gutter-mobile: 16px;
  --grid-max: 1280px;

  /* Base shape (neutral; niches override) */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-card: 0px;
  --radius-pill: 999px;
  --radius-input: 2px;

  /* Motion */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0, 1);
  --ease-accelerate: cubic-bezier(0.3, 0, 1, 1);
  --dur-instant: 80ms;
  --dur-quick: 160ms;
  --dur-standard: 240ms;
  --dur-slow: 400ms;

  /* Depth (subtle; editorial-appropriate) */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.12);

  /* Rule weights */
  --rule-hair: 1px;
  --rule-thin: 1px;
  --rule-bold: 2px;

  /* ---------- BRAND TOKENS — default (neutral, if no preset applied) ---------- */

  --color-bg: #fdfcf9;
  --color-surface: #ffffff;
  --color-text-primary: #16150f;
  --color-text-secondary: #5c5a52;
  --color-text-muted: #8a8780;
  --color-rule: #e4e0d6;
  --color-rule-soft: #f0ede5;
  --color-accent: #2a4d8f;       /* default = calm navy */
  --color-accent-ink: #ffffff;
  --color-selection: #fde68a;

  --font-display: "GT Sectra", "Tiempos Headline", "Playfair Display", Georgia, serif;
  --font-body: "Söhne", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "Berkeley Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;

  --density: comfortable;        /* comfortable | dense */
  --card-style: minimal;          /* minimal | editorial | magazine */
  --hero-style: featured;         /* featured | grid | magazine */

  /* Brand-overridable component tokens */
  --radius-card: 0px;
  --card-border: 1px solid var(--color-rule);
  --card-shadow: none;
  --category-treatment: rule;     /* rule | pill | block */
  --nav-weight: 500;
}

/* =========================================================================
   PRESET: ANIMEAKIE — French anime/manga editorial, thoughtful, critical
   ========================================================================= */

.system-root[data-preset="animeakie"] {
  --color-bg: #f6f3ec;
  --color-surface: #fffdf7;
  --color-text-primary: #141310;
  --color-text-secondary: #585449;
  --color-text-muted: #8f8b7e;
  --color-rule: #ddd7c8;
  --color-rule-soft: #ebe6d8;
  --color-accent: #8a2e2a;           /* oxblood — literary, French, not anime-coded */
  --color-accent-ink: #fffdf7;
  --color-selection: #f2e4b8;

  --font-display: "GT Sectra", "Tiempos Headline", "Cambria", Georgia, serif;
  --font-body: "Söhne", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --density: comfortable;
  --card-style: editorial;
  --hero-style: featured;

  --radius-card: 0px;
  --card-border: 1px solid var(--color-rule);
  --card-shadow: none;
  --category-treatment: rule;
  --nav-weight: 500;
}

/* =========================================================================
   PRESET: GAMING MAG — high contrast, loud, Polygon-adjacent
   ========================================================================= */

.system-root[data-preset="gaming"] {
  --color-bg: #0e0e11;
  --color-surface: #17171c;
  --color-text-primary: #f5f4ef;
  --color-text-secondary: #a8a6a0;
  --color-text-muted: #6c6a64;
  --color-rule: #2a2a32;
  --color-rule-soft: #1f1f26;
  --color-accent: #d1ff3a;           /* acid lime */
  --color-accent-ink: #0e0e11;
  --color-selection: #d1ff3a;

  --font-display: "Druk", "Neue Haas Grotesk Display", "Helvetica Neue", Helvetica, sans-serif;
  --font-body: "Söhne", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --density: dense;
  --card-style: magazine;
  --hero-style: magazine;

  --radius-card: 2px;
  --card-border: 1px solid var(--color-rule);
  --card-shadow: none;
  --category-treatment: block;
  --nav-weight: 700;
}

/* =========================================================================
   PRESET: AUTOMOTIVE — technical, spec-heavy, restrained
   ========================================================================= */

.system-root[data-preset="automotive"] {
  --color-bg: #ffffff;
  --color-surface: #f6f6f4;
  --color-text-primary: #0a0a0a;
  --color-text-secondary: #4a4a48;
  --color-text-muted: #8a8a86;
  --color-rule: #dcdcd6;
  --color-rule-soft: #ededea;
  --color-accent: #c8102e;            /* signal red */
  --color-accent-ink: #ffffff;
  --color-selection: #ffe5e8;

  --font-display: "Neue Haas Grotesk Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Neue Haas Grotesk Text", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --density: dense;
  --card-style: minimal;
  --hero-style: grid;

  --radius-card: 0px;
  --card-border: 1px solid var(--color-rule);
  --card-shadow: none;
  --category-treatment: pill;
  --nav-weight: 600;
}

/* =========================================================================
   SPECIMEN — shared look for any element sitting inside .system-root
   ========================================================================= */

.system-root {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  transition: background-color 0.4s var(--ease-standard),
              color 0.4s var(--ease-standard);
}

.system-root .specimen-surface {
  background: var(--color-bg);
  color: var(--color-text-primary);
  padding: var(--space-6);
  transition: background-color 0.4s var(--ease-standard);
}

/* specimens — type */
.system-root .type-row {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: baseline;
  gap: var(--space-5);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-rule-soft);
}
.system-root .type-row:last-child { border-bottom: none; }
.system-root .type-row .label {
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.system-root .type-row .val {
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  text-align: right;
}
.system-root .type-row .display {
  font-family: var(--font-display);
  color: var(--color-text-primary);
}
.system-root .type-row .body {
  font-family: var(--font-body);
  color: var(--color-text-primary);
}

.t-display { font-size: var(--fs-display); line-height: var(--lh-display); letter-spacing: -0.02em; }
.t-h1      { font-size: var(--fs-h1);      line-height: var(--lh-heading); letter-spacing: -0.02em; }
.t-h2      { font-size: var(--fs-h2);      line-height: var(--lh-heading); letter-spacing: -0.015em; }
.t-h3      { font-size: var(--fs-h3);      line-height: var(--lh-heading); letter-spacing: -0.01em; }
.t-h4      { font-size: var(--fs-h4);      line-height: 1.25;              letter-spacing: -0.005em; font-weight: 600; }
.t-lede    { font-size: var(--fs-lede);    line-height: 1.45; }
.t-body    { font-size: var(--fs-body);    line-height: var(--lh-body); }
.t-body-ui { font-size: var(--fs-body-ui); line-height: var(--lh-ui); }
.t-small   { font-size: var(--fs-small);   line-height: 1.5; }
.t-caption { font-size: var(--fs-caption); line-height: 1.4; }

/* specimens — swatch */
.system-root .swatch {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.system-root .swatch-chip {
  aspect-ratio: 4/3;
  border: 1px solid var(--color-rule);
  position: relative;
}
.system-root .swatch-name {
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 10.5px;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 6px;
}
.system-root .swatch-val {
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 11px;
  color: var(--color-text-primary);
}

/* specimens — spacing ruler */
.system-root .space-row {
  display: grid;
  grid-template-columns: 110px 80px 1fr;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}
.system-root .space-bar {
  background: var(--color-accent);
  height: 12px;
}

/* specimens — shape */
.system-root .shape-tile {
  background: var(--color-surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  padding: var(--space-5);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* specimens — motion */
.system-root .motion-bar {
  height: 3px;
  background: var(--color-accent);
  width: 0%;
  animation-fill-mode: forwards;
  animation-iteration-count: infinite;
}

/* specimens — card preview (lightweight, for preset swap demo) */
.system-root .demo-card {
  background: var(--color-surface);
  border: var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    background-color 0.4s var(--ease-standard),
    border-color 0.4s var(--ease-standard),
    border-radius 0.4s var(--ease-standard);
}
.system-root .demo-card .img {
  aspect-ratio: 16/10;
  background:
    repeating-linear-gradient(135deg,
      rgba(0,0,0,0.04) 0 1px,
      transparent 1px 8px),
    var(--color-rule-soft);
  position: relative;
}
.system-root[data-preset="gaming"] .demo-card .img {
  background:
    repeating-linear-gradient(135deg,
      rgba(255,255,255,0.04) 0 1px,
      transparent 1px 8px),
    #22222a;
}
.system-root .demo-card .img::after {
  content: "figure";
  position: absolute;
  inset: auto auto 8px 10px;
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.system-root .demo-card .body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.system-root .demo-card .cat {
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  font-weight: 600;
}
.system-root[data-preset="gaming"] .demo-card .cat,
.system-root[data-preset="automotive"] .demo-card .cat {
  display: inline-block;
  align-self: flex-start;
  color: var(--color-accent-ink);
  background: var(--color-accent);
  padding: 4px 8px;
}
.system-root[data-preset="automotive"] .demo-card .cat {
  border-radius: 999px;
}
.system-root .demo-card .title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-text-primary);
  margin: 0;
}
.system-root[data-preset="gaming"] .demo-card .title {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.005em;
}
.system-root .demo-card .meta {
  font-family: var(--font-mono, var(--doc-font-mono));
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* article specimen */
.system-root .article {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: var(--space-6);
}
.system-root .article h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: var(--lh-heading);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-3);
  color: var(--color-text-primary);
}
.system-root .article .dek {
  font-family: var(--font-body);
  font-size: var(--fs-lede);
  line-height: 1.45;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-6);
  max-width: 50ch;
}
.system-root .article p {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text-primary);
  margin: 0 0 var(--space-4);
  max-width: var(--measure);
}
.system-root .article ::selection {
  background: var(--color-selection);
  color: var(--color-text-primary);
}
