/* ===========================================================================
   CORTEX — Base + Component Layer
   GOV.UK-style structural discipline; AISI restraint; TMP corporate hierarchy.
   =========================================================================== */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-body);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-strong);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--sp-4);
  font-weight: 600;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); font-weight: 600; }

p { margin: 0 0 var(--sp-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--navy-700); }

strong { font-weight: 600; color: var(--text-strong); }

img, svg { max-width: 100%; }

/* --- Focus: visible everywhere (WCAG 2.2) ----------------------------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Skip link -------------------------------------------------------- */
.skip-link {
  position: absolute; left: var(--sp-4); top: -100px;
  background: var(--navy); color: #fff; padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-sm); z-index: 1000; font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: var(--sp-4); color: #fff; }

/* --- Layout primitives ------------------------------------------------ */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.prose { max-width: var(--maxw-prose); }
.section { padding-block: var(--section-y); }
.section--page { background: var(--bg-page); }
.section--surface { background: var(--bg-surface); }
.section--panel { background: var(--bg-panel); }
.section--invert { background: var(--navy); color: var(--text-on-invert); }
.section--invert h1, .section--invert h2, .section--invert h3 { color: #fff; }
.section--invert .lead { color: var(--text-on-invert-muted); }

.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* --- Section header / kicker ------------------------------------------ */
.kicker {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-kicker); font-weight: 600;
  letter-spacing: var(--tracking-kicker); text-transform: uppercase;
  color: var(--slate-600); margin: 0 0 var(--sp-3);
}
.section--invert .kicker { color: var(--amber); }
.kicker::before {
  content: ""; width: 22px; height: 2px; background: var(--amber); display: inline-block;
}
.lead {
  font-size: var(--fs-lead); line-height: 1.5; color: var(--text-muted);
  max-width: 60ch;
}
.section-head { max-width: 60ch; margin-bottom: var(--sp-7); }

/* --- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font: inherit; font-weight: 600; font-size: var(--fs-small);
  padding: 0.75rem 1.25rem; border-radius: var(--r-sm);
  border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
  line-height: 1.2; transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn .arw { transition: transform .12s ease; }
.btn:hover .arw { transform: translateX(2px); }

.btn--primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn--primary:hover { background: var(--navy-700); color: #fff; }

.btn--secondary { background: transparent; color: var(--navy); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--white); border-color: var(--navy); color: var(--navy); }

.section--invert .btn--primary { background: var(--amber); color: var(--navy-900); border-color: var(--amber); }
.section--invert .btn--primary:hover { background: #f7be57; color: var(--navy-900); }
.section--invert .btn--secondary { color: #fff; border-color: rgba(255,255,255,.4); }
.section--invert .btn--secondary:hover { border-color: #fff; background: rgba(255,255,255,.06); color: #fff; }

/* Quiet text link with arrow */
.tlink {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 600; font-size: var(--fs-small); color: var(--navy);
  text-decoration: none;
}
.tlink::after { content: "\2192"; transition: transform .12s ease; }
.tlink:hover { text-decoration: underline; text-underline-offset: 4px; }
.tlink:hover::after { transform: translateX(3px); }
.section--invert .tlink { color: var(--amber); }

.cta-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }

/* --- Header / nav ----------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); min-height: 72px; }
.nav > nav[aria-label="Primary"] { flex: 1 1 auto; display: flex; justify-content: center; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--navy); }
.brand__mark { flex: none; }
.brand__name {
  font-weight: 600; font-size: 1.3rem; letter-spacing: 0.06em; color: var(--navy);
  text-transform: uppercase;
}
.nav__links { display: flex; align-items: center; gap: clamp(0.85rem, 2vw, 2.25rem); list-style: none; margin: 0; padding: 0; margin-inline: clamp(0.75rem, 2vw, 2rem); }
.nav__links a {
  text-decoration: none; color: var(--charcoal); font-weight: 500; font-size: var(--fs-small);
  padding: 0.5rem 0.25rem; border-bottom: 2px solid transparent;
}
.nav__links a:hover { color: var(--navy); border-bottom-color: var(--amber); }
.nav__actions { display: flex; align-items: center; gap: var(--sp-3); }
/* Compact header CTA — a navigation action, not a hero button */
.nav__actions .btn--primary {
  font-size: var(--fs-caption);
  padding: 0.42rem 0.85rem;
  border-width: 1px;
  gap: 0.35rem;
}
.nav__toggle { display: none; }

/* --- Hero ------------------------------------------------------------- */
.hero { background: var(--hero-bg); color: var(--hero-text); }
.hero h1 { color: var(--hero-text); font-size: var(--fs-display); }
.hero .lead { color: var(--hero-muted); }
.hero__grid {
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(2rem, 4vw, 4.5rem);
  align-items: center; padding-block: clamp(3rem, 2rem + 5vw, 6rem);
}
.hero__copy { max-width: 38rem; }
.hero__copy .lead { margin-bottom: var(--sp-6); }
.hero__figure { width: 100%; }

/* --- Grids ------------------------------------------------------------ */
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

/* --- Card ------------------------------------------------------------- */
.card {
  position: relative; background: var(--card-bg);
  border: var(--card-border); border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3);
}
.card__accent {
  display: var(--card-accent-display);
  height: 3px; width: 40px; background: var(--amber); border-radius: 2px; margin-bottom: var(--sp-1);
}
.card h3 { margin: 0; font-size: var(--fs-h4); }
.card__num {
  font-family: var(--font-mono); font-size: var(--fs-caption); font-weight: 500;
  color: var(--slate); letter-spacing: 0.04em;
}
.card p { color: var(--text-muted); font-size: var(--fs-small); }
.card .tlink { margin-top: auto; }
.card--link { text-decoration: none; color: inherit; }
.card--link:hover { border-color: var(--navy); box-shadow: var(--sh-lg); }
.card--link:hover h3 { color: var(--navy); }

/* sector card with motif */
.sector-card { gap: var(--sp-4); }
.sector-card .motif { width: 100%; height: 96px; border-radius: var(--r-sm); background: var(--pale); display: block; }

/* briefing card */
.brief-card .tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tag {
  font-size: var(--fs-caption); font-weight: 600; color: var(--slate-600);
  background: var(--page); border: 1px solid var(--line); padding: 0.15rem 0.6rem; border-radius: var(--r-pill);
}
:root[data-direction="institute"] .tag { background: transparent; }

/* --- Trust band ------------------------------------------------------- */
.trust-band {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
}
.trust-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.04);
  color: var(--text-on-invert); border-radius: var(--r-pill);
  padding: 0.5rem 1rem; font-size: var(--fs-small); font-weight: 500;
}
.trust-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex: none; }

/* --- Diagram frame + caption ----------------------------------------- */
.figure {
  background: var(--hero-diagram-bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-5);
}
.hero .figure { box-shadow: var(--sh-md); }
:root[data-direction="boardroom"] .hero .figure { border-color: rgba(255,255,255,.12); }
.figure--plain { background: transparent; border: 0; padding: 0; }
.figcaption {
  font-size: var(--fs-caption); color: var(--text-muted); margin-top: var(--sp-3);
  line-height: 1.5;
}
.section--invert .figcaption { color: var(--text-on-invert-muted); }

/* --- Steps (engagement path) ------------------------------------------ */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); counter-reset: step; }
.step {
  position: relative; padding: var(--sp-5); background: var(--card-bg);
  border: var(--card-border); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
}
.step__n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff;
  font-weight: 600; font-size: var(--fs-small); margin-bottom: var(--sp-3);
}
.step h3 { font-size: var(--fs-h4); }
.step p { font-size: var(--fs-small); color: var(--text-muted); margin: 0; }

/* --- Footer ----------------------------------------------------------- */
.site-footer { background: var(--navy-900); color: var(--text-on-invert-muted); padding-block: var(--sp-8) var(--sp-6); }
.footer__grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--sp-6); }
.site-footer h4 { color: #fff; font-size: var(--fs-small); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--sp-3); }
.footer__links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.footer__links a { color: var(--text-on-invert-muted); text-decoration: none; font-size: var(--fs-small); }
.footer__links a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.footer__brand .brand__name { color: #fff; }
.footer__desc { font-size: var(--fs-small); font-weight: 600; color: #fff; margin-top: var(--sp-3); letter-spacing: 0.01em; }
.footer__prov { font-size: var(--fs-small); color: var(--amber); margin-top: 2px; font-weight: 500; }
.footer__note { font-size: var(--fs-caption); line-height: 1.6; max-width: 38ch; margin-top: var(--sp-3); color: var(--text-on-invert-muted); }
.footer__base {
  margin-top: var(--sp-7); padding-top: var(--sp-5); border-top: 1px solid rgba(255,255,255,.12);
  display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: space-between;
  font-size: var(--fs-caption); color: var(--text-on-invert-muted);
}

/* --- Utilities -------------------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.stack-6 > * + * { margin-top: var(--sp-6); }

/* ===========================================================================
   RESPONSIVE
   =========================================================================== */
@media (max-width: 960px) {
  .hero__grid { grid-template-columns: 1fr; gap: var(--sp-6); padding-block: var(--sp-7); }
  .hero__figure { order: 2; }
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
  .footer__grid { grid-template-columns: 1fr 1fr; }
}

/* Collapse the mega-nav to a menu button early — 6 dropdowns + CTA need room.
   These are scoped under .site-header so they out-specify the global
   `.nav__links { position: relative }` in pages.css (which loads later);
   without the extra class the open panel would stay position:relative and
   collapse into a narrow in-flow strip. */
@media (max-width: 1024px) {
  .site-header .nav__links, .nav__actions .btn { display: none; }
  .nav__toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: var(--navy); color: #fff; border: 0; border-radius: var(--r-sm);
    padding: 0.6rem 0.9rem; font: inherit; font-weight: 600; font-size: var(--fs-small); cursor: pointer;
  }
  .site-header .nav__links--open {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; left: 0; right: 0; top: 100%; margin: 0;
    background: #fff; border-bottom: 1px solid var(--line); padding: var(--sp-4) var(--gutter);
    gap: 0; box-shadow: var(--sh-lg); max-height: 75vh; overflow-y: auto;
  }
  .site-header .nav__links--open li { width: 100%; }
  .site-header .nav__links--open a { display: block; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr; }
}
