@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

/* Base / Theme Tokens */
:root {
  --primary: #3338A0;
  --primary-600: #2a2f86;
  --primary-700: #1e226a;
  --primary-800: #15194e;

  --secondary: #FCC61D;
  --secondary-600: #e4b017;
  --secondary-800: #b1880c;

  --bg: #ffffff;
  --text: #101114;
  --muted: #5b6071;
  --surface: #f6f7fb;
  --surface-2: #eef0f7;
  --border: #d8dbe7;
  --focus: #0b5fff;
  --brand-accent: var(--secondary-800);
  --btn-text: var(--primary);

  /* Link tokens */
  --link: var(--primary);
  --link-hover: color-mix(in srgb, var(--primary) 85%, #000 15%);

  /* Header offset (JS updates this dynamically) */
  --header-offset: 72px;

  color-scheme: light dark;
}

:root[data-theme="dark"] {
  --bg: #0f1118;
  --text: #e9ecf1;
  --muted: #a4a9ba;
  --surface: #151829;
  --surface-2: #1b1f34;
  --border: #2d3352;
  --focus: #89a8ff;
  --brand-accent: var(--secondary);
  --btn-text: var(--text);

  /* Lighter link color in dark theme */
  --link: #c9d0ff;
  --link-hover: #aeb7ff;

  transition: all ease 250ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; scroll-padding: var(--header-offset); }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Poppins","Noto Sans", "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  /* Prevent content hiding under fixed header */
  padding-top: var(--header-offset);
}

/* Accessibility helpers */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  top: 0; left: 0;
  transform: translateY(-100%);
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 0 0 0.5rem 0;
  text-decoration: none;
  z-index: 1000;
}
.skip-link:focus { transform: translateY(0); }

/* Layout */
.container { width: min(1100px, 92vw); margin-inline: auto; }
.flow > * + * { margin-top: 2rem; }

/* Header (now fixed, no scroll transition state) */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 999;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0.25rem;
}
.brand {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.625rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand-logo img { width: clamp(0.35rem, 5vw, 2rem); }
.brand-text { font-size: 1.1rem; }
.brand-accent { color: var(--brand-accent); }

/* Global link styles (lighter in dark mode via tokens) */
a:not(.btn) {
  color: var(--link);
  text-decoration: none;
}
a:not(.btn):hover,
a:not(.btn):focus-visible {
  color: var(--link-hover);
  text-decoration: underline;
  outline: none;
}

/* Nav */
.nav ul {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
}
.nav a {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--text);
  text-decoration: none;
}
.nav a:hover, .nav a:focus-visible {
  background: var(--surface-2);
  outline: none;
}

/* Actions */
.header-actions { display: inline-flex; align-items: center; gap: 0.5rem; }
.theme-toggle, .menu-toggle, .btn { font: inherit; cursor: pointer; border: none; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.675rem;
  border-radius: 0.6rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.theme-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

h1, h2, h3 { font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji",
               "Segoe UI Emoji", sans-serif;
  font-optical-sizing: auto;
  line-height: 1.6; }

/* Hamburger */
.menu-toggle {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border-radius: 0.6rem;
  background: var(--primary);
  color: #fff;
}
.menu-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 20px; height: 2px;
  background: currentColor;
  border-radius: 2px;
  content: "";
  transition: transform 200ms ease, opacity 200ms ease;
}
.menu-icon { position: relative; }
.menu-icon::before { position: absolute; transform: translateY(-6px); }
.menu-icon::after  { position: absolute; transform: translateY(6px); }

/* Mobile-first nav: collapsed by default when JS is enabled */
html.js .nav {
  position: fixed;
  inset: 0 0 auto 0;
  top: var(--header-offset);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transform: translateY(-110%);
  transition: transform 200ms ease;
}
html.js .nav.open { transform: translateY(0); }
html.js .nav ul { flex-direction: column; padding: 0.75rem; }
html.js .nav a { padding: 0.5rem; }

/* Hero */
.hero {
  padding: clamp(2rem, 5vw, 4rem) 2rem;
  background:
    radial-gradient(1400px 400px at 110% -20%, var(--secondary) 0%, transparent 60%),
    radial-gradient(900px 300px at 120% 60%, color-mix(in oklab, var(--secondary) 60%, #fff) 0%, transparent 60%),
    linear-gradient(0deg, var(--surface), var(--surface));
  border: 1px solid var(--border);
  border-radius: 1rem;
  margin-top: 1rem;
}
h1 { font-size: clamp(2rem, 10vw, 3.25rem); }
.lead { color: var(--muted); max-width: 60ch; }

.btn {
  display: inline-block;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  text-decoration: none !important;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--primary-600); outline: none; }
.btn-ghost {
  background: transparent; color: var(--btn-text);
  border: 1px solid var(--primary);
}
.btn-ghost:hover, .btn-ghost:focus-visible {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  outline: none;
}

/* Cards */
.card-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.card-grid h2 { margin-bottom: 0.5rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 1rem;
}
.card h3 { margin-top: 0; }

/* Prose section */
.prose a { color: var(--link); }
.prose a:hover, .prose a:focus-visible { color: var(--link-hover); }

/* Footer */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  padding: 1rem 0.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.back-to-top { color: var(--link); text-decoration: none; }
.back-to-top:hover, .back-to-top:focus-visible { color: var(--link-hover); }
.back-to-top:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Desktop enhancements */
@media (min-width: 900px) {
  .nav { flex: 1 1 auto; }
  .nav ul {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem 0.5rem;
  }
  .nav a { white-space: nowrap; }
  h1 { font-size: clamp(2.5rem, 15vw, 4rem); }
  .header-inner { padding: 0.5rem 0; }
  .menu-toggle { display: none; }
  html.js .nav { position: static; transform: none; border-bottom: none; top: auto; }
  html.js .nav ul { flex-direction: row; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* --- Mobile drawer not covering hamburger: fixes --- */

/* Keep header above everything */
.site-header {
  position: fixed;       /* you already have this */
  top: 0; left: 0; right: 0;
  z-index: 1100;         /* bumped up for safety */
}

/* Ensure the brand + actions (hamburger/theme) paint above the drawer */
.header-inner { position: relative; }
.brand, .header-actions { position: relative; z-index: 2; }

/* Drawer sits below header and below the buttons */
html.js .nav {
  position: fixed;
  top: 0;                /* anchor to viewport top */
  left: 0; right: 0;
  padding-top: var(--header-offset);   /* push content below header */
  transform: translateY(-110%);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 1;            /* under .brand/.header-actions, over page content */
}

/* Desktop reset (no drawer layout on wide screens) */
@media (min-width: 900px) {
  html.js .nav {
    position: static;
    transform: none;
    padding-top: 0;
    border-bottom: 0;
    z-index: auto;
  }
}

/* Animate only when the html has .theme-animate */
html.theme-animate * {
  transition: background-color 275ms ease, color 275ms ease,
              border-color 275ms ease, fill 275ms ease, stroke 275ms ease,
              box-shadow 275ms ease;
}

@media (prefers-reduced-motion: reduce), (forced-colors: active) {
  html.theme-animate * { transition: none !important; }
}

/* Sponsored section */
.sponsored-section {
  /* uses your grid, just styled differently */
  border: 1px solid color-mix(in srgb, var(--secondary) 45%, transparent);
  background:
    linear-gradient(0deg,
      color-mix(in srgb, var(--secondary) 10%, transparent),
      color-mix(in srgb, var(--secondary) 10%, transparent));
  border-radius: 1rem;
  padding: 1rem;
  gap: 1rem;
}

/* Dark theme tuning: a bit stronger tint for clarity */
:root[data-theme="dark"] .sponsored-section {
  border-color: color-mix(in srgb, var(--secondary) 55%, transparent);
  background:
    linear-gradient(0deg,
      color-mix(in srgb, var(--secondary) 18%, transparent),
      color-mix(in srgb, var(--secondary) 18%, transparent));
}

.sponsored-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.25rem 0 0.5rem;
}

.sponsored-badge {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.5rem;
  border-radius: 0.4rem;
  background: var(--secondary);
  color: #111;
  border: 1px solid color-mix(in srgb, #000 12%, var(--secondary));
}

/* Disclosure */
.sponsored-disclosure {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.6rem;
  padding: 0.5rem 0.75rem;
}
.sponsored-disclosure summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}
.sponsored-disclosure[open] {
  border-style: solid;
}

/* Sponsor cards inherit .card but can get subtle lift */
.card.sponsor {
  background: color-mix(in srgb, var(--surface) 88%, #fff 12%);
  border-color: color-mix(in srgb, var(--secondary) 25%, var(--border));
}
:root[data-theme="dark"] .card.sponsor {
  background: color-mix(in srgb, var(--surface) 88%, #000 12%);
  border-color: color-mix(in srgb, var(--secondary) 30%, var(--border));
}
:root[data-theme="dark"] .sponsored-disclosure summary {
  color: #ddf;
}

/* Optional: reduce motion-friendly emphasis when section appears */
@media (prefers-reduced-motion: no-preference) {
  .sponsored-section { transition: background-color 240ms, border-color 240ms; }
}

#about {
    min-height: 50vh;
}

/* -------- Alert bar -------- */
.alert-bar[hidden] { display: none !important; }
.alert-bar {
  position: sticky;               /* stays visible under the header */
  top: var(--header-offset);
  z-index: 100;                   /* below the fixed header; above page content */
  background: color-mix(in srgb, var(--secondary) 92%, #fff 8%);
  border-bottom: 1px solid color-mix(in srgb, #000 12%, var(--secondary));
  color: #111;
}
:root[data-theme="dark"] .alert-bar {
  background: color-mix(in srgb, var(--secondary) 24%, #000 76%);
  color: #fff;
  border-bottom-color: color-mix(in srgb, #fff 18%, transparent);
}
.alert-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
}
.alert-msg { margin: 0; }
.alert-close {
  border: 0; border-radius: 0.5rem;
  padding: 0.25rem 0.55rem;
  background: color-mix(in srgb, #000 10%, transparent);
  color: currentColor;
  cursor: pointer;
}
.alert-close:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Optional: color-tint the alert bar by severity */
.alert-bar[data-severity="Extreme"],
:root[data-theme="dark"] .alert-bar[data-severity="Extreme"],
.alert-bar[data-severity="Severe"],
:root[data-theme="dark"] .alert-bar[data-severity="Severe"] {
  background: #f12a2a;
  color: #fff;
}
.alert-bar[data-severity="Moderate"],
:root[data-theme="dark"] .alert-bar[data-severity="Moderate"] {
  background: color-mix(in srgb, #ff9800 45%, var(--secondary));
  color: #111;
}
.alert-bar[data-severity="Minor"] {
  background: color-mix(in srgb, var(--focus) 50%, #fff 50%);
  color: #111;
}
:root[data-theme="dark"] .alert-bar[data-severity="Minor"] {
  background: color-mix(in srgb, var(--secondary) 24%, #000 76%);
  color: #fff;
}
.alert-link { text-decoration: underline; }


/* Optional: improve GPU compositing during theme toggle */
.site-header, .alert-bar, .card {
  will-change: background-color, border-color, box-shadow;
}
