/* ────────────────────────────────────────────────────────────────────
 * AROOGA Design System — Typography
 *
 * Self-hosted variable fonts (Inter body · Inter Tight display).
 *
 * Font loading strategy:
 *   - Astro imports `@fontsource-variable/inter` and `@fontsource-variable/inter-tight`
 *     in the master layout (Phase 3). That publishes @font-face from the package's
 *     own CSS, pointing at WOFF2 files in node_modules/@fontsource-variable/*.
 *   - We DO NOT redeclare @font-face here; we rely on the package declaration.
 *     This prevents two conflicting sources of truth.
 *   - For static preview (preview.html, no build), uncomment the @font-face
 *     block below and drop WOFF2 files into ./fonts/.
 *
 * Font-display policy (revised per performance CoV):
 *   - BOTH fonts use `font-display: swap` — content readability + brand visibility.
 *   - Display font is `<link rel="preload">` from every landing's <head> so
 *     LCP hero renders with brand type, not system-ui fallback.
 *   - A metric-matched fallback @font-face (using size-adjust + ascent-override,
 *     generated via Capsize/Fontaine) is REQUIRED in Phase 3 to eliminate CLS
 *     during swap. Not part of Phase 1 — token layer only.
 *
 * NFR-04: ≤ 30KB gzip per axis (variable WOFF2 covers latin+latin-ext subsets ~25KB).
 * ──────────────────────────────────────────────────────────────────── */

/*
 * @font-face fallback declarations (uncomment for static preview only).
 * Production uses @fontsource-variable packages from Astro layout.
 *
 * @font-face {
 *   font-family: "Inter Variable";
 *   font-style: normal;
 *   font-weight: 100 900;
 *   font-display: swap;
 *   src: url("./fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
 * }
 * @font-face {
 *   font-family: "Inter Tight Variable";
 *   font-style: normal;
 *   font-weight: 100 900;
 *   font-display: swap;
 *   src: url("./fonts/inter-tight-latin-wght-normal.woff2") format("woff2-variations");
 * }
 */

/* ── BASE ──────────────────────────────────────────────────────────── */

html {
  /* Body text defaults — inherited everywhere unless overridden */
  font-family: var(--font-family-body);
  font-size: 100%; /* respect user zoom */
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11"; /* Inter stylistic alternates: rounder 'a', one-storey 'g' */
  font-variant-ligatures: common-ligatures contextual;
}

body {
  font-size: var(--text-base);
  font-weight: var(--font-weight-regular);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
}

/* ── HEADINGS ─────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6,
.t-display {
  font-family: var(--font-family-display);
  color: var(--color-text-primary);
  margin: 0;
  font-feature-settings: "ss01", "cv11", "cv02"; /* tighter display alternates */
}

/* Semantic headings — default sizes.
 * Use utility classes (.t-h1-hero etc) when you need a non-hierarchical size. */
h1, .t-h1 {
  font-size: clamp(var(--text-4xl), 5vw, var(--text-6xl));
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--font-weight-display);
}

h2, .t-h2 {
  font-size: clamp(var(--text-3xl), 3.5vw, var(--text-4xl));
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--font-weight-display);
}

h3, .t-h3 {
  font-size: var(--text-2xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
  font-weight: var(--font-weight-semibold);
}

h4, .t-h4 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  font-weight: var(--font-weight-semibold);
}

h5, .t-h5 {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  font-weight: var(--font-weight-semibold);
}

h6, .t-h6 {
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-secondary);
}

/* Hero-scale utility — for oversized marketing H1 only */
.t-h1-hero {
  font-family: var(--font-family-display);
  font-size: clamp(var(--text-5xl), 7vw, var(--text-7xl));
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: var(--font-weight-display);
}

/* AE skin — heavier display weight + tighter tracking on H1 for monumentality */
[data-market="ae"] .t-h1-hero,
[data-market="ae"] h1 {
  font-weight: 700;
  letter-spacing: -0.04em;
}

/* ── BODY UTILITIES ────────────────────────────────────────────────── */

p {
  margin: 0;
  line-height: var(--leading-relaxed);
  color: var(--color-text-primary);
}

.t-lead {
  font-size: var(--text-xl);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-regular);
}

.t-body       { font-size: var(--text-base); line-height: var(--leading-relaxed); }
.t-body-lg    { font-size: var(--text-lg);   line-height: var(--leading-relaxed); }
.t-body-sm    { font-size: var(--text-sm);   line-height: var(--leading-normal); }
.t-caption    { font-size: var(--text-xs);   line-height: var(--leading-normal); color: var(--color-text-secondary); }
.t-overline {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
}

.t-mono {
  font-family: var(--font-family-mono);
  font-size: 0.95em;
  font-feature-settings: "zero", "cv01";
}

/* Numeric emphasis — Metric component uses this */
.t-metric {
  font-family: var(--font-family-display);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum", "lnum", "ss01";
  font-weight: var(--font-weight-display);
  letter-spacing: -0.03em;
  line-height: 1;
}

.t-metric-xl {
  font-family: var(--font-family-display);
  font-variant-numeric: tabular-nums lining-nums;
  font-size: clamp(var(--text-5xl), 7vw, var(--text-7xl));
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

/* ── LINKS ─────────────────────────────────────────────────────────── */

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--duration-fast) var(--ease-soft);
}
a:hover { color: var(--color-primary-hover); }
a:focus-visible {
  /* Transparent outline first keeps focus visible in Windows High Contrast Mode. */
  outline: 2px solid transparent;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-xs);
}
@media (forced-colors: active) {
  a:focus-visible { outline: 2px solid Highlight; box-shadow: none; }
}

/* Utility: remove decoration for nav / CTA wrappers */
.t-link-plain,
.t-link-plain:hover { text-decoration: none; color: inherit; }

/* ── CODE + KBD ────────────────────────────────────────────────────── */

code, kbd, samp, pre {
  font-family: var(--font-family-mono);
  font-size: 0.92em;
}

code {
  padding: 0.1em 0.35em;
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

kbd {
  padding: 0.15em 0.4em;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  color: var(--color-text-secondary);
}

pre {
  padding: var(--space-4);
  background: var(--color-surface-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
pre code {
  padding: 0;
  background: transparent;
  border: 0;
}

/* ── LISTS ─────────────────────────────────────────────────────────── */

ul, ol {
  margin: 0;
  padding: 0 0 0 var(--space-6);
}
ul li, ol li { line-height: var(--leading-relaxed); }

/* Plain list utility */
.t-list-plain { padding: 0; list-style: none; }

/* ── RULES / DIVIDERS ──────────────────────────────────────────────── */

hr {
  border: 0;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-8) 0;
}

/* ── SELECTION ─────────────────────────────────────────────────────── */

::selection {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ── DARK-SECTION OVERRIDE ─────────────────────────────────────────── */

.surface-dark h1, .surface-dark h2, .surface-dark h3,
.surface-dark h4, .surface-dark h5,
.surface-dark p, .surface-dark li,
.surface-dark .t-h1-hero, .surface-dark .t-lead,
.surface-dark .t-body, .surface-dark .t-body-lg {
  color: var(--color-text-on-dark);
}
.surface-dark .t-body-sm,
.surface-dark .t-caption,
.surface-dark .t-overline,
.surface-dark h6 {
  color: var(--color-text-on-dark-2);
}
.surface-dark a {
  color: var(--color-primary-light);
  text-decoration-color: currentColor;
}
.surface-dark a:hover {
  color: var(--raw-periwinkle);
  filter: brightness(1.1);
  text-decoration-thickness: 2px;
}
.surface-dark code {
  background: rgba(245, 240, 232, 0.06);
  border-color: var(--color-border-on-dark);
  color: var(--color-text-on-dark);
}
