/* ════════════════════════════════════════════════════════════════
   First Nation Fidelity — base.css
   Typography, layout primitives, reset.
   Owns: html/body defaults, container, type classes, reveal motion.
   Does NOT own: section-specific styles (sections.css).
   ════════════════════════════════════════════════════════════════ */

/* ─── Modern reset ─── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html, body { height: 100%; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  line-height: var(--lh-relaxed);
  font-family: var(--body);
  font-size: var(--t-body);
  font-weight: 400;
  color: var(--on-paper);
  background: var(--paper);
  overflow-x: hidden;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* ─── Page-level surfaces ─── */
.page-ink   { background: var(--ink);    color: var(--on-ink); }
.page-paper { background: var(--paper);  color: var(--on-paper); }

/* ─── Container ─── */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container.is-wide  { max-width: var(--container-wide); }
.container.is-prose { max-width: var(--container-prose); }

/* ─── Section rhythm ─── */
section { position: relative; }
.section-pad       { padding-block: var(--sec-pad); }
.section-pad-tight { padding-block: var(--sec-pad-tight); }

/* ─── Hairline rule (the editorial separator) ─── */
.rule {
  border: 0;
  border-top: 1px solid var(--ink-line);
  width: 100%;
}
.rule.is-paper  { border-top-color: rgba(17, 25, 42, 0.14); }
.rule.is-short  { width: 56px; }
.rule.is-brass  { border-top-color: var(--brass-line); }

/* ════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ════════════════════════════════════════════════════════════════ */

/* Display serif headings — Instrument Serif at 300/400 only */
.display, .h1, .h2, .h3 {
  font-family: var(--display);
  font-weight: 400;
  line-height: var(--lh-display);
  letter-spacing: var(--tr-tight);
  color: inherit;
  text-wrap: balance;
}
.h1 { font-size: var(--t-h1); line-height: var(--lh-tight); }
.h2 { font-size: var(--t-h2); line-height: var(--lh-tight); letter-spacing: var(--tr-snug); }
.h3 { font-size: var(--t-h3); line-height: var(--lh-snug); letter-spacing: var(--tr-snug); }
.h4 { font-family: var(--body); font-weight: 500; font-size: var(--t-h4); line-height: var(--lh-snug); letter-spacing: var(--tr-snug); }
.h5 { font-family: var(--body); font-weight: 500; font-size: var(--t-h5); line-height: var(--lh-snug); }
.h6 { font-family: var(--body); font-weight: 500; font-size: var(--t-h6); line-height: var(--lh-snug); }

/* Italic display (use sparingly, 1-2 words per page) */
.display em, .h1 em, .h2 em, .h3 em {
  font-style: italic;
  color: var(--brass);
}
.page-paper .display em, .page-paper .h1 em, .page-paper .h2 em, .page-paper .h3 em {
  color: var(--brass-deep);
}

/* Eyebrow / kicker label (mono uppercase, signals a section is starting) */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--mono);
  font-size: var(--t-mono-xs);
  font-weight: 500;
  letter-spacing: var(--tr-wider);
  text-transform: uppercase;
  color: var(--brass);
}
.eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--brass);
  display: inline-block;
}
.page-paper .eyebrow { color: var(--brass-deep); }
.page-paper .eyebrow::before { background: var(--brass-deep); }

/* Body */
.lede {
  font-size: var(--t-body-xl);
  line-height: var(--lh-relaxed);
  color: var(--on-paper-dim);
  text-wrap: pretty;
  max-width: 56ch;
}
.page-ink .lede { color: var(--on-ink-dim); }
.body-lg { font-size: var(--t-body-lg); line-height: var(--lh-relaxed); }
.body-sm { font-size: var(--t-body-sm); line-height: var(--lh-relaxed); }

/* Mono numerics (stats, dollars, days) */
.num {
  font-family: var(--mono);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  font-variant-numeric: tabular-nums lining-nums;
}

/* Stat block — large serif numeral with hairline + uppercase label */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  align-items: flex-start;
}
.stat-num {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(48px, 6vw, 96px);
  line-height: 0.9;
  letter-spacing: var(--tr-tight);
  color: var(--brass);
}
.page-paper .stat-num { color: var(--brass-deep); }
.stat-num em {
  /* mono inline numerals inside serif stats — the 87% pattern */
  font-family: var(--mono);
  font-style: normal;
  font-weight: 500;
  font-size: 0.84em;
  letter-spacing: -0.01em;
}
.stat-label {
  font-family: var(--mono);
  font-size: var(--t-mono-xs);
  font-weight: 500;
  letter-spacing: var(--tr-wider);
  text-transform: uppercase;
  color: var(--on-ink-mute);
  padding-top: var(--s-3);
  border-top: 1px solid var(--ink-line);
  width: 100%;
  max-width: 220px;
}
.page-paper .stat-label {
  color: var(--on-paper-mute);
  border-top-color: rgba(17, 25, 42, 0.14);
}

/* ════════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: 18px 32px;
  font-family: var(--body);
  font-size: var(--t-body-sm);
  font-weight: 500;
  letter-spacing: var(--tr-wider);
  text-transform: uppercase;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition:
    background-color var(--d-fast) var(--ease-silk),
    color var(--d-fast) var(--ease-silk),
    border-color var(--d-fast) var(--ease-silk),
    transform var(--d-ui) var(--ease-silk);
  cursor: pointer;
  text-wrap: nowrap;
}
.btn:active { transform: scale(0.98); }

/* Primary — brass on ink, fills on hover */
.btn-primary {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass);
}
.btn-primary:hover {
  background: var(--brass-bright);
  border-color: var(--brass-bright);
}
.page-paper .btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.page-paper .btn-primary:hover {
  background: var(--ink-1);
  border-color: var(--ink-1);
}

/* Ghost — outlined, fills with current color on hover */
.btn-ghost {
  background: transparent;
  color: currentColor;
  border-color: currentColor;
}
.btn-ghost:hover {
  background: var(--on-ink);
  color: var(--ink);
}
.page-paper .btn-ghost:hover {
  background: var(--ink);
  color: var(--paper);
}

/* Link button — pure underline, low chrome */
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 0 6px 0;
  font-family: var(--body);
  font-size: var(--t-body-sm);
  font-weight: 500;
  color: inherit;
  border-bottom: 1px solid currentColor;
  transition: color var(--d-fast) var(--ease-silk),
              border-color var(--d-fast) var(--ease-silk),
              transform var(--d-fast) var(--ease-silk);
}
.btn-link:hover {
  color: var(--brass);
  border-color: var(--brass);
}
.page-paper .btn-link:hover {
  color: var(--brass-deep);
  border-color: var(--brass-deep);
}
.btn-link .btn-arrow {
  display: inline-block;
  transition: transform var(--d-fast) var(--ease-spring);
}
.btn-link:hover .btn-arrow {
  transform: translateX(4px);
}

/* ════════════════════════════════════════════════════════════════
   REVEAL — visible by default, plays a one-shot keyframe IF intersected.
   This pattern is critical for SEO + Playwright fullPage capture:
   the final state is the default, so anything that never intersects
   (because the page is captured without scroll, or JS is disabled)
   stays visible and styled correctly.
   ════════════════════════════════════════════════════════════════ */

[data-reveal] {
  opacity: 1;
  transform: translateY(0);
}
/* Only when both data-reveal AND is-visible (added by IO) does the
   keyframe play. Animation-fill-mode 'both' means the final state
   is preserved after the animation completes. */
[data-reveal].is-visible {
  animation: reveal-up var(--d-hero) var(--ease-drama) both;
}

@keyframes reveal-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger delays — applied via data-reveal-delay="N" */
[data-reveal-delay="1"].is-visible { animation-delay: calc(1 * var(--d-stagger)); }
[data-reveal-delay="2"].is-visible { animation-delay: calc(2 * var(--d-stagger)); }
[data-reveal-delay="3"].is-visible { animation-delay: calc(3 * var(--d-stagger)); }
[data-reveal-delay="4"].is-visible { animation-delay: calc(4 * var(--d-stagger)); }
[data-reveal-delay="5"].is-visible { animation-delay: calc(5 * var(--d-stagger)); }
[data-reveal-delay="6"].is-visible { animation-delay: calc(6 * var(--d-stagger)); }

@media (prefers-reduced-motion: reduce) {
  [data-reveal], [data-reveal].is-visible {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ─── Word reveal (hero headline) ─── */
/* Same principle: words are visible by default. IO adds .is-visible to
   the parent .word-reveal. Each .word plays the keyframe with a stagger
   driven by --i (the JS sets this index on each word). */
.word-reveal .word {
  display: inline-block;
  opacity: 1;
  transform: translateY(0);
}
.word-reveal.is-visible .word {
  animation: reveal-word 600ms var(--ease-editor) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes reveal-word {
  from { opacity: 0; transform: translateY(0.4em); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .word-reveal .word, .word-reveal.is-visible .word {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ─── Skip link ─── */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: var(--s-3) var(--s-5);
  background: var(--brass);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-body-sm);
  font-weight: 500;
  z-index: var(--z-toast);
  transform: translateY(-100%);
  transition: transform var(--d-fast) var(--ease-silk);
}
.skip-link:focus {
  transform: translateY(0);
}

/* Quick Quote nav link */
.nav-quick {
  font-family: var(--body);
  font-size: var(--t-body);
  color: var(--brass-deep);
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--brass);
  border-radius: 2px;
  letter-spacing: var(--tr-snug);
  margin-right: var(--s-3);
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-quick:hover {
  background: var(--brass);
  color: var(--on-paper);
}
@media (max-width: 900px) {
  .nav-quick { display: none; }
}

/* Hero secondary CTA (paired with btn-primary) */
.btn.btn-secondary {
  background: transparent;
  color: var(--on-paper);
  border: 1px solid var(--on-paper);
  padding: 14px 24px;
  text-decoration: none;
  font-family: var(--body);
  font-size: var(--t-body);
  letter-spacing: var(--tr-snug);
  border-radius: 2px;
  transition: background-color 150ms ease, color 150ms ease;
}
.btn.btn-secondary:hover { background: var(--on-paper); color: var(--paper); }
