/* ============================================================================
   ZKCAP-X · V3 CANDIDATE · FOUNDATION
   Layer 1 of 6 — tokens, typography, spacing, layout, surfaces, motion.
   No component styles live here. No surface-specific rules live here.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. TOKENS
   ------------------------------------------------------------------------ */

:root {
  /* --- Institutional navy (primary structural colour) --- */
  --navy-950: #050d17;
  --navy-900: #081422;
  --navy-850: #0b1b2b;
  --navy-800: #0f2234;
  --navy-700: #16304a;
  --navy-600: #1f4162;
  --navy-500: #2d587e;

  /* --- Paper (warm, printed-document family) --- */
  --paper-000: #ffffff;
  --paper-050: #fbf8f2;
  --paper-100: #f5f1e7;
  --paper-150: #efe9dc;
  --paper-200: #e7e0d0;
  --paper-300: #d9d0bd;

  /* --- Gilt (restrained metallic accent; rules, marks, numerals) --- */
  --gilt-700: #6f561b;
  --gilt-600: #8a6c22;
  --gilt-500: #a8842c;
  --gilt-400: #c2a052;
  --gilt-300: #d8bd7e;
  --gilt-200: #eadfc2;

  /* --- Ink / text --- */
  --ink-900: #0b1725;
  --ink-800: #16273a;
  --ink-700: #33475e;
  --ink-600: #4d6076;
  --ink-500: #5b6c81;
  --ink-400: #62718a;
  --ink-300: #aab6c4;

  /* --- Signal (status semantics; institutional, not candy) --- */
  --signal-ready: #1c6b4d;
  --signal-ready-bg: #e8f1ec;
  --signal-ready-line: #bcd6c9;
  --signal-attention: #8d6410;
  --signal-attention-bg: #f8f0dd;
  --signal-attention-line: #e3cfa0;
  --signal-review: #2b4a7d;
  --signal-review-bg: #eaeff8;
  --signal-review-line: #c2cee4;
  --signal-blocker: #8a2f2f;
  --signal-blocker-bg: #f8eaea;
  --signal-blocker-line: #e2c2c2;
  --signal-unknown: #5a6474;
  --signal-unknown-bg: #eef0f2;
  --signal-unknown-line: #d3d8de;

  /* --- Lines --- */
  --line: rgba(11, 23, 37, 0.13);
  --line-soft: rgba(11, 23, 37, 0.07);
  --line-strong: rgba(11, 23, 37, 0.26);
  --line-invert: rgba(251, 248, 242, 0.18);
  --line-invert-soft: rgba(251, 248, 242, 0.09);

  /* --- Type --- */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;

  --fs-display-1: clamp(2.35rem, 5.2vw, 4.05rem);
  --fs-display-2: clamp(1.9rem, 3.6vw, 2.85rem);
  --fs-display-3: clamp(1.5rem, 2.4vw, 2rem);
  --fs-title-1: 1.5rem;
  --fs-title-2: 1.25rem;
  --fs-title-3: 1.0625rem;
  --fs-body-lg: 1.0625rem;
  --fs-body: 0.9375rem;
  --fs-body-sm: 0.875rem;
  --fs-micro: 0.75rem;
  --fs-micro-xs: 0.6875rem;

  --lh-tight: 1.08;
  --lh-snug: 1.22;
  --lh-title: 1.3;
  --lh-body: 1.6;
  --lh-loose: 1.72;

  --ls-eyebrow: 0.16em;
  --ls-label: 0.09em;
  --ls-tight: -0.015em;

  /* --- Space (4px base) --- */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.25rem;
  --s-6: 1.5rem;
  --s-8: 2rem;
  --s-10: 2.5rem;
  --s-12: 3rem;
  --s-16: 4rem;
  --s-20: 5rem;
  --s-24: 6rem;
  --s-32: 8rem;

  /* --- Structure --- */
  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  --shadow-lift: 0 1px 2px rgba(8, 20, 34, 0.05), 0 8px 24px -14px rgba(8, 20, 34, 0.28);
  --shadow-overlay: 0 24px 64px -24px rgba(5, 13, 23, 0.42), 0 2px 8px rgba(5, 13, 23, 0.12);

  --measure-narrow: 46ch;
  --measure: 62ch;
  --measure-wide: 78ch;

  --shell-max: 1280px;
  --shell-gutter: clamp(1.25rem, 4vw, 3.5rem);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 120ms;
  --dur: 220ms;

  --z-base: 1;
  --z-sticky: 40;
  --z-overlay: 80;
  --z-lab: 120;
  --z-toast: 160;
}

/* ---------------------------------------------------------------------------
   2. RESET / BASE
   ------------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--navy-950);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-800);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

button {
  cursor: pointer;
}

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

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
blockquote {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--gilt-500);
  outline-offset: 2px;
}

::selection {
  background: var(--gilt-200);
  color: var(--ink-900);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  z-index: var(--z-toast);
  background: var(--paper-050);
  border: 1px solid var(--line-strong);
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-body-sm);
}

.skip-link:focus {
  top: var(--s-4);
}

/* ---------------------------------------------------------------------------
   3. TYPOGRAPHY PRIMITIVES
   ------------------------------------------------------------------------ */

.t-display-1,
.t-display-2,
.t-display-3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--ls-tight);
  color: var(--ink-900);
  text-wrap: balance;
}

.t-display-1 {
  font-size: var(--fs-display-1);
  line-height: var(--lh-tight);
}

.t-display-2 {
  font-size: var(--fs-display-2);
  line-height: var(--lh-snug);
}

.t-display-3 {
  font-size: var(--fs-display-3);
  line-height: var(--lh-title);
}

.t-title-1 {
  font-family: var(--font-display);
  font-size: var(--fs-title-1);
  line-height: var(--lh-title);
  font-weight: 400;
  color: var(--ink-900);
  letter-spacing: var(--ls-tight);
}

.t-title-2 {
  font-family: var(--font-display);
  font-size: var(--fs-title-2);
  line-height: var(--lh-title);
  font-weight: 400;
  color: var(--ink-900);
}

.t-title-3 {
  font-family: var(--font-sans);
  font-size: var(--fs-title-3);
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink-900);
  letter-spacing: -0.005em;
}

.t-body-lg {
  font-size: var(--fs-body-lg);
  line-height: var(--lh-loose);
  color: var(--ink-700);
}

.t-body {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--ink-700);
}

.t-body-sm {
  font-size: var(--fs-body-sm);
  line-height: 1.55;
  color: var(--ink-600);
}

.t-micro {
  font-size: var(--fs-micro);
  line-height: 1.45;
  color: var(--ink-600);
}

.t-eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-micro-xs);
  font-weight: 600;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--gilt-600);
}

.t-label {
  font-family: var(--font-sans);
  font-size: var(--fs-micro-xs);
  font-weight: 600;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-500);
}

.t-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

.t-numeral {
  font-family: var(--font-display);
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 0.9375rem;
  letter-spacing: 0.04em;
  color: var(--gilt-500);
}

.t-strong {
  font-weight: 600;
  color: var(--ink-900);
}

.t-quiet {
  color: var(--ink-500);
}

.t-invert {
  color: var(--paper-050);
}

.t-invert-soft {
  color: rgba(251, 248, 242, 0.68);
}

.measure {
  max-width: var(--measure);
}

.measure-narrow {
  max-width: var(--measure-narrow);
}

.measure-wide {
  max-width: var(--measure-wide);
}

/* ---------------------------------------------------------------------------
   4. LAYOUT
   ------------------------------------------------------------------------ */

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

.shell-wide {
  width: 100%;
  max-width: 1560px;
  margin-inline: auto;
  padding-inline: var(--shell-gutter);
}

.stack {
  display: flex;
  flex-direction: column;
}

.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-5 > * + * { margin-top: var(--s-5); }
.stack-6 > * + * { margin-top: var(--s-6); }
.stack-8 > * + * { margin-top: var(--s-8); }
.stack-10 > * + * { margin-top: var(--s-10); }
.stack-12 > * + * { margin-top: var(--s-12); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.cluster-tight {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.grid {
  display: grid;
  gap: var(--s-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-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: var(--s-10);
  align-items: start;
}

.grid-sidebar-start {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: var(--s-10);
  align-items: start;
}

.rule {
  border-top: 1px solid var(--line);
}

.rule-soft {
  border-top: 1px solid var(--line-soft);
}

.rule-gilt {
  border-top: 1px solid var(--gilt-300);
}

.pad-y-4 { padding-block: var(--s-4); }
.pad-y-6 { padding-block: var(--s-6); }
.pad-y-8 { padding-block: var(--s-8); }

/* ---------------------------------------------------------------------------
   5. SECTION FRAME (editorial numbering rhythm)
   ------------------------------------------------------------------------ */

.band {
  padding-block: var(--s-16);
}

.band-tight {
  padding-block: var(--s-12);
}

.band-loose {
  padding-block: var(--s-24);
}

.band-paper {
  background: var(--paper-050);
  color: var(--ink-800);
}

.band-paper-raised {
  background: var(--paper-000);
  color: var(--ink-800);
}

.band-navy {
  background: var(--navy-900);
  color: var(--paper-050);
}

.band-navy .t-display-1,
.band-navy .t-display-2,
.band-navy .t-display-3,
.band-navy .t-title-1,
.band-navy .t-title-2,
.band-navy .t-title-3 {
  color: var(--paper-050);
}

.band-navy .t-body,
.band-navy .t-body-lg,
.band-navy .t-body-sm,
.band-navy .t-micro {
  color: rgba(251, 248, 242, 0.7);
}

.band-navy .rule,
.band-navy .rule-soft {
  border-color: var(--line-invert);
}

.band-paper-100 {
  background: var(--paper-100);
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
  margin-bottom: var(--s-10);
}

.section-head-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  gap: var(--s-10);
  align-items: end;
  margin-bottom: var(--s-10);
}

.section-index {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.section-index::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  transform: translateY(-3px);
}

.band-navy .section-index::after {
  background: var(--line-invert);
}

/* ---------------------------------------------------------------------------
   6. UTILITY
   ------------------------------------------------------------------------ */

.hide { display: none !important; }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }
.mt-8 { margin-top: var(--s-8); }
.mt-10 { margin-top: var(--s-10); }
.mt-12 { margin-top: var(--s-12); }
.mb-4 { margin-bottom: var(--s-4); }
.mb-6 { margin-bottom: var(--s-6); }
.mb-8 { margin-bottom: var(--s-8); }
.text-center { text-align: center; }
.align-start { align-items: start; }
.align-end { align-items: end; }
.full { width: 100%; }

/* ---------------------------------------------------------------------------
   7. MOTION
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: fadeIn var(--dur) var(--ease) both;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
