/* ==========================================================================
   ACT for Trades — theme.css
   Design tokens, typography, base elements, and the Bootstrap bridge.
   Load order: bootstrap.min.css → theme.css → main.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts — self-hosted variable families.
   Archivo carries a width axis (62–125%), used for masthead compression.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/fraunces-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --------------------------------------------------------------------------
   2. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Colour — named for materials, not values.
     Contrast ratios verified to WCAG 2.2 AA; see docs spec §4. */
  --ink:          #0E0E10;   /* warm near-black */
  --ink-2:        #17171B;
  --ink-3:        #24242C;
  --ink-4:        #33333D;

  --paper:        #F6F3EC;   /* warm bone, uncoated stock */
  --paper-2:      #EDE8DD;
  --paper-3:      #DED7C8;

  --torch:        #E2542C;   /* signature. Heat, not hi-vis. */
  --torch-lit:    #FF6B3D;
  --torch-deep:   #B93A15;   /* AA-safe on paper at text sizes */
  /* Button and badge fills carrying white label text. --torch itself is only
     3.79:1 against white, which fails AA below 24px; this is 4.94:1. */
  --torch-fill:   #C7431C;

  --copper:       #B98240;
  --copper-lit:   #D8A063;

  --blueprint:    #12283F;
  --blueprint-2:  #1B3A59;

  --slate:        #5C5A54;   /* muted on paper — 6.2:1 */
  --concrete:     #8A8880;   /* muted on ink — 5.5:1 */

  /* Semantic surface roles. Sections flip these; components read them.
     This is what lets one card component sit on light or dark ground. */
  --surface:      var(--paper);
  --surface-2:    var(--paper-2);
  --on-surface:   var(--ink);
  --on-surface-muted: var(--slate);
  --rule:         rgba(14, 14, 16, 0.14);
  --rule-strong:  rgba(14, 14, 16, 0.30);
  --accent:       var(--torch-deep);
  --accent-vivid: var(--torch);

  /* Type */
  --font-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-body:    'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-edit:    'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono:    ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Menlo, monospace;

  /* Fluid scale. Min values hold at 360px, max at ~1600px. */
  --fs-xs:    0.75rem;
  --fs-sm:    0.8125rem;
  --fs-base:  1.0625rem;
  --fs-md:    clamp(1.0625rem, 1.02rem + 0.20vw, 1.1875rem);
  --fs-lg:    clamp(1.1875rem, 1.10rem + 0.40vw, 1.4375rem);
  --fs-xl:    clamp(1.4375rem, 1.26rem + 0.80vw, 2rem);
  --fs-2xl:   clamp(1.875rem, 1.53rem + 1.55vw, 3rem);
  --fs-3xl:   clamp(2.375rem, 1.72rem + 2.90vw, 4.5rem);
  --fs-4xl:   clamp(2.875rem, 1.55rem + 5.90vw, 7rem);
  --fs-mast:  clamp(3.25rem, 0.40rem + 12.7vw, 12rem);

  --lh-tight:  0.94;
  --lh-snug:   1.08;
  --lh-normal: 1.35;
  --lh-prose:  1.62;

  /* Tracking. Display type is still set tight — large sizes need negative
     tracking to avoid looking gappy — but only about half as tight as
     before, because Archivo is also compressed on the width axis and the two
     compound into something too dense to read comfortably. */
  --tr-mast:  0.004em;
  --tr-tight: 0.004em;
  --tr-normal: -0.004em;
  --tr-caps:   0.16em;

  /* Space — 8px base, modular ramp */
  --s-1:  0.25rem;
  --s-2:  0.5rem;
  --s-3:  0.75rem;
  --s-4:  1rem;
  --s-5:  1.5rem;
  --s-6:  2rem;
  --s-7:  3rem;
  --s-8:  4rem;
  --s-9:  6rem;
  --s-10: 8rem;
  --section-y: clamp(4.5rem, 3rem + 7vw, 9.5rem);

  /* Layout */
  --shell:      1360px;
  --shell-pad:  clamp(1.25rem, 0.6rem + 2.8vw, 4rem);
  --measure:    64ch;
  --measure-sm: 46ch;

  /* Form */
  --radius-0: 0;
  --radius-1: 2px;
  --radius-2: 4px;
  --radius-pill: 999px;

  /* Elevation — warm-tinted, never neutral grey */
  --shadow-1: 0 1px 2px rgba(14,14,16,.06), 0 2px 6px rgba(14,14,16,.05);
  --shadow-2: 0 2px 6px rgba(14,14,16,.07), 0 10px 26px rgba(14,14,16,.08);
  --shadow-3: 0 4px 12px rgba(14,14,16,.09), 0 24px 60px rgba(14,14,16,.14);
  --shadow-lift: 0 8px 20px rgba(14,14,16,.10), 0 40px 90px rgba(14,14,16,.18);

  /* Motion. --dur-* collapse to 1ms under reduced motion (see §7). */
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --dur-1: 140ms;
  --dur-2: 260ms;
  --dur-3: 460ms;
  --dur-4: 800ms;

  /* Grain overlay — feTurbulence, inlined so it costs no request */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
}

/* Dark ground. Applied to a section, it re-points every semantic role, so
   components nested inside adapt without needing dark-specific rules. */
.on-ink {
  --surface:      var(--ink);
  --surface-2:    var(--ink-2);
  --on-surface:   var(--paper);
  --on-surface-muted: var(--concrete);
  --rule:         rgba(246, 243, 236, 0.16);
  --rule-strong:  rgba(246, 243, 236, 0.34);
  --accent:       var(--torch);
  --accent-vivid: var(--torch-lit);
  background-color: var(--surface);
  color: var(--on-surface);
}

.on-blueprint {
  --surface:      var(--blueprint);
  --surface-2:    var(--blueprint-2);
  --on-surface:   #E8EEF5;
  --on-surface-muted: #94A9BE;
  --rule:         rgba(232, 238, 245, 0.16);
  --rule-strong:  rgba(232, 238, 245, 0.32);
  --accent:       var(--copper-lit);
  --accent-vivid: var(--torch-lit);
  background-color: var(--surface);
  color: var(--on-surface);
}

/* --------------------------------------------------------------------------
   3. Bootstrap bridge — repoint Bootstrap's own variables at our tokens
   so its components inherit the identity instead of fighting it.
   -------------------------------------------------------------------------- */

:root {
  --bs-body-font-family: var(--font-body);
  --bs-body-font-size: var(--fs-base);
  --bs-body-line-height: var(--lh-prose);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--paper);
  --bs-emphasis-color: var(--ink);
  --bs-secondary-color: var(--slate);

  --bs-primary: #E2542C;
  --bs-primary-rgb: 226, 84, 44;
  --bs-dark: #0E0E10;
  --bs-dark-rgb: 14, 14, 16;

  --bs-link-color: var(--torch-deep);
  --bs-link-color-rgb: 185, 58, 21;
  --bs-link-hover-color: var(--ink);
  --bs-link-decoration: none;

  --bs-border-color: rgba(14, 14, 16, 0.14);
  --bs-border-radius: var(--radius-2);
  --bs-border-radius-sm: var(--radius-1);
  --bs-border-radius-lg: var(--radius-2);

  --bs-heading-color: inherit;
  --bs-focus-ring-color: rgba(226, 84, 44, 0.45);
  --bs-focus-ring-width: 3px;
}

/* Bootstrap's container is replaced by our editorial shell (main.css .shell),
   but keep the fluid container honest where it is used. */
.container, .container-fluid,
.container-sm, .container-md, .container-lg, .container-xl, .container-xxl {
  padding-inline: var(--shell-pad);
}

/* --------------------------------------------------------------------------
   4. Base
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Header is fixed; anchor targets must clear it. */
  scroll-padding-top: 6.5rem;
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 420;
  line-height: var(--lh-prose);
  letter-spacing: var(--tr-normal);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

/* Page-wide grain. Pointer-events off so it never intercepts a click. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  background-image: var(--grain);
  opacity: 0.30;
  mix-blend-mode: multiply;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 760;
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-tight);
  margin: 0 0 var(--s-4);
  text-wrap: balance;
  color: inherit;
}

h1 { font-size: var(--fs-3xl); line-height: var(--lh-tight); letter-spacing: var(--tr-mast); }
h2 { font-size: var(--fs-2xl); line-height: var(--lh-snug); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5, h6 { font-size: var(--fs-md); }

p { margin: 0 0 var(--s-5); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

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

strong, b { font-weight: 700; }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  opacity: 1;
  margin: var(--s-7) 0;
}

::selection { background: var(--torch-fill); color: #fff; }

/* --------------------------------------------------------------------------
   5. Typographic roles
   -------------------------------------------------------------------------- */

/* Masthead — Archivo compressed hard. The site's loudest voice. */
.t-mast {
  font-family: var(--font-display);
  font-size: var(--fs-mast);
  font-weight: 860;
  font-stretch: 92%;
  line-height: 0.88;
  letter-spacing: var(--tr-mast);
  text-transform: uppercase;
  margin: 0;
}

.t-display {
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  font-weight: 800;
  font-stretch: 96%;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-mast);
  margin: 0;
}

/* Eyebrow — small caps with a copper rule. The magazine "kicker". */
.t-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 640;
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--s-5);
  line-height: 1;
}
.t-eyebrow::before {
  content: '';
  width: 2rem;
  height: 1px;
  background: currentColor;
  flex: none;
}
.t-eyebrow--plain::before { display: none; }

/* Editorial serif voice */
.t-edit {
  font-family: var(--font-edit);
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 22, 'WONK' 1;
  font-weight: 500;
  letter-spacing: -0.008em;
}

.t-lead {
  font-size: var(--fs-lg);
  line-height: 1.5;
  color: var(--on-surface-muted);
  max-width: var(--measure);
  font-weight: 420;
}

.t-quote {
  font-family: var(--font-edit);
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 30, 'WONK' 1;
  font-size: var(--fs-2xl);
  font-weight: 460;
  line-height: 1.22;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* Plate numbers, folios, captions — the print furniture. */
.t-folio {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--on-surface-muted);
  font-variant-numeric: tabular-nums;
}

.t-caption {
  font-family: var(--font-edit);
  font-optical-sizing: auto;
  font-size: var(--fs-sm);
  font-style: italic;
  line-height: 1.45;
  color: var(--on-surface-muted);
}

.t-muted { color: var(--on-surface-muted); }
.t-measure { max-width: var(--measure); }
.t-measure-sm { max-width: var(--measure-sm); }

/* Drop cap — first letter of a lead paragraph, set in Fraunces. */
.t-dropcap::first-letter {
  font-family: var(--font-edit);
  font-variation-settings: 'SOFT' 0, 'WONK' 0;
  font-weight: 700;
  font-size: 3.6em;
  line-height: 0.78;
  float: left;
  padding: 0.08em 0.10em 0 0;
  color: var(--accent);
}

/* Accent word inside a heading */
.t-hl { color: var(--accent-vivid); }

/* Underline that draws on hover — used on inline editorial links. */
.t-link {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size var(--dur-2) var(--ease-out);
  padding-bottom: 1px;
}
.t-link:hover { background-size: 0% 1px; background-position: 100% 100%; }

/* --------------------------------------------------------------------------
   6. Accessibility primitives
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: var(--s-4);
  z-index: 10000;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--paper);
  padding: var(--s-3) var(--s-5);
  font-weight: 640;
  font-size: var(--fs-sm);
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  border-radius: var(--radius-1);
  transition: transform var(--dur-2) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* One focus treatment, everywhere. Never removed, only styled. */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--torch);
  outline-offset: 3px;
  border-radius: var(--radius-1);
}
.on-ink :focus-visible,
.on-blueprint :focus-visible {
  outline-color: var(--torch-lit);
}

.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* Windows High Contrast / forced colours — restore system semantics. */
@media (forced-colors: active) {
  body::after { display: none; }
  .btn, .card-edit, .pillar { border: 1px solid CanvasText; }
  :focus-visible { outline: 3px solid Highlight; }
}

/* --------------------------------------------------------------------------
   7. Reduced motion — collapse durations at the token level so every
   component inherits the preference without individual overrides.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 1ms;
    --dur-2: 1ms;
    --dur-3: 1ms;
    --dur-4: 1ms;
  }
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  /* Reveal elements start in their final state rather than animating in. */
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}
