/* ─── TOKENS ─────────────────────────────────────────────────── */
:root {
  --accent:      #1a6b72;
  --accent-mid:  #1f8a92;
  --accent-pale: #e8f4f5;
  --ink:         #1a1a1a;
  --ink-mid:     #444444;
  --ink-muted:   #7a7a7a;
  --bg:          #faf9f7;
  --bg-card:     #ffffff;
  --bg-sidebar:  #f5f3f0;
  --border:      #e8e4df;
  --border-mid:  #d4cfc8;
  --warning-bg:  #fff9ee;
  --warning-bdr: #f0c060;
  --tip-bg:      #eef7f8;
  --tip-bdr:     #1a6b72;
  --danger-bg:   #fff1f1;
  --danger-bdr:  #e05555;

  --font-body: 'Lora', Georgia, 'Times New Roman', serif;
  --font-ui:   'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --radius:    6px;
  --radius-lg: 12px;
  --sidebar-w: 260px;
  --content-w: 740px;
}

/* ─── RESET & BASE ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 17px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── LAYOUT ─────────────────────────────────────────────────── */
.site-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 2rem 0 3rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.sidebar-brand {
  padding: 0 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.sidebar-brand .brand-tag {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.sidebar-brand .brand-title {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.nav-section-label {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 1.2rem 1.5rem 0.4rem;
}
.nav-list { list-style: none; }
.nav-list a {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--ink-mid);
  text-decoration: none;
  padding: 0.45rem 1.5rem;
  border-left: 2px solid transparent;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
  line-height: 1.4;
}
.nav-list a:hover {
  color: var(--accent);
  background: rgba(26, 107, 114, 0.06);
}
.nav-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(26, 107, 114, 0.08);
  font-weight: 600;
}
.nav-sub a {
  padding-left: 2.2rem;
  font-size: 0.78rem;
}

/* ─── MAIN CONTENT ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 0 2.5rem 5rem;
}

/* ─── HERO ───────────────────────────────────────────────────── */
.hero {
  padding: 4.5rem 0 3.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4rem;
  max-width: var(--content-w);
}
.hero-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.hero h1 {
  font-family: var(--font-body);
  font-size: clamp(2rem, 4vw, 2.9rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 1.1rem;
  letter-spacing: -0.01em;
}
.hero-sub {
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink-mid);
  max-width: 560px;
  line-height: 1.65;
}
.hero-meta {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.hero-meta-item {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}
.hero-meta-item strong {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-mid);
  font-weight: 600;
}

/* ─── SECTIONS ───────────────────────────────────────────────── */
.content-section {
  max-width: var(--content-w);
  margin-bottom: 5rem;
  padding-top: 1rem;
}
.section-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.section-num {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}
.content-section h2 {
  font-family: var(--font-body);
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────────── */
.prose h3 {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin: 2.2rem 0 0.7rem;
  letter-spacing: -0.01em;
}
.prose h4 {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 1.8rem 0 0.5rem;
}
.prose p {
  margin: 0.9rem 0;
  color: var(--ink-mid);
}
.prose p:first-child { margin-top: 0; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; }
.prose ul, .prose ol {
  margin: 0.9rem 0 0.9rem 1.4rem;
  color: var(--ink-mid);
}
.prose li { margin: 0.3rem 0; }
.prose li::marker { color: var(--accent); }
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(26, 107, 114, 0.4);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}
.prose a:hover { text-decoration-color: var(--accent); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: rgba(26, 107, 114, 0.08);
  color: var(--accent);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* ─── BLOCKQUOTE ─────────────────────────────────────────────── */
.prose blockquote {
  margin: 1.8rem 0;
  padding: 1.1rem 1.4rem;
  background: var(--accent-pale);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p {
  color: var(--ink);
  font-style: italic;
  font-size: 1.02rem;
  margin: 0;
}
.prose blockquote strong { color: var(--accent); }

/* callout variants */
.callout {
  margin: 1.8rem 0;
  padding: 1.1rem 1.4rem;
  border-radius: var(--radius);
  border-left: 3px solid;
}
.callout-tip { background: var(--tip-bg); border-color: var(--tip-bdr); }
.callout-warning { background: var(--warning-bg); border-color: var(--warning-bdr); }
.callout-danger { background: var(--danger-bg); border-color: var(--danger-bdr); }
.callout p { margin: 0; color: var(--ink-mid); font-size: 0.93rem; }
.callout strong { color: var(--ink); }
.callout-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.callout-tip .callout-label { color: var(--accent); }
.callout-warning .callout-label { color: #b08020; }
.callout-danger .callout-label { color: #c04040; }

/* ─── TABLES ─────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1.8rem 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.83rem;
  min-width: 480px;
}
thead th {
  background: var(--bg-sidebar);
  color: var(--ink);
  font-weight: 700;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-mid);
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: rgba(26, 107, 114, 0.02); }
tbody td {
  padding: 0.65rem 1rem;
  color: var(--ink-mid);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
tbody tr:last-child td { border-bottom: none; }
tbody td strong { color: var(--ink); }

/* ─── SPRINT CARDS ───────────────────────────────────────────── */
.sprint-grid {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}
.sprint-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.5rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.sprint-card:hover {
  border-color: var(--accent-mid);
  box-shadow: 0 2px 16px rgba(26, 107, 114, 0.09);
}
.sprint-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.7rem;
}
.sprint-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 0.1rem;
}
.sprint-card-title {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.sprint-card-body {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--ink-mid);
  line-height: 1.6;
}
.sprint-card-output {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.25rem 0.65rem;
  background: var(--accent-pale);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 50px;
}

/* ─── COMPASS RULES ──────────────────────────────────────────── */
.compass-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.compass-item {
  display: flex;
  gap: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.compass-num {
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  width: 1.4rem;
  line-height: 1.6;
}
.compass-text {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--ink-mid);
  line-height: 1.5;
}

/* ─── METRICS ROW ────────────────────────────────────────────── */
.metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.4rem 0;
}
.metric-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-mid);
}
.metric-chip strong {
  display: block;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.15rem;
}

/* ─── SOURCES ────────────────────────────────────────────────── */
.sources {
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.sources-label {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
}
.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
}
.sources-list a {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-decoration: underline;
  text-decoration-color: var(--border-mid);
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.sources-list a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ─── SECTION DIVIDER ────────────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 0 0 5rem;
  max-width: var(--content-w);
}

/* ─── MOBILE HEADER ──────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.2rem;
  align-items: center;
  justify-content: space-between;
}
.mobile-brand {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}
.mobile-menu-btn {
  background: none;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-mid);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.mobile-menu-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── DRAWER ─────────────────────────────────────────────────── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.22s;
}
.drawer-overlay.open { display: block; opacity: 1; }
.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  z-index: 210;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 1.5rem 0 3rem;
}
.drawer.open { transform: translateX(0); }
.drawer-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--ink-muted);
  cursor: pointer;
  line-height: 1;
}

/* ─── BACK-TO-TOP ────────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.back-to-top.visible { opacity: 1; transform: translateY(0); }

/* ─── READING PROGRESS ───────────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 300;
  width: 0%;
  transition: width 0.1s linear;
}

/* ─── MISC ───────────────────────────────────────────────────── */
hr.prose-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ─── PART HEADING (programme A/B divider) ───────────────────── */
.prose h3.part-heading {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  border-top: 1px solid var(--border);
  padding-top: 1.6rem;
  margin-top: 2.4rem;
  margin-bottom: 1.2rem;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .main-content { padding: 0 1.2rem 4rem; }
  .hero { padding: 2.5rem 0 2rem; }
  .compass-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  html { font-size: 16px; }
  .main-content { padding: 0 1rem 4rem; }
  .metrics-row { gap: 0.5rem; }
  .metric-chip { width: 100%; }
}
