/* ============================================================================
   Solutions Factory — Visual Token System
   Canonical design language, shared 1:1 with the dashboard substrate (brief §7).
   See ADR 0002. The only hex values in the entire stack are the four below;
   every other shade is an rgba of charcoal or gold.

   ACCESSIBILITY NOTE (load-bearing): burnished gold #B89968 on ivory is ~2.46:1,
   which fails WCAG AA for text and the 3:1 non-text threshold. Gold is therefore
   used ONLY where it passes: as a fill behind charcoal text, as borders /
   underlines / decorative marks, and as text on the DARK code surface (gold on
   charcoal = ~6.5:1). Text on ivory is always charcoal or charcoal-muted.
   ============================================================================ */

:root {
  /* — Palette: the only hex values in the system (ADR 0002) — */
  --bg-ivory: #F8F4ED;
  --text-charcoal: #1A1816;
  --accent-gold: #B89968;
  --accent-gold-soft: #D5B788;

  /* — Charcoal-derived (rgba; no new hex). Alphas chosen for AA on ivory. — */
  --text-muted: rgba(26, 24, 22, 0.66);    /* ~5.5:1 on ivory — body-safe */
  --text-faint: rgba(26, 24, 22, 0.48);    /* ~3.1:1 — large/decorative only */
  --hairline: rgba(26, 24, 22, 0.15);
  --hairline-strong: rgba(26, 24, 22, 0.30);

  /* — Gold-derived tints (rgba; no new hex) — */
  --gold-tint-soft: rgba(184, 153, 104, 0.06);
  --gold-tint: rgba(184, 153, 104, 0.10);
  --gold-tint-strong: rgba(184, 153, 104, 0.16);

  /* — Surfaces — */
  --surface-card: #F8F4ED;                 /* ivory; differentiated by hairline */
  --surface-dark: #1A1816;                 /* code / terminal — canonical charcoal */
  --on-gold: #1A1816;                      /* text on gold fill — 6.5:1 */
  --on-dark: #F8F4ED;                      /* text on charcoal — canonical ivory */
  --on-dark-muted: rgba(248, 244, 237, 0.62);
  --on-dark-hairline: rgba(248, 244, 237, 0.14);

  /* — Typography (brief §7.2). Open + system fallbacks; no web-font CDN. — */
  --font-serif: 'Tiempos Headline', 'Crimson Pro', 'GT Sectra', 'Sentinel', Georgia, serif;
  --font-sans: 'Söhne', 'IBM Plex Sans', 'Untitled Sans', 'Aktiv Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Type scale (rem; 1rem = 16px) */
  --fs-eyebrow: 0.6875rem;   /* 11px */
  --fs-small: 0.8125rem;     /* 13px */
  --fs-body: 1rem;           /* 16px */
  --fs-lead: 1.1875rem;      /* 19px */
  --fs-h4: 1.125rem;         /* 18px */
  --fs-h3: 1.375rem;         /* 22px */
  --fs-h2: 2rem;             /* 32px */
  --fs-h1: 3rem;             /* 48px */
  --fs-display: 3.5rem;      /* 56px hero */
  --lh-tight: 1.14;
  --lh-snug: 1.3;
  --lh-body: 1.65;

  /* — Spacing (brief §7.4) — */
  --sp-section: 64px;
  --sp-gutter: 48px;
  --sp-card: 32px;
  --sp-card-tight: 24px;
  --sp-3: 16px;
  --sp-2: 12px;
  --sp-1: 8px;

  /* — Radius (never larger than 6px) — */
  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;

  /* — Shadow: the hairline-overlap shadow is the ONLY shadow (brief §7.4) — */
  --shadow-hairline: 0 1px 2px rgba(26,24,22,0.04), 0 0 0 1px rgba(26,24,22,0.06);

  /* — Motion (brief §7.3) — */
  --motion-fade: 400ms;
  --motion-stagger: 100ms;
  --motion-hover: 200ms;
  --motion-drawer-in: 350ms;
  --motion-drawer-out: 250ms;
  --motion-modal: 400ms;
  --ease-canonical: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: ease-out;
  --ease-drawer-out: cubic-bezier(0.4, 0, 1, 1);

  /* — Layout — */
  --measure: 68ch;
  --container: 1120px;
  --container-narrow: 760px;
  --nav-h: 64px;
}

/* ---------------------------------------------------------------- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-ivory);
  color: var(--text-charcoal);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
svg { fill: currentColor; }

/* ----------------------------------------------------------- Elements --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: var(--lh-snug);
  color: var(--text-charcoal);
  margin: 0 0 var(--sp-3);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); letter-spacing: -0.022em; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
p { margin: 0 0 var(--sp-3); max-width: var(--measure); }
.lead { font-size: var(--fs-lead); color: var(--text-muted); line-height: 1.55; }

/* Links default to charcoal text + gold underline — AA-safe everywhere.
   Nav, footer, and buttons opt out and set their own treatment. */
a {
  color: var(--text-charcoal);
  text-decoration: underline;
  text-decoration-color: var(--accent-gold);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: text-decoration-thickness var(--motion-hover) var(--ease-out);
}
a:hover { text-decoration-thickness: 2.5px; }

strong, b { font-weight: 600; }
small { font-size: var(--fs-small); }
ul, ol { margin: 0 0 var(--sp-3); padding-left: 24px; max-width: var(--measure); }
li { margin-bottom: var(--sp-1); }
hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--sp-section) 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--gold-tint);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}
pre { font-family: var(--font-mono); margin: 0; }
pre code { background: transparent; padding: 0; font-size: inherit; }

/* ------------------------------------------------------------- Focus --- */
/* Charcoal outline guarantees SC 1.4.11 (>=3:1); gold halo adds brand warmth.
   Gold alone on ivory is 2.46:1 and would fail, so it is not used as the ring. */
:focus-visible {
  outline: 2px solid var(--text-charcoal);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ------------------------------------------------------ Utility classes --- */
/* Named exactly per directive 2.1. */
.font-serif-heading { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.015em; }
.font-sans-body { font-family: var(--font-sans); }
.font-numeric-tabular { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* Eyebrow — charcoal-muted text (AA) with a decorative gold leading bar. */
.eyebrow, .text-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 var(--sp-2);
  font-family: var(--font-sans);
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.eyebrow::before, .text-eyebrow::before {
  content: "";
  width: 24px;
  height: 2px;
  background: var(--accent-gold);
  flex: none;
}
.eyebrow--bare::before, .text-eyebrow--bare::before { display: none; }

/* Canonical fade-in. Default (no JS) = visible. The <html class="js"> hook
   (set by an inline one-liner in <head>) enables the hidden-then-reveal state,
   so there is no flash of unstyled content and no-JS users see everything. */
.fade-in-canonical { opacity: 1; transform: none; }
.js .fade-in-canonical {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--motion-fade) var(--ease-canonical),
              transform var(--motion-fade) var(--ease-canonical);
  will-change: opacity, transform;
}
.js .fade-in-canonical.is-visible { opacity: 1; transform: none; }

.stagger-1 { transition-delay: calc(var(--motion-stagger) * 1); }
.stagger-2 { transition-delay: calc(var(--motion-stagger) * 2); }
.stagger-3 { transition-delay: calc(var(--motion-stagger) * 3); }
.stagger-4 { transition-delay: calc(var(--motion-stagger) * 4); }
.stagger-5 { transition-delay: calc(var(--motion-stagger) * 5); }
.stagger-6 { transition-delay: calc(var(--motion-stagger) * 6); }

/* Button press feedback. */
.btn-press-canonical {
  transition: transform var(--motion-hover) var(--ease-out),
              background-color var(--motion-hover) var(--ease-out),
              border-color var(--motion-hover) var(--ease-out),
              color var(--motion-hover) var(--ease-out);
}
.btn-press-canonical:active { transform: translateY(1px); }

/* Visually-hidden, still in the a11y tree. */
.visually-hidden {
  position: absolute !important;
  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;
}

/* ---------------------------------------------------- Reduced motion --- */
/* Clamp every motion token to 0.01ms AND hard-stop all animation/transition. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fade: 0.01ms;
    --motion-stagger: 0.01ms;
    --motion-hover: 0.01ms;
    --motion-drawer-in: 0.01ms;
    --motion-drawer-out: 0.01ms;
    --motion-modal: 0.01ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  .js .fade-in-canonical { opacity: 1 !important; transform: none !important; }
}
