/* ============================================
   NIS2-guiden — design tokens & base styles
   ============================================ */

:root {
  /* Palette: warm cream + deep green + sage (default) */
  --bg: #f0eee8;
  --bg-elev: #f6f4ef;
  --bg-card: #ffffff;
  --ink: #14201b;
  --ink-soft: #3a463f;
  --ink-mute: #6b756e;
  --line: #d9d4c7;
  --line-soft: #e6e1d4;
  --brand: #0f4d3a;
  --brand-deep: #0a3528;
  --brand-soft: #a8c5b0;
  --brand-tint: #dbe6dd;
  --accent: #b8612f;          /* warm terracotta for warnings */
  --accent-soft: #f1d7c4;
  --good: #2f7a52;
  --warn: #a85a1a;
  --crit: #8a2b1f;
  --focus: #0a3528;

  /* Type */
  --f-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-sans: "Geist", "Söhne", "Inter Tight", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;

  /* Layout */
  --container: 1200px;
  --container-wide: 1320px;
  --container-narrow: 880px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 18px;

  --gutter: clamp(16px, 3vw, 32px);

  /* Motion */
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* Theme: navy */
[data-palette="navy"] {
  --bg: #f5f3ee;
  --bg-elev: #fbf9f4;
  --bg-card: #ffffff;
  --ink: #0e1730;
  --ink-soft: #2a3554;
  --ink-mute: #5e6884;
  --line: #d6d2c4;
  --line-soft: #e6e1d4;
  --brand: #1f2a5a;
  --brand-deep: #0e1730;
  --brand-soft: #b6bedc;
  --brand-tint: #dde0ee;
  --accent: #b8612f;
  --accent-soft: #f1d7c4;
  --focus: #0e1730;
}

/* Theme: editorial dark */
[data-palette="dark"] {
  --bg: #111210;
  --bg-elev: #181a17;
  --bg-card: #1c1f1b;
  --ink: #f3f1ea;
  --ink-soft: #cfcbbe;
  --ink-mute: #8a8678;
  --line: #2c2f2a;
  --line-soft: #232622;
  --brand: #c1ff4d;
  --brand-deep: #a8e02f;
  --brand-soft: #4a5a2e;
  --brand-tint: #232a17;
  --accent: #e8a566;
  --accent-soft: #3a2a18;
  --focus: #c1ff4d;
}

/* ---------- reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; }
p { margin: 0 0 1em; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-family: var(--f-display); font-weight: 500; letter-spacing: -0.01em; line-height: 1.1; text-wrap: balance; }
h1 { font-size: clamp(40px, 5.5vw, 76px); }
h2 { font-size: clamp(28px, 3.4vw, 44px); }
h3 { font-size: clamp(20px, 2vw, 26px); }
h4 { font-size: 18px; font-family: var(--f-sans); font-weight: 600; letter-spacing: 0; }
small { font-size: 13px; color: var(--ink-mute); }

/* ---------- focus ring (WCAG) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  z-index: 200;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-inline: var(--gutter);
}
.container-wide { max-width: var(--container-wide); }
.container-narrow { max-width: var(--container-narrow); }

/* ---------- top utility bar ---------- */
.utility-bar {
  background: var(--brand-deep);
  color: #e8efe9;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
[data-palette="dark"] .utility-bar { background: #000; }
.utility-bar .row {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 36px; gap: 16px; flex-wrap: wrap;
}
.utility-bar a, .utility-bar button {
  color: inherit; background: transparent; border: 0; cursor: pointer;
  padding: 6px 8px; text-decoration: none;
}
.utility-bar a:hover, .utility-bar button:hover { text-decoration: underline; }
.util-group { display: flex; align-items: center; gap: 4px; }

/* ---------- header / nav ---------- */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(140%) blur(8px);
}
.site-header .row {
  display: flex; align-items: center; gap: 24px;
  min-height: 76px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--ink);
  font-family: var(--f-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-mark {
  width: 36px; height: 36px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--f-mono);
  font-size: 13px; font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0;
}
.brand em { font-style: italic; color: var(--brand); font-weight: 500; }

.primary-nav {
  display: flex; gap: 2px; margin-left: auto; align-items: center;
}
.primary-nav a {
  text-decoration: none; color: var(--ink-soft);
  padding: 10px 12px;
  font-size: 15px; font-weight: 500;
  border-radius: 6px;
  position: relative;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.primary-nav a:hover { color: var(--ink); background: var(--bg-elev); }
.primary-nav a.active {
  color: var(--brand);
}
.primary-nav a.active::after {
  content: ""; position: absolute;
  left: 12px; right: 12px; bottom: 2px;
  height: 2px; background: var(--brand);
}
.mobile-nav-toggle {
  display: none; margin-left: auto;
  background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 10px 14px;
  cursor: pointer; font-weight: 500;
}

@media (max-width: 1100px) {
  .primary-nav { display: none; }
  .mobile-nav-toggle { display: inline-flex; align-items: center; gap: 8px; }
  .primary-nav.open {
    display: flex; flex-direction: column;
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 12px var(--gutter); gap: 4px;
  }
  .primary-nav.open a { padding: 14px 12px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500; font-size: 15px;
  text-decoration: none; cursor: pointer;
  background: transparent; color: var(--ink);
  transition: transform .15s var(--ease), background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); color: #fff; }
[data-palette="dark"] .btn-primary { color: #111; }
[data-palette="dark"] .btn-primary:hover { color: #111; }
.btn-outline { border-color: var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--bg); }
.btn-ghost { color: var(--ink); }
.btn-ghost:hover { background: var(--bg-elev); }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn-lg { padding: 16px 28px; font-size: 16px; }
.btn[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.card-flat {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
}
[data-palette="dark"] .card { background: var(--bg-card); }

/* ---------- eyebrow / kicker ---------- */
.kicker {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand);
  display: inline-flex; align-items: center; gap: 8px;
}
.kicker::before {
  content: ""; width: 18px; height: 1px; background: var(--brand);
}
.kicker.no-line::before { display: none; }

/* ---------- meta row / divider ---------- */
.meta-row {
  display: flex; flex-wrap: wrap; gap: 18px;
  font-family: var(--f-mono); font-size: 12px;
  color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: .1em;
}
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 48px 0; }

/* ---------- chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-deep);
  font-size: 12px; font-weight: 500;
  font-family: var(--f-mono);
  letter-spacing: .04em;
}
[data-palette="dark"] .chip { color: var(--brand); }
.chip-outline { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.chip-warn { background: var(--accent-soft); color: var(--accent); }

/* ---------- form ---------- */
.field { display: block; margin-bottom: 18px; }
.field label, .field-label {
  display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px;
}
.field .hint { font-size: 13px; color: var(--ink-mute); margin-top: 4px; }
.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
  outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.field-error {
  color: var(--crit); font-size: 13px; margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
}
.radio-row, .check-row {
  display: flex; flex-direction: column; gap: 8px;
}
.radio-row label, .check-row label {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg-card);
  transition: border-color .15s, background .15s;
}
.radio-row label:hover, .check-row label:hover { border-color: var(--brand); }
.radio-row input, .check-row input { margin-top: 3px; accent-color: var(--brand); }
.radio-row label.selected, .check-row label.selected {
  border-color: var(--brand);
  background: var(--brand-tint);
}

/* ---------- accordion ---------- */
.accordion-item {
  border-top: 1px solid var(--line);
}
.accordion-item:last-child { border-bottom: 1px solid var(--line); }
.accordion-trigger {
  width: 100%; text-align: left;
  background: transparent; border: 0; cursor: pointer;
  padding: 22px 0; display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
  font-family: var(--f-display); font-size: 20px; font-weight: 500;
  color: var(--ink);
}
.accordion-trigger .plus {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); flex-shrink: 0;
  display: grid; place-items: center;
  transition: transform .3s var(--ease), background .15s;
  font-family: var(--f-sans); font-size: 18px; line-height: 1;
}
.accordion-item[data-open="true"] .accordion-trigger .plus {
  transform: rotate(45deg); background: var(--brand); color: #fff; border-color: var(--brand);
}
.accordion-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height .35s var(--ease);
}
.accordion-item[data-open="true"] .accordion-panel { max-height: 600px; }
.accordion-panel-inner { padding-bottom: 22px; color: var(--ink-soft); max-width: 70ch; }

/* ---------- placeholder / image slot ---------- */
.placeholder {
  background:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,.035) 8px 9px),
    var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand-deep);
  font-family: var(--f-mono); font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase;
  min-height: 160px;
  text-align: center; padding: 16px;
}
[data-palette="dark"] .placeholder { color: var(--brand); }

/* ---------- footer ---------- */
.site-footer {
  background: var(--brand-deep);
  color: #d8e3da;
  margin-top: 96px;
  padding: 64px 0 32px;
}
[data-palette="dark"] .site-footer { background: #000; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 40px;
}
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-grid h4 {
  font-family: var(--f-mono); font-size: 12px;
  font-weight: 500; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.6); margin-bottom: 16px;
}
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-bottom {
  margin-top: 56px; padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: rgba(255,255,255,.55);
}

/* ---------- hero (shared) ---------- */
.hero {
  padding: 80px 0 64px;
  border-bottom: 1px solid var(--line);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 56px;
  align-items: start;
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero { padding: 56px 0 40px; }
}
.hero h1 { margin-bottom: 24px; }
.hero h1 em { font-style: italic; color: var(--brand); }
.hero-lead {
  font-size: clamp(17px, 1.4vw, 19px);
  color: var(--ink-soft);
  max-width: 52ch;
}
.hero-meta {
  display: flex; gap: 24px; margin-top: 28px;
  font-family: var(--f-mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-mute);
  flex-wrap: wrap;
}

/* ---------- section ---------- */
.section { padding: 80px 0; }
.section-sm { padding: 56px 0; }
.section-title {
  display: flex; justify-content: space-between; align-items: end;
  gap: 24px; margin-bottom: 40px; flex-wrap: wrap;
}
.section-title .kicker { margin-bottom: 12px; }

/* ---------- grid helpers ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- callout ---------- */
.callout {
  background: var(--brand-tint);
  border-left: 0;
  border: 1px solid var(--brand-soft);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex; gap: 18px; align-items: flex-start;
}
.callout-warn { background: var(--accent-soft); border-color: #e9c4a8; color: var(--accent); }
.callout .icon { flex-shrink: 0; font-family: var(--f-mono); font-weight: 600; font-size: 12px;
  background: var(--brand); color: #fff; padding: 4px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .08em;
}
.callout-warn .icon { background: var(--accent); color: #fff; }

/* ---------- step indicators ---------- */
.steps {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px; overflow-x: auto;
}
.step {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-elev); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--f-mono); font-size: 13px; font-weight: 500;
}
.step.active .step-num { background: var(--brand); color: #fff; border-color: var(--brand); }
.step.done .step-num { background: var(--brand-soft); color: var(--brand-deep); border-color: var(--brand-soft); }
.step-label { font-size: 14px; color: var(--ink-soft); }
.step.active .step-label { color: var(--ink); font-weight: 500; }
.step-bar { width: 32px; height: 1px; background: var(--line); }

/* ---------- timeline ---------- */
.timeline {
  display: grid; gap: 0;
  position: relative;
}
.timeline-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 32px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  align-items: start;
}
.timeline-row:last-child { border-bottom: 1px solid var(--line); }
.timeline-time {
  font-family: var(--f-mono); font-size: 13px;
  color: var(--brand); font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em;
}
.timeline-content h4 { margin-bottom: 4px; }
.timeline-content p { margin: 0; color: var(--ink-soft); }
@media (max-width: 700px) {
  .timeline-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- stat row ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat {
  padding: 28px 24px;
  border-right: 1px solid var(--line);
}
.stat:last-child { border-right: 0; }
.stat-num {
  font-family: var(--f-display);
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1;
  margin-bottom: 10px;
  color: var(--brand);
  font-weight: 400;
  letter-spacing: -0.02em;
}
.stat-label { font-size: 14px; color: var(--ink-soft); max-width: 28ch; }
@media (max-width: 800px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(1), .stat:nth-child(2) { border-bottom: 1px solid var(--line); }
}

/* ---------- toc / sidebar ---------- */
.layout-sidebar {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 64px;
  align-items: start;
}
.toc {
  position: sticky; top: 100px;
  font-size: 14px;
  border-left: 1px solid var(--line);
  padding-left: 20px;
}
.toc h4 {
  font-family: var(--f-mono); font-size: 11px;
  font-weight: 500; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-mute); margin-bottom: 14px;
}
.toc a {
  display: block; padding: 6px 0;
  text-decoration: none; color: var(--ink-soft);
  border-left: 2px solid transparent; margin-left: -22px; padding-left: 20px;
  transition: color .15s, border-color .15s;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 500; }
@media (max-width: 1000px) {
  .layout-sidebar { grid-template-columns: 1fr; gap: 32px; }
  .toc { position: static; }
}

/* ---------- table ---------- */
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 15px;
}
.data-table th, .data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table th {
  font-family: var(--f-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-mute); font-weight: 500;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.data-table tr:hover td { background: var(--bg-elev); }

/* ---------- prose ---------- */
.prose { max-width: 68ch; font-size: 17px; line-height: 1.65; color: var(--ink-soft); }
.prose h2 { margin-top: 48px; color: var(--ink); }
.prose h3 { margin-top: 36px; color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--ink); }

/* ---------- visually-hidden (sr-only) ---------- */
.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;
}

/* ---------- transitions ---------- */
.page-enter {
  animation: pageIn .35s var(--ease);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- TINY UTILITIES ---------- */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mt-5 { margin-top: 48px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.text-mute { color: var(--ink-mute); }
.text-soft { color: var(--ink-soft); }
.text-brand { color: var(--brand); }
.text-center { text-align: center; }
.font-mono { font-family: var(--f-mono); }
.flex-wrap { flex-wrap: wrap; }
.full-width { width: 100%; }
