/* The Base Rate — shared theme: design tokens (single source of truth),
   light/dark, sticky header, and accessibility. Loaded on every page;
   tokens use !important so they unify each page's older inline :root. */

:root{
  --bg0:#080B12 !important; --bg1:#0D1426 !important;
  --card:#121a2e !important; --card2:#1a2440 !important;
  --teal:#1DB8A4 !important; --teal-br:#43E6CE !important;
  --gold:#E6BC4A !important; --white:#F4F7FC !important;
  --grey:#9DAAC4 !important; --dgrey:#8593B0 !important;   /* bumped for WCAG AA on dark */
  --edge:#2b3a5c !important; --red:#E25C5C !important;
  --page-bg:
      radial-gradient(900px 520px at 12% -5%, rgba(29,184,164,.16), transparent 60%),
      radial-gradient(820px 520px at 100% 8%, rgba(230,188,74,.12), transparent 55%),
      radial-gradient(1200px 800px at 50% 100%, #101b34 0%, #0D1426 40%, #080B12 100%) !important;
  --panel: linear-gradient(180deg,#16284a,#0f1c34) !important;
  --header-bg: rgba(9,13,22,.80) !important;
  --card-shadow: 0 20px 50px rgba(0,0,0,.40) !important;
  --logo-ink:#06231f;
}

:root[data-theme="light"]{
  --bg0:#EDF2F8 !important; --bg1:#E4EDF6 !important;
  --card:#FFFFFF !important; --card2:#FBFDFF !important;
  --teal:#0B7567 !important; --teal-br:#0B7567 !important;
  --gold:#9A7011 !important; --white:#11192A !important;   /* "white" = foreground ink in light mode */
  --grey:#46536E !important; --dgrey:#5C6883 !important;
  --edge:#D4DEEA !important; --red:#C23B3B !important;
  --page-bg:
      radial-gradient(900px 520px at 12% -5%, rgba(29,184,164,.10), transparent 60%),
      radial-gradient(820px 520px at 100% 8%, rgba(230,188,74,.12), transparent 55%),
      radial-gradient(1200px 800px at 50% 100%, #e8f0f9 0%, #f2f6fb 40%, #ffffff 100%) !important;
  --panel: linear-gradient(180deg,#ffffff,#f3f8fc) !important;
  --header-bg: rgba(255,255,255,.85) !important;
  --card-shadow: 0 14px 40px rgba(20,40,80,.10) !important;
  --logo-ink:#FFFFFF;
}

/* Tokenise surfaces that pages hardcoded, so they follow the theme */
body{ background: var(--page-bg) !important; color: var(--white); padding:0 0 64px 0 !important; min-height:100vh; }
.wrap{ padding-left:clamp(14px,4vw,20px) !important; padding-right:clamp(14px,4vw,20px) !important; }
.card{ box-shadow: var(--card-shadow) !important; }
.result{ background: var(--panel) !important; }
.seg{ color:#0A1018 !important; }   /* labels on bright bars: always dark for contrast */

/* ---- Sticky header / nav -------------------------------------------- */
.site-header{
  position:sticky; top:0; z-index:60;
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  padding:9px clamp(14px,4vw,26px); margin-bottom:8px;
  background:var(--header-bg); border-bottom:1px solid var(--edge);
  -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px);
  font-family:'Poppins',system-ui,sans-serif;
}
.site-header .logo{ display:flex; align-items:center; gap:9px; text-decoration:none;
  color:var(--white); font-weight:800; font-size:15px; letter-spacing:.02em; white-space:nowrap; }
.site-header .logo .tile{ width:26px; height:26px; border-radius:7px; background:var(--teal);
  display:grid; place-items:center; color:var(--logo-ink); font-weight:800; font-size:15px; }
.site-header nav{ display:flex; align-items:center; gap:2px; flex-wrap:wrap; justify-content:flex-end; }
.site-header nav a{ color:var(--grey); text-decoration:none; font-weight:600; font-size:13.5px;
  padding:7px 10px; border-radius:9px; white-space:nowrap; }
.site-header nav a:hover{ color:var(--white); background:color-mix(in srgb, var(--grey) 16%, transparent); }
.site-header nav a[aria-current="page"]{ color:var(--teal); }
.theme-toggle{ margin-left:4px; background:transparent; border:1.5px solid var(--edge);
  color:var(--white); width:38px; height:34px; border-radius:9px; cursor:pointer;
  font-size:15px; line-height:1; display:grid; place-items:center; font-family:inherit; }
.theme-toggle:hover{ border-color:var(--teal); }
@media(max-width:600px){
  .site-header{ flex-direction:column; align-items:stretch; gap:8px; padding-top:11px; }
  .site-header nav{ justify-content:center; }
}

/* skip link for keyboard/screen-reader users */
.skip-link{ position:absolute; left:-9999px; top:0; z-index:100; background:var(--teal);
  color:var(--logo-ink); padding:10px 16px; border-radius:0 0 10px 0; font-weight:700; text-decoration:none; }
.skip-link:focus{ left:0; }

/* ---- Accessibility -------------------------------------------------- */
*:focus-visible{ outline:2px solid var(--teal); outline-offset:2px; border-radius:3px; }
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
  html{ scroll-behavior:auto !important; }
}

/* ---- Cookie consent banner ------------------------------------------ */
.cookie-banner{ position:fixed; left:12px; right:12px; bottom:12px; z-index:80; margin:0 auto;
  max-width:780px; background:var(--card2); border:1px solid var(--edge); border-radius:16px;
  padding:15px 18px; box-shadow:0 18px 50px rgba(0,0,0,.45);
  display:flex; gap:14px; align-items:center; flex-wrap:wrap;
  font-family:'Poppins',system-ui,sans-serif; color:var(--grey); font-size:13.5px; line-height:1.5; }
.cookie-banner p{ margin:0; flex:1 1 300px; }
.cookie-banner a{ color:var(--teal); }
.cookie-banner .btns{ display:flex; gap:8px; flex:0 0 auto; flex-wrap:wrap; }
.cookie-banner button{ font-family:inherit; font-weight:700; font-size:13.5px; padding:10px 16px;
  border-radius:10px; cursor:pointer; border:1.5px solid var(--edge); }
.cookie-banner .accept{ background:var(--teal); border-color:var(--teal); color:var(--logo-ink); }
.cookie-banner .reject{ background:transparent; color:var(--white); }
.cookie-settings-link{ background:none; border:none; color:var(--grey); font:inherit; cursor:pointer;
  text-decoration:underline; padding:0; }

/* ---- Embed mode (calculator inside someone else's page via ?embed) -- */
body.embed .site-header, body.embed .skip-link, body.embed .cookie-banner,
body.embed .cta, body.embed .below, body.embed .disc{ display:none !important; }
body.embed{ padding-bottom:8px !important; }
.embed-foot{ max-width:1000px; margin:14px auto 0; padding:11px 16px; border-top:1px solid var(--edge);
  display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; align-items:center;
  font-size:12px; color:var(--dgrey); font-family:'Poppins',system-ui,sans-serif; }
.embed-foot a{ color:var(--teal); text-decoration:none; font-weight:700; }

/* ---- "Embed this calculator" snippet box ---------------------------- */
.embed-cta{ max-width:760px; margin:18px auto 0; border:1px solid var(--edge); border-radius:18px;
  padding:18px 20px; background:linear-gradient(180deg,var(--card2),var(--card));
  font-family:'Poppins',system-ui,sans-serif; }
.embed-cta h2{ font-size:18px; font-weight:700; margin:0 0 6px; color:var(--white); }
.embed-cta p{ color:var(--grey); font-size:13.5px; margin:0 0 10px; }
.embed-cta textarea{ width:100%; height:84px; resize:vertical; background:var(--bg0);
  border:1.5px solid var(--edge); color:var(--grey); border-radius:10px; padding:10px 12px;
  font-family:ui-monospace,Menlo,Consolas,monospace; font-size:12px; }
.embed-cta textarea:focus{ outline:none; border-color:var(--teal); }
.embed-cta .copy{ margin-top:10px; background:var(--teal); border:none; color:var(--logo-ink);
  font-family:inherit; font-weight:700; font-size:13.5px; padding:10px 16px; border-radius:10px; cursor:pointer; }
