/* ============================================================
   UK Government Tracker — shared base stylesheet
   Single source of truth for the chrome shared by every page:
   reset, top bar, header, primary navigation, the mobile
   navigation drawer, and small-screen layout polish.

   Page-specific styles (hero panels, charts, tables, colour
   variables) still live in each page's own <style> block and
   override anything here, because each page links this file
   BEFORE its inline styles.
   ============================================================ */

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
html, body { max-width: 100%; overflow-x: clip; }

body {
  font-family: var(--font-body, 'Quicksand', sans-serif);
  background: var(--bg, #f0f1f4);
  color: var(--text-primary, #0f1117);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Stop wide media/tables from forcing horizontal scroll on phones */
img, canvas, svg, video, iframe, table { max-width: 100%; }

h1, h2, h3, h4 { font-family: var(--font-head, 'Montserrat', sans-serif); }

/* ── Header ────────────────────────────────────────────── */
header {
  background: var(--white, #ffffff);
  border-bottom: 1px solid var(--border, #dde0e7);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 62px; display: flex; align-items: center;
  justify-content: space-between; gap: 24px;
}
.logo { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.logo-mark {
  width: 38px; height: 38px; background: var(--accent, #00358a);
  border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-mark svg { width: 33px; height: 33px; fill: #fff; }
.logo-text { display: flex; flex-direction: column; line-height: 1.04; }
.logo-text span {
  font-family: var(--font-head, 'Montserrat', sans-serif);
  font-size: 15px; font-weight: 800; letter-spacing: -.02em;
}
.logo-text span:first-child { color: var(--text-primary, #0f1117); }
.logo-text span:last-child { color: var(--accent, #00358a); }

/* ── Primary navigation ────────────────────────────────── */
nav { display: flex; align-items: center; gap: 1px; }
nav a {
  font-family: var(--font-head, 'Montserrat', sans-serif);
  font-size: 13px; font-weight: 600; color: var(--text-secondary, #454c5e);
  text-decoration: none; padding: 6px 9px; border-radius: var(--radius-sm, 6px);
  transition: background .15s, color .15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.nav-ico { width: 15px; height: 15px; stroke: currentColor; fill: none; flex-shrink: 0; }
nav a:hover { background: var(--off-white, #f6f7f9); color: var(--text-primary, #0f1117); }
nav a.active { color: var(--accent, #00358a); background: var(--accent-light, #e5edfb); }

/* ── Mobile navigation toggle (hamburger) ──────────────── */
.nav-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 42px; height: 42px; padding: 10px; margin-left: auto;
  background: transparent;
  border: 1px solid var(--border, #dde0e7);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer; flex-shrink: 0;
}
.nav-toggle span {
  display: block; width: 100%; height: 2px; border-radius: 2px;
  background: var(--text-primary, #0f1117);
  transition: transform .25s ease, opacity .2s ease;
}
header.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
header.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
header.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Responsive: tablet / mobile ───────────────────────── */
@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  header .nav-inner > nav {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: 8px;
    background: var(--white, #ffffff);
    border-top: 1px solid var(--border, #dde0e7);
    border-bottom: 1px solid var(--border, #dde0e7);
    box-shadow: 0 8px 24px rgba(0,0,0,.10);
    max-height: calc(100vh - 60px); overflow-y: auto;
  }
  header.nav-open .nav-inner > nav { display: flex; }
  header .nav-inner > nav a {
    width: 100%; font-size: 15px; padding: 12px 14px;
    border-radius: var(--radius-sm, 6px);
  }
}

/* Small phones: tighten gutters, scale oversized display numbers */
@media (max-width: 600px) {
  .nav-inner { padding-left: 16px; padding-right: 16px; gap: 12px; }
  .hero, .page-hero { padding-left: 16px; padding-right: 16px; }
  .main-content, .main, body > main { padding-left: 16px; padding-right: 16px; }
  footer { padding-left: 16px; padding-right: 16px; }
  .counter-number { font-size: 44px; }
  .hero h1 { font-size: clamp(24px, 7vw, 30px); }

  .cr-table th, .cr-table td { padding-left: 9px; padding-right: 9px; }
  .asy-table th, .asy-table td { padding-left: 10px; padding-right: 10px; }
  .asy-table td:first-child, .asy-table th:first-child { padding-left: 12px; }
  .asy-table td:nth-child(2),
  .asy-table td:nth-child(3),
  .asy-table td:nth-child(4),
  .asy-table td:nth-child(5) { padding-left: 10px; }
}

/* Very small phones: collapse remaining multi-column rows */
@media (max-width: 420px) {
  .stats-bar, .stat-row, .stat-row-3, .stat-grid,
  .branch-grid, .spend-grid, .kpi-grid, .intercon-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .footer-copy { text-align: left; }
}

/* ── Shared site footer ────────────────────────────────── */
.site-footer { background: #0b1f44; color: rgba(255,255,255,.72); margin-top: 56px; }
.site-footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 40px 24px 26px;
  display: flex; flex-wrap: wrap; gap: 28px 48px; justify-content: space-between;
}
.sf-brand { max-width: 360px; }
.sf-logo { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.sf-mark {
  width: 36px; height: 36px; background: #fff; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sf-mark svg { width: 31px; height: 31px; fill: #0b1f44; }
.sf-name { font-family: var(--font-head, 'Montserrat', sans-serif); font-size: 15px; font-weight: 800; color: #fff; letter-spacing: -.01em; }
.sf-tagline { font-size: 13px; line-height: 1.6; color: rgba(255,255,255,.6); margin: 12px 0 0; }
.sf-links { display: flex; flex-wrap: wrap; gap: 10px 22px; align-content: flex-start; }
.sf-links a {
  font-family: var(--font-head, 'Montserrat', sans-serif); font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.82); text-decoration: none;
}
.sf-links a:hover { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.site-footer-bottom {
  max-width: 1200px; margin: 0 auto; padding: 16px 24px 30px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between;
  font-size: 12.5px; color: rgba(255,255,255,.58);
}
.site-footer-bottom a { color: rgba(255,255,255,.9); text-decoration: underline; text-underline-offset: 2px; }
.site-footer-bottom a:hover { color: #fff; }
@media (max-width: 600px) {
  .site-footer-inner { padding: 32px 16px 20px; gap: 22px; }
  .site-footer-bottom { padding: 16px 16px 26px; }
}
