/* ==========================================================================
   R2G — design tokens + typographic base
   Spec: research/DESIGN-SYSTEM.md
   Component styles live elsewhere; this file is tokens + resets only.

   Fonts are preloaded/enqueued in PHP. Equivalent @import for reference:
   @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Montserrat:wght@400;500;600&display=swap');
   ========================================================================== */

:root {
  /* ---- Brand colour ---------------------------------------------------- */
  --navy-50:  #EEF3F5;
  --navy-100: #D6E2E7;
  --navy-300: #4A7A8C;
  --navy-400: #2F6A80;   /* link hover on light, 6.01:1 on white */
  --navy-500: #225264;   /* brand primary, 8.54:1 on white */
  --navy-600: #1C4553;   /* navy button hover */
  --navy-700: #183B48;   /* hero / footer / dark sections */
  --navy-900: #0F2A36;   /* darkest text, text on lime */

  --lime-100: #F4F7D6;   /* supporting tint */
  --lime-500: #CBDB2A;   /* accent / CTA fill — NEVER as text on white (1.53:1) */
  --lime-600: #B5C41F;   /* lime button hover */
  --lime-700: #6B7510;   /* only lime allowed as text on white (5.03:1) */

  /* ---- Neutrals (cool, navy-biased) ------------------------------------ */
  --grey-50:  #F5F8F9;
  --grey-100: #E9EEF0;
  --grey-200: #D5DEE2;
  --grey-300: #B9C6CB;
  --grey-400: #9AABB2;
  --grey-500: #7B8A90;   /* 3.57:1 — large/decorative text only */
  --grey-600: #5B6B72;   /* secondary text, 5.54:1 */
  --grey-700: #3C4A50;   /* body text, 9.18:1 */
  --grey-800: #263238;
  --grey-900: #1A2327;
  --white:    #FFFFFF;

  /* ---- Semantic --------------------------------------------------------- */
  --success:      #0E7A5B;
  --success-bg:   #E3F3EC;
  --warning-text: #8A5A00;
  --warning-bg:   #FFF4D6;
  --error:        #B42318;
  --error-bg:     #FCE9E7;
  --info:         var(--navy-400);
  --info-bg:      var(--navy-50);

  /* ---- EPC rating bands (brand motif) ---------------------------------- */
  --epc-a: #008054;
  --epc-b: #19B459;
  --epc-c: #8DCE46;
  --epc-d: #FFD500;
  --epc-e: #FCAA65;
  --epc-f: #EF8023;
  --epc-g: #E9153B;
  --epc-label-light: var(--white);     /* on A, B, F, G */
  --epc-label-dark:  var(--navy-900);  /* on C, D, E */

  /* ---- Role aliases (use these in components, not raw scales) ---------- */
  --color-bg:            var(--white);
  --color-bg-subtle:     var(--grey-50);
  --color-bg-dark:       var(--navy-700);
  --color-bg-darker:     var(--navy-900);
  --color-bg-tint:       var(--lime-100);
  --color-text:          var(--grey-700);
  --color-text-strong:   var(--navy-900);
  --color-text-muted:    var(--grey-600);
  --color-text-on-dark:  var(--white);
  --color-text-on-dark-muted: var(--grey-200);
  --color-text-on-dark-meta:  var(--grey-300);
  --color-heading:       var(--navy-500);
  --color-link:          var(--navy-500);
  --color-link-hover:    var(--navy-400);
  --color-border:        var(--grey-200);
  --color-border-strong: var(--grey-300);
  --color-accent:        var(--lime-500);
  --color-accent-hover:  var(--lime-600);
  --color-accent-text:   var(--lime-700);
  --color-on-accent:     var(--navy-900);
  --color-focus:         var(--navy-500);
  --color-focus-on-dark: var(--lime-500);

  /* ---- Typography ------------------------------------------------------- */
  --font-heading: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "Montserrat", "Segoe UI", Roboto, Arial, sans-serif;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --fs-display: clamp(2.5rem, 1.8rem + 3.2vw, 4.25rem);       /* 40 → 68 */
  --fs-h1:      clamp(2.125rem, 1.6rem + 2.4vw, 3.25rem);     /* 34 → 52 */
  --fs-h2:      clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem);       /* 28 → 40 */
  --fs-h3:      clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);     /* 22 → 28 */
  --fs-h4:      clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem); /* 18 → 21 */
  --fs-h5:      1.0625rem;                                    /* 17 */
  --fs-h6:      0.9375rem;                                    /* 15 */
  --fs-lead:    clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem); /* 18 → 21 */
  --fs-body:    clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);      /* 16 → 17 */
  --fs-small:   0.875rem;                                     /* 14 */
  --fs-xs:      0.8125rem;                                    /* 13 */
  --fs-eyebrow: 0.8125rem;                                    /* 13, uppercase */
  --fs-stat:    clamp(2.5rem, 1.8rem + 3.2vw, 4rem);          /* 40 → 64 */
  --fs-btn:     0.9375rem;                                    /* 15 */
  --fs-btn-lg:  1rem;                                         /* 16 */

  --lh-tight:  1.05;
  --lh-snug:   1.2;
  --lh-normal: 1.5;
  --lh-body:   1.65;

  --ls-tight:   -0.02em;
  --ls-heading: -0.015em;
  --ls-eyebrow:  0.12em;

  --measure: 65ch;

  /* ---- Spacing (4px base) ---------------------------------------------- */
  --space-1:  0.25rem;  /* 4  */
  --space-2:  0.5rem;   /* 8  */
  --space-3:  0.75rem;  /* 12 */
  --space-4:  1rem;     /* 16 */
  --space-5:  1.25rem;  /* 20 */
  --space-6:  1.5rem;   /* 24 */
  --space-8:  2rem;     /* 32 */
  --space-10: 2.5rem;   /* 40 */
  --space-12: 3rem;     /* 48 */
  --space-16: 4rem;     /* 64 */
  --space-20: 5rem;     /* 80 */
  --space-24: 6rem;     /* 96 */

  --section-y: clamp(3rem, 2rem + 5vw, 6rem);       /* 48 → 96 */
  --gutter:    clamp(1rem, 0.5rem + 2.5vw, 2rem);   /* 16 → 32 */
  --card-pad:  var(--space-6);

  /* ---- Radii ------------------------------------------------------------ */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   16px;
  --radius-full: 999px;

  /* ---- Shadows (navy-tinted) ------------------------------------------- */
  --shadow-sm: 0 1px 2px rgb(15 42 54 / 0.06);
  --shadow-md: 0 4px 12px -2px rgb(15 42 54 / 0.10);
  --shadow-lg: 0 16px 40px -8px rgb(15 42 54 / 0.18);
  --ring-focus:      0 0 0 3px rgb(34 82 100 / 0.15);
  --ring-focus-dark: 0 0 0 4px rgb(203 219 42 / 0.35);

  /* ---- Layout ----------------------------------------------------------- */
  --container-sm: 720px;
  --container-md: 960px;
  --container-lg: 1200px;
  --container-xl: 1360px;

  --bp-sm: 640px;   /* reference only — media queries cannot read custom props */
  --bp-md: 900px;
  --bp-lg: 1200px;

  --header-h:      64px;
  --sticky-bar-h:  56px;
  --btn-h:         44px;
  --btn-h-lg:      48px;
  --input-h:       48px;
  --touch-min:     44px;

  /* ---- Z-index ---------------------------------------------------------- */
  --z-below:      -1;
  --z-base:        0;
  --z-raised:      10;
  --z-sticky-bar:  40;
  --z-header:      50;
  --z-dropdown:    60;
  --z-mobile-nav:  70;
  --z-modal:       80;
  --z-toast:       90;

  /* ---- Motion ----------------------------------------------------------- */
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 600ms;
  --ease:     cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (min-width: 900px) {
  :root {
    --header-h: 72px;
    --card-pad: var(--space-8);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 1ms;
    --dur-base: 1ms;
    --dur-slow: 1ms;
  }
}

/* ==========================================================================
   Base resets — typography only
   ========================================================================== */

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
  color: var(--color-heading);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

h1 { font-size: var(--fs-h1); line-height: 1.1;  letter-spacing: var(--ls-tight); }
h2 { font-size: var(--fs-h2); line-height: 1.15; letter-spacing: var(--ls-heading); }
h3 { font-size: var(--fs-h3); line-height: 1.2;  letter-spacing: -0.01em; }
h4 { font-size: var(--fs-h4); line-height: 1.3; }
h5 { font-size: var(--fs-h5); line-height: 1.35; }
h6 { font-size: var(--fs-h6); line-height: 1.4;  letter-spacing: 0.01em; }

p, ul, ol, blockquote, figure, table {
  margin: 0 0 var(--space-4);
}

p:last-child,
ul:last-child,
ol:last-child {
  margin-bottom: 0;
}

.lead {
  font-size: var(--fs-lead);
  line-height: 1.55;
}

small,
.text-small {
  font-size: var(--fs-small);
  line-height: var(--lh-normal);
}

.eyebrow {
  display: block;
  margin-bottom: var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-bold);
  line-height: 1;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--color-accent-text);
}

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

a:hover {
  color: var(--color-link-hover);
  text-decoration-thickness: 2px;
}

strong, b { font-weight: var(--fw-semibold); }

/* Dark-surface context: set on hero, stats, quote band, footer */
.is-dark,
.bg-dark {
  --color-text:          var(--color-text-on-dark-muted);
  --color-text-strong:   var(--white);
  --color-text-muted:    var(--color-text-on-dark-meta);
  --color-heading:       var(--white);
  --color-link:          var(--white);
  --color-link-hover:    var(--lime-500);
  --color-border:        rgb(255 255 255 / 0.14);
  --color-accent-text:   var(--lime-500);
  --color-focus:         var(--lime-500);
  color: var(--color-text);
  background-color: var(--color-bg-dark);
}

/* Focus — consistent everywhere */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

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

/* Form controls inherit type */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  font-family: var(--font-heading);
  font-weight: var(--fw-bold);
}

/* Screen-reader-only utility */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
