/* AIP shared component styles.
   Tokens live in tokens.css. Fonts in fonts.css. This file must not
   declare a brand colour or a font stack — only var() references. */
@import url('tokens.css');
@import url('fonts.css');

/* ── AIP — K–12 AI Governance · Shared stylesheet ──
   Owns: design tokens, nav, page-header, breadcrumb chip, alerts, tables,
   cards, badges, footer, print. Page-specific styles live inline.

   Mode = which "door" the page belongs to (tools / blueprint / showcase /
   program / research). Set on <body class="mode-tools"> etc. — accents
   automatically follow.                                                    */

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


/* Mode body classes override the defaults */
body.mode-tools     { --mode: var(--mode-tools);     --mode-dark: var(--mode-tools-dark);     --mode-soft: var(--mode-tools-soft); }
body.mode-blueprint { --mode: var(--mode-blueprint); --mode-dark: var(--mode-blueprint-dark); --mode-soft: var(--mode-blueprint-soft); }
body.mode-showcase  { --mode: var(--mode-showcase);  --mode-dark: var(--mode-showcase-dark);  --mode-soft: var(--mode-showcase-soft); }
body.mode-program   { --mode: var(--mode-program);   --mode-dark: var(--mode-program-dark);   --mode-soft: var(--mode-program-soft); }
body.mode-research  { --mode: var(--mode-research);  --mode-dark: var(--mode-research-dark);  --mode-soft: var(--mode-research-soft); }

/* Design system: type roles come from tokens.css (--font-heading / --font-body).
   The !important is intentional — many pages have inherited inline overrides we want to defeat
   so the whole site reads as one system. Inline mode classes (body.mode-XXX) still drive the
   accent color via CSS variables. */
body {
  font-family: var(--font-body) !important;
  color: var(--text);
  background: #fff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--mode); }

/* ── Accessibility primitives ── */
:focus-visible {
  outline: 2px solid var(--mode);
  outline-offset: 2px;
  border-radius: 4px;
}
.site-nav :focus-visible,
.page-header :focus-visible,
.site-footer :focus-visible { outline-color: #fff; }

/* Skip-link: hidden until focused */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: var(--z-modal);
  background: var(--brand-dark);
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover, .door:hover, a.card:hover { transform: none !important; }
}

h1, h2, h3, h4 { font-family: var(--font-heading) !important; color: var(--brand); }

/* ── Top nav ── */
.site-nav {
  background: var(--brand-dark);
  padding: 0 32px;
  display: flex;
  align-items: center;
  height: 48px;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }
/* On narrow viewports, fade the right edge so users see there's nav past the cut-off.
   Uses mask-image so the gradient doesn't scroll with content. */
@media (max-width: 700px) {
  .site-nav {
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 28px), transparent 100%);
            mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 28px), transparent 100%);
  }
}
.nav-brand {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-soft);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  margin-right: 28px;
  white-space: nowrap;
}
.nav-brand:hover { color: #fff; }
.nav-links { display: flex; gap: 0; }
.nav-link {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  padding: 0 14px;
  height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.nav-link:hover { color: #fff; }
.nav-link.active {
  color: #fff;
  border-bottom-color: var(--mode);
}
.nav-sep { color: rgba(255,255,255,0.2); padding: 0 6px; display: flex; align-items: center; font-size: 11px; }

/* ── Page header ──
   Forced with !important so the mode gradient defeats inherited inline
   `background: var(--brand)` overrides on imported pages. */
.page-header {
  background: linear-gradient(135deg, var(--mode-dark), var(--mode)) !important;
  color: #fff;
  position: relative;
  overflow: hidden;
  padding: 48px 32px 36px;
}
/* Per-mode explicit overrides so the body class always wins even against
   inline page-specific styles. */
body.mode-tools     .page-header { background: linear-gradient(135deg, var(--mode-tools-dark),     var(--mode-tools))     !important; }
body.mode-blueprint .page-header { background: linear-gradient(135deg, var(--mode-blueprint-dark), var(--mode-blueprint)) !important; }
body.mode-showcase  .page-header { background: linear-gradient(135deg, var(--mode-showcase-dark),  var(--mode-showcase))  !important; }
body.mode-program   .page-header { background: linear-gradient(135deg, var(--mode-program-dark),   var(--mode-program))   !important; }
body.mode-research  .page-header { background: linear-gradient(135deg, var(--mode-research-dark),  var(--mode-research))  !important; }
.page-header::after {
  content: '';
  position: absolute;
  right: -100px;
  top: -100px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  pointer-events: none;
}
.page-header > * { position: relative; }

/* Breadcrumb chip */
.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
  text-decoration: none;
}
.breadcrumb a { color: rgba(255,255,255,0.85); text-decoration: none; }
.breadcrumb a:hover { color: #fff; }
.breadcrumb .sep { opacity: 0.5; }

.page-header h1 { font-size: 2.1rem; font-weight: 700; line-height: 1.2; margin-bottom: 12px; color: #fff; }
.page-header .sub { font-size: 15px; color: rgba(255,255,255,0.85); max-width: 640px; line-height: 1.6; }

.page-header .stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.page-header .stat .n {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}
.page-header .stat .l {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── Layout containers ── */
.container       { max-width: 960px;  margin: 0 auto; padding: 48px 32px 80px; }
.container-wide  { max-width: 1100px; margin: 0 auto; padding: 48px 32px 80px; }
.container-narrow{ max-width: 760px;  margin: 0 auto; padding: 48px 32px 80px; }

/* ── Section labels ──
   Both `.section-label` (our new convention) and `.section-heading` (used by
   imported showcase / blueprint pages) get the mode accent via !important
   overrides per body class. This keeps section dividers visually mode-aware
   across the entire site. */
.section-label, .section-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--mode);
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 24px;
  margin-top: 48px;
}
.section-label:first-of-type, .section-heading:first-of-type { margin-top: 0; }
body.mode-tools     .section-label, body.mode-tools     .section-heading { color: var(--mode-tools)     !important; }
body.mode-blueprint .section-label, body.mode-blueprint .section-heading { color: var(--mode-blueprint) !important; }
body.mode-showcase  .section-label, body.mode-showcase  .section-heading { color: var(--mode-showcase)  !important; }
body.mode-program   .section-label, body.mode-program   .section-heading { color: var(--mode-program)   !important; }
body.mode-research  .section-label, body.mode-research  .section-heading { color: var(--mode-research)  !important; }

/* Active nav-link underline uses the page's mode color */
body.mode-tools     .nav-link.active { border-bottom-color: var(--mode-tools)     !important; color: #fff !important; }
body.mode-blueprint .nav-link.active { border-bottom-color: var(--mode-blueprint) !important; color: #fff !important; }
body.mode-showcase  .nav-link.active { border-bottom-color: var(--mode-showcase)  !important; color: #fff !important; }
body.mode-program   .nav-link.active { border-bottom-color: var(--mode-program)   !important; color: #fff !important; }
body.mode-research  .nav-link.active { border-bottom-color: var(--mode-research)  !important; color: #fff !important; }

h3 { font-size: 1.05rem; margin: 24px 0 12px; }
h4 { font-size: 0.95rem; font-family: var(--font-sans); font-weight: 700; margin: 16px 0 8px; }

p { font-size: 15px; margin-bottom: 12px; line-height: 1.65; }

ul, ol { padding-left: 22px; margin-bottom: 14px; }
li { font-size: 14px; margin-bottom: 6px; line-height: 1.55; }

/* ── Alerts ── */
.alert {
  border-radius: 0 8px 8px 0;
  padding: 14px 18px 14px 22px;
  margin-bottom: 16px;
  font-size: 14px;
  position: relative;
}
.alert::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}
.alert-green  { background: #f0faf4; color: #0a3a1e; }
.alert-green::before  { background: var(--green); }
.alert-amber  { background: #fff8e6; color: #5a3e00; }
.alert-amber::before  { background: var(--amber); }
.alert-red    { background: #fff4f4; color: #5a0000; }
.alert-red::before    { background: var(--red); }
.alert-blue   { background: #e8f4fb; color: #0a2a3a; }
.alert-blue::before   { background: var(--accent); }
.alert-mode   { background: var(--mode-soft); color: var(--text); }
.alert-mode::before   { background: var(--mode); }
.alert strong { font-weight: 700; }

/* ── Status badges ── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  vertical-align: middle;
}
.badge-delivered, .badge-complete, .badge-low, .badge-closed { background: #e6f9ef; color: var(--green); }
.badge-active     { background: #e8f4fb; color: var(--accent); }
.badge-review, .badge-mitigated, .badge-med { background: #fff8e6; color: var(--amber); }
.badge-pending    { background: #f4f4f4; color: var(--muted); }
.badge-high, .badge-open { background: #fff0f0; color: var(--red); }
.badge-mode { background: var(--mode-soft); color: var(--mode-dark); }

/* ── Data tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}
.data-table th {
  background: var(--brand);
  color: #fff;
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:nth-child(even) td { background: var(--light-bg); }
.data-table .wrap { white-space: normal; max-width: 280px; }

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 16px;
  text-align: center;
}
.stat-card .num {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
}
.stat-card .lbl {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  letter-spacing: 0.5px;
}
.stat-card.highlight {
  background: var(--brand);
  border-color: var(--brand);
}
.stat-card.highlight .num { color: #fff; }
.stat-card.highlight .lbl { color: var(--accent-soft); }

/* ── Card grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
}
a.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.08); transform: translateY(-1px); }
a.card:active { transform: translateY(0); transition-duration: 50ms; }
.card h4 { font-size: 14px; color: var(--brand); margin-bottom: 8px; }
.card p { font-size: 13px; color: var(--muted); margin-bottom: 0; }

/* ── Door card (three-doors hub) ── */
.doors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 22px;
}
.door {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s, transform 0.18s;
}
.door:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.1); transform: translateY(-3px); }
.door:active { transform: translateY(0); transition-duration: 50ms; }
.door .door-head {
  padding: 28px 26px 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.door .door-head::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
}
.door.tools     .door-head { background: linear-gradient(135deg, var(--mode-tools-dark), var(--mode-tools)); }
.door.blueprint .door-head { background: linear-gradient(135deg, var(--mode-blueprint-dark), var(--mode-blueprint)); }
.door.showcase  .door-head { background: linear-gradient(135deg, var(--mode-showcase-dark), var(--mode-showcase)); }
.door.program   .door-head { background: linear-gradient(135deg, var(--mode-program-dark), var(--mode-program)); }
.door .door-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 10px;
  position: relative;
}
.door h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 8px;
  position: relative;
}
.door .door-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  position: relative;
  line-height: 1.5;
}
.door .door-body {
  padding: 22px 26px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.door ul { list-style: none; padding: 0; margin: 0 0 16px; flex: 1; }
.door ul li {
  font-size: 13px;
  color: var(--text);
  padding: 6px 0 6px 18px;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.door ul li:last-child { border-bottom: none; }
.door ul li::before {
  content: '→';
  position: absolute;
  left: 0;
  font-weight: 700;
  font-size: 11px;
  top: 7px;
}
.door.tools     ul li::before { color: var(--mode-tools); }
.door.blueprint ul li::before { color: var(--mode-blueprint); }
.door.showcase  ul li::before { color: var(--mode-showcase); }
.door.program   ul li::before { color: var(--mode-program); }
.door .door-cta {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
}
.door.tools     .door-cta { background: var(--mode-tools); }
.door.blueprint .door-cta { background: var(--mode-blueprint); }
.door.showcase  .door-cta { background: var(--mode-showcase); }
.door.program   .door-cta { background: var(--mode-program); }

/* ── Mode CTA button ── */
.btn {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 10px 22px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary {
  background: var(--mode);
  color: #fff;
}
.btn-primary:hover { background: var(--mode-dark); }
.btn-ghost {
  background: transparent;
  border-color: var(--mode);
  color: var(--mode);
}
.btn-ghost:hover { background: var(--mode-soft); }

/* ── Cross-link footer (between Showcase / Blueprint / Program) ── */
.cross-links {
  background: var(--mode-soft);
  border-radius: 12px;
  padding: 24px 28px;
  margin-top: 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  align-items: center;
}
.cross-links .cross-item {
  display: block;
  text-decoration: none;
  color: var(--text);
}
.cross-links .cross-item .lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--mode-dark);
  margin-bottom: 4px;
}
.cross-links .cross-item .val {
  font-size: 14px;
  font-weight: 700;
  color: var(--mode-dark);
}
.cross-links .cross-item:hover .val { text-decoration: underline; }

/* Placeholder highlight (Blueprint mode) */
body.mode-blueprint .placeholder,
.placeholder {
  background: rgba(184, 119, 13, 0.13);
  border-bottom: 1.5px dashed var(--mode-blueprint);
  padding: 0 4px;
  border-radius: 2px;
  font-style: italic;
  color: var(--mode-blueprint-dark);
}

/* ── Checklist ── */
.checklist { list-style: none; padding: 0; margin-bottom: 16px; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.checklist li:last-child { border-bottom: none; }
.checklist li::before {
  content: '☐';
  font-size: 16px;
  color: var(--mode);
  flex-shrink: 0;
  line-height: 1.4;
}

/* ── Site footer ── */
.site-footer {
  background: var(--brand-dark);
  color: rgba(255,255,255,0.75);
  padding: 28px 32px;
  font-size: 12px;
  line-height: 1.7;
}
.site-footer .ft-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.site-footer strong { color: rgba(255,255,255,0.9); font-weight: 700; }
.site-footer a { color: rgba(255,255,255,0.7); text-decoration: none; }
.site-footer a:hover { color: #fff; }
.site-footer .ft-links { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer .ft-links span { color: rgba(255,255,255,0.35); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .page-header { padding: 32px 24px 28px; }
  .container, .container-wide, .container-narrow { padding: 32px 20px 60px; }
  .site-footer .ft-grid { grid-template-columns: 1fr; text-align: center; }
  .site-footer .ft-links { justify-content: center; }
}
@media (max-width: 600px) {
  .page-header h1 { font-size: 1.6rem; }
  .page-header .stats { gap: 20px; }
}

/* ── Print ── */
@media print {
  .site-nav, .site-footer, .cross-links, .door-cta { display: none !important; }
  .page-header { background: #fff !important; color: var(--brand) !important; padding: 16px 24px; border-bottom: 2px solid var(--brand); }
  .page-header::after { display: none; }
  .page-header h1, .page-header .sub, .page-header .stat .n, .page-header .stat .l { color: var(--text) !important; }
  .breadcrumb { background: transparent; color: var(--mode) !important; padding: 0; margin-bottom: 8px; }
  body { font-size: 12px; }
  .container, .container-wide, .container-narrow { padding: 16px 24px; max-width: 100%; }
  a { text-decoration: none; color: var(--text); }
}


/* ---------------------------------------------------------------
   Small-screen safety net. Added after measuring real horizontal
   overflow at 390px across every page - wide tables, button rows that
   would not wrap, and fixed-width grids were pushing the document
   wider than the viewport. Scoped to <=700px so desktop is untouched.
   --------------------------------------------------------------- */
@media (max-width: 700px) {
  /* Wide tables scroll inside their own box instead of the page */
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Button and chip rows wrap rather than run off the edge */
  .filter-bar, .filter-btns, .country-selector, .tier-selector,
  .btn-row, .chip-row, .tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .filter-btn, .country-btn, .tier-btn { flex: 0 1 auto; }

  /* Fixed multi-column rows collapse to a single column */
  .input-group, .stat-row, .kv-row { grid-template-columns: 1fr !important; }

  /* Comparison rows keep their column structure - collapsing them makes a
     pre/post or before/after reading meaningless - so the row scrolls inside
     itself instead of widening the page. Covers dim-row, version-row,
     transfer-row and any other *-row grid. */
  [class$="-row"], [class*="-row "] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .dim-grid, .dims, .dimension-list { overflow-x: auto; }
  .dim-legend-row { overflow-x: auto; }

  /* Panels and cards must be allowed to shrink inside a grid/flex parent */
  .inputs-panel, .results-panel, .card, .case-card, .tool-card, .door, .tier {
    min-width: 0;
    max-width: 100%;
  }

  /* Long unbroken strings - URLs, scopes, identifiers - must not set the width */
  body { overflow-wrap: anywhere; }
  pre, code { white-space: pre-wrap; word-break: break-word; }
}

/* Document meta strip — Version / counts / Last updated, under a deliverable's
   title. The markup shipped on ten blueprint pages with no rule behind it, so
   every item stacked into its own line and the label sat above its value like a
   broken list. Found by looking at a rendered page rather than a diff. */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 32px;
  margin: 14px 0 4px;
}
.meta-row .meta-item { min-width: 0; }
.meta-row .lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 2px;
}
.meta-row .val { font-size: 15px; font-weight: 700; line-height: 1.25; }
