/* =============================================================
   Commons World — base.css
   Modern reset · design tokens (BUILD-CONTRACT §2) ·
   element + typography · utilities · accessibility · motion.
   Source Serif 4 + Source Sans 3 variable fonts (OFL) + system fallbacks.
   Hand-written, no framework, no build step.
   ============================================================= */

/* -------------------------------------------------------------
   TYPEFACES — Source Serif 4 (headings/serif) + Source Sans 3
   (body/UI), self-hosted variable woff2 (OFL, latin subset).
   F1 (Phase 4, REBRIEF-MASTER-PLAN §7 / docs/plan/system-A §1).
   Replaces Fraunces site-wide.
------------------------------------------------------------- */
@font-face {
  font-family: "Source Serif 4 var";
  src: url("../fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900; /* wght axis */
  font-stretch: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4 var";
  src: url("../fonts/source-serif-4-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3 var";
  src: url("../fonts/source-sans-3.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3 var";
  src: url("../fonts/source-sans-3-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

/* -------------------------------------------------------------
   DESIGN TOKENS — every custom property from contract §2.
   Mirrored into theme.json by the theme team.
------------------------------------------------------------- */
:root {
  /* Brand colour (brief §4.2 · design-rescue-v3 palette) */
  --cw-navy: #142844;
  --cw-navy-deep: #0b1d33;
  --cw-navy-soft: #1b3456;
  --cw-navy-ink: #0b1c33;
  --cw-sage: #4f7163;
  --cw-sage-muted: #6f877a;
  --cw-gold: #c8a24a;
  --cw-gold-soft: #d8b85f;
  --cw-gold-light: #ead391;
  --cw-gold-deep: #9f7b2b;
  --cw-gold-ink: #3a2912; /* warm espresso text for ON-gold surfaces (CTAs, badges) — ~5.8:1 on gold, warmer than cold navy */
  --cw-cream: #f7f1e7;
  --cw-cream-light: #fffaf1;
  --cw-cream-dark: #e8dcc9;
  --cw-paper: #fbf6ec;
  --cw-sand: #e8dcc7;
  --cw-sand-soft: #efe5d3;
  --cw-ink: #10213a;
  --cw-ink-soft: #46566e; /* refined slate-navy: quiet body/caption ink that holds AA on the cream-dark zone surface (5.5:1) where --cw-muted (3.9:1) fails */
  --cw-muted: #5f6d7a;
  --cw-muted-blue: #607184;
  --cw-muted-cream: rgba(255, 250, 241, 0.76);
  --cw-border: rgba(16, 33, 58, 0.16);
  --cw-border-soft: rgba(16, 33, 58, 0.09);
  --cw-gold-border: rgba(191, 148, 56, 0.34);
  --cw-border-dark: rgba(245, 240, 232, 0.16);
  --cw-white: #ffffff;
  --cw-error: #9b2c2c;
  --cw-success: #2f6f4e;

  /* GAR bars — logo lockup ONLY (seven Global Accountability Ratings colours) */
  --cw-gar-1: #c42e2a;
  --cw-gar-2: #e2762b;
  --cw-gar-3: #f2c20d;
  --cw-gar-4: #1fa13c;
  --cw-gar-5: #1e73c8;
  --cw-gar-6: #7a3dae;
  --cw-gar-7: #ffffff;

  /* Semantic */
  --cw-bg: var(--cw-cream);
  --cw-surface: var(--cw-cream-light);
  --cw-surface-zone: var(--cw-cream-dark);
  --cw-surface-dark: var(--cw-navy);
  --cw-surface-darker: var(--cw-navy-deep);
  --cw-text: var(--cw-ink);
  --cw-text-muted: var(--cw-muted-blue);
  --cw-heading: var(--cw-ink);
  --cw-on-dark: var(--cw-cream);
  --cw-on-dark-muted: rgba(245, 240, 232, 0.74);
  --cw-cta: var(--cw-gold);
  --cw-cta-hover: var(--cw-gold-deep);
  --cw-cta-text: var(--cw-gold-ink);
  --cw-link: var(--cw-navy);
  --cw-link-underline: var(--cw-gold);
  --cw-focus: var(--cw-gold-deep);

  /* Type — F1: Source Serif 4 (headings/serif) + Source Sans 3 (body/UI).
     Fallbacks are serif↔serif / sans↔sans so a swap never reflows letterform kind. */
  --cw-font-sans: "Source Sans 3 var", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
  --cw-font-serif: "Source Serif 4 var", Georgia, "Times New Roman", Times, serif;
  --cw-font-heading: var(--cw-font-serif); /* all headings = Source Serif 4 */
  --cw-font-body: var(--cw-font-sans); /* body/UI = Source Sans 3 */

  /* Type scale — tuned for Source Serif 4 (reads larger than Fraunces). */
  --cw-fs-hero: clamp(3rem, 7vw, 6rem); /* home H1 */
  --cw-fs-h1: clamp(2.6rem, 6vw, 5rem); /* page H1 */
  --cw-fs-h2: clamp(2rem, 4vw, 3.4rem);
  --cw-fs-h3: clamp(1.3rem, 2.2vw, 1.9rem);
  --cw-fs-h4: 1.2rem;
  --cw-fs-quote: clamp(1.5rem, 3vw, 2.4rem); /* pull-quote bands */
  --cw-fs-stat: clamp(2.6rem, 5vw, 4rem); /* big serif numerals */
  --cw-fs-body-lg: 1.18rem;
  --cw-fs-body: 1.0625rem; /* 17px luminous body */
  --cw-fs-small: 0.875rem;
  --cw-fs-micro: 0.78rem;
  --cw-fs-nav: 0.78rem;
  --cw-lh-tight: 1.06;
  --cw-lh-heading: 1.16;
  --cw-lh-quote: 1.4;
  --cw-lh-body: 1.7;
  --cw-lh-reading: 1.75;
  /* Heading weights (named — F1 headings are 600, not 400). */
  --cw-wt-heading: 600;
  --cw-wt-quote: 500;
  --cw-track-eyebrow: 0.14em;

  /* Layout (brief §4.4 · design-rescue-v3) */
  --cw-container: 1320px;
  --cw-container-mid: 1180px;
  --cw-container-narrow: 760px;
  --cw-reading-width: 720px;
  --cw-gutter: clamp(1.25rem, 4vw, 2.5rem);
  --cw-section-y-lg: clamp(72px, 9vw, 132px);
  --cw-section-y-md: clamp(48px, 7vw, 96px);
  --cw-section-y-sm: clamp(32px, 5vw, 56px);
  --cw-radius-sm: 10px;
  --cw-radius-md: 16px;
  --cw-radius-lg: 26px;
  --cw-radius-pill: 9999px;
  --cw-header-height: 82px;
  --cw-shadow-soft: 0 24px 80px rgba(11, 29, 51, 0.12);
  --cw-shadow-card: 0 18px 50px rgba(11, 29, 51, 0.1);
  --cw-shadow-gold: 0 18px 42px rgba(191, 148, 56, 0.18);

  /* Motion / z */
  --cw-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --cw-dur: 240ms;
  --cw-dur-fast: 160ms;
  --cw-z-header: 200;
  --cw-z-overlay: 900;
  --cw-z-modal: 1000;
}

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

* {
  margin: 0;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
  -moz-tab-size: 4;
  tab-size: 4;
  font-optical-sizing: auto; /* lets Source Serif 4's opsz axis track size */
}

body {
  min-height: 100vh;
  font-family: var(--cw-font-body);
  font-size: var(--cw-fs-body);
  line-height: 1.65;
  font-weight: 400;
  color: var(--cw-text);
  background-color: var(--cw-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

img,
picture {
  font-style: italic; /* alt-text styling if image fails */
}

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

button {
  background: none;
  border: 0;
  cursor: pointer;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

/* -------------------------------------------------------------
   TYPOGRAPHY — Georgia headings w/ clamps, Arial body 1rem/1.7
------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6,
.serif {
  font-family: var(--cw-font-heading);
  color: var(--cw-heading);
  line-height: var(--cw-lh-heading);
  font-weight: var(--cw-wt-heading);
  letter-spacing: -0.012em; /* F1 retune off Fraunces's -0.04em (per-element below) */
  text-wrap: balance;
}

h1 {
  font-size: var(--cw-fs-h1);
  line-height: var(--cw-lh-tight);
  letter-spacing: -0.018em;
}
h2 {
  font-size: var(--cw-fs-h2);
}
h3 {
  font-size: var(--cw-fs-h3);
  letter-spacing: -0.004em; /* ~0 at h3 (F1) */
}
h4 {
  font-size: 1.25rem;
}
h5 {
  font-size: 1.0625rem;
}
h6 {
  font-size: var(--cw-fs-small);
  letter-spacing: var(--cw-track-eyebrow);
  text-transform: uppercase;
}

p {
  text-wrap: pretty;
}

/* Reading rhythm — flow spacing between consecutive blocks */
p + p,
p + ul,
p + ol,
ul + p,
ol + p {
  margin-top: 1.25em;
}

a {
  color: var(--cw-link);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--cw-dur-fast) var(--cw-ease),
    text-decoration-color var(--cw-dur-fast) var(--cw-ease);
}

/* Links underline gold on hover */
a:hover {
  text-decoration: underline;
  text-decoration-color: var(--cw-link-underline);
  text-decoration-thickness: 2px;
}

strong,
b {
  font-weight: 700;
  color: var(--cw-ink);
}

em,
i {
  font-style: italic;
}

small {
  font-size: var(--cw-fs-small);
}

blockquote {
  font-family: var(--cw-font-heading);
  font-style: italic;
}

code,
kbd,
samp,
pre {
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.92em;
}

ul,
ol {
  padding-left: 1.4em;
}

li + li {
  margin-top: 0.4em;
}

li::marker {
  color: var(--cw-gold-deep);
}

hr {
  border: 0;
  height: 1px;
  background: var(--cw-border);
}

::selection {
  background: rgba(191, 148, 56, 0.28);
  color: var(--cw-ink);
}

/* -------------------------------------------------------------
   ACCESSIBILITY PRIMITIVES
------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--cw-focus);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Don't show the focus ring for mouse users who haven't tabbed */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link — offscreen, visible on focus */
.cw-skip-link {
  position: absolute;
  left: 1rem;
  top: -120px;
  z-index: var(--cw-z-modal);
  display: inline-block;
  padding: 0.75rem 1.25rem;
  background: var(--cw-navy);
  color: var(--cw-cream);
  font-size: var(--cw-fs-small);
  font-weight: 700;
  letter-spacing: var(--cw-track-eyebrow);
  text-transform: uppercase;
  text-decoration: none;
  border-radius: var(--cw-radius-sm);
  transition: top var(--cw-dur) var(--cw-ease);
}
.cw-skip-link:focus {
  top: 1rem;
}
.cw-skip-link:hover {
  text-decoration: none;
}

/* Visually-hidden but available to assistive tech */
.cw-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;
}

/* -------------------------------------------------------------
   UTILITY: EYEBROW — uppercase, gold, letter-spaced, gold dash
------------------------------------------------------------- */
.cw-eyebrow {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 22px;
  font-family: var(--cw-font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cw-gold-deep);
}
.cw-eyebrow::before {
  content: "";
  width: 44px;
  height: 1px;
  flex: 0 0 44px;
  background: currentColor;
}

/* On dark surfaces the eyebrow lifts to the lighter gold */
.cw-section--dark .cw-eyebrow,
.cw-support .cw-eyebrow,
.cw-capture .cw-eyebrow {
  color: var(--cw-gold-light);
}

/* -------------------------------------------------------------
   UTILITY: DIVIDER — thin gold rule
------------------------------------------------------------- */
.cw-divider {
  border: 0;
  height: 1px;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    var(--cw-gold) 18%,
    var(--cw-gold) 82%,
    transparent
  );
  margin-block: clamp(2rem, 5vw, 4rem);
}
.cw-divider--short {
  width: 3.5rem;
  background: var(--cw-gold);
  margin-inline: 0;
}

/* -------------------------------------------------------------
   UTILITY: ICON — inline SVG wrapper using currentColor
------------------------------------------------------------- */
.cw-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5em;
  height: 1.5em;
  color: currentColor;
  vertical-align: middle;
}
.cw-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
}

/* -------------------------------------------------------------
   UTILITY: LINK ARROW — quiet, uppercase forward link
------------------------------------------------------------- */
.cw-link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--cw-font-sans);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cw-ink);
  text-decoration: none;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cw-gold);
}
.cw-link-arrow:hover {
  text-decoration: none;
  color: var(--cw-navy-deep);
}
.cw-link-arrow .cw-icon {
  width: 1em;
  height: 1em;
  transition: transform var(--cw-dur) var(--cw-ease);
}
.cw-link-arrow:hover .cw-icon {
  transform: translateX(4px);
}

/* -------------------------------------------------------------
   UTILITY: INLINE LINK — for prose / running text
------------------------------------------------------------- */
.cw-inline-link {
  color: var(--cw-link);
  text-decoration: underline;
  text-decoration-color: var(--cw-link-underline);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}
.cw-inline-link:hover {
  text-decoration-thickness: 2px;
}

/* Prose links default to inline-link treatment */
.cw-prose a:not(.cw-btn):not(.cw-link-arrow) {
  color: var(--cw-link);
  text-decoration: underline;
  text-decoration-color: var(--cw-link-underline);
  text-decoration-thickness: 1.5px;
}
.cw-prose a:not(.cw-btn):not(.cw-link-arrow):hover {
  text-decoration-thickness: 2px;
}

/* -------------------------------------------------------------
   SCROLL ANCHORS — keep targets clear of the sticky header
------------------------------------------------------------- */
#download-book,
.cw-pillars,
.cw-support {
  scroll-margin-top: calc(var(--cw-header-height) + 24px);
}
@media (max-width: 1023px) {
  #download-book,
  .cw-pillars,
  .cw-support {
    scroll-margin-top: 126px;
  }
}

/* -------------------------------------------------------------
   REDUCED MOTION — zero out animation/transition/scroll (brief §16)
------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
