/*
 * Dikenocracy — Public Website
 * styles.css
 *
 * Design principles:
 *   - Dark, restrained, institutional
 *   - No glow, no neon, no cyberpunk decoration
 *   - Clean hierarchy, strong readability
 *   - Mobile-first responsive layout
 */

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */

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

:root {
  /* Color palette */
  --bg-deep:       #0B0B0B;
  --bg-panel:      #121212;
  --bg-card:       #16161e;
  --border:        #2a2a38;
  --accent:        #D4AF37;
  --accent-alt:    #e4bf47;
  --accent-dim:    rgba(212, 175, 55, 0.25);
  --text-primary:  #EAEAEA;
  --text-secondary:#888888;
  --text-muted:    #5a5a6a;
  --white:         #ffffff;

  /* Typography */
  --font-main:  'Georgia', 'Times New Roman', serif;
  --font-ui:    'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:  'Courier New', Courier, monospace;

  /* Spacing rhythm */
  --gap-xs:  0.5rem;
  --gap-sm:  1rem;
  --gap-md:  2rem;
  --gap-lg:  4rem;
  --gap-xl:  6rem;

  /* Transitions */
  --fade:  opacity 0.3s ease, visibility 0.3s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
  outline: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ─── Intro / Welcome Screens (index.html only) ─────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 8vh;
  transition: var(--fade);
  z-index: 10;
}

.screen--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Subtle dark overlay to preserve readability without obscuring the image */
.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

#intro-screen {
  background: #0A0A0A;
  z-index: 12;
  justify-content: center;
  align-items: center;
  padding-bottom: 0;
}

/* No overlay needed — solid background, no hero image */
#intro-screen::after {
  display: none;
}

#welcome-screen {
  background-color: #0B0B0B;
  background-image:
    linear-gradient(rgba(212, 175, 55, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 175, 55, 0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  z-index: 11;
}

/* Enter CTA (welcome screen) */
.enter-cta {
  position: relative;
  z-index: 20;
  text-align: center;
}

.enter-cta__btn {
  display: inline-block;
  padding: 0.85rem 2.4rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 8px;
  border: none;
  color: #111111;
  background: #D4AF37;
  cursor: pointer;
  transition: background 0.2s ease;
  text-decoration: none;
}

.enter-cta__btn:hover,
.enter-cta__btn:focus {
  background: #C09B28;
  color: #111111;
  text-decoration: none;
  outline: none;
}

.enter-cta__sub {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  opacity: 0.85;
}

/* Manifest text container (intro screen, Stage A) */
.manifest-container {
  position: relative;
  z-index: 20;
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 12px;
  background: rgba(11, 11, 11, 0.88);
  padding: 2.5rem 3rem;
  max-width: 560px;
  text-align: center;
}

.manifest-container__text {
  font-family: var(--font-main);
  font-size: 1.2rem;
  line-height: 1.85;
  color: #EAEAEA;
  letter-spacing: 0.025em;
}

/* Welcome overlay text (welcome screen, Stage B) */
.welcome-overlay {
  position: relative;
  z-index: 20;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.welcome-overlay__title {
  font-family: var(--font-main);
  font-size: 2.2rem;
  color: #EAEAEA;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.welcome-overlay__sub {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Interstitial protocol loading overlay */
#interstitial {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0B0B0B;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

#interstitial.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.interstitial__bar {
  width: 160px;
  height: 1px;
  background: rgba(212, 175, 55, 0.2);
  position: relative;
  overflow: hidden;
}

.interstitial__bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  height: 100%;
  width: 60%;
  background: var(--accent);
  animation: interstitial-scan 0.6s ease forwards;
}

@keyframes interstitial-scan {
  from { left: -60%; }
  to   { left: 140%; }
}

.interstitial__msg {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.75;
}

/* ─── Site Navigation ────────────────────────────────────────────────────────── */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--gap-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-nav__brand {
  font-family: var(--font-main);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  font-weight: normal;
}

.site-nav__brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav__links {
  list-style: none;
  display: flex;
  gap: var(--gap-md);
}

.site-nav__links a {
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.site-nav__links a:hover,
.site-nav__links a:focus,
.site-nav__links a[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
}

/* Hamburger for mobile */
.site-nav__toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}

.site-nav__toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

@media (max-width: 680px) {
  .site-nav__toggle {
    display: flex;
  }

  .site-nav__links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    gap: 0;
    padding: var(--gap-sm) 0;
  }

  .site-nav__links.is-open {
    display: flex;
  }

  .site-nav__links li a {
    display: block;
    padding: 0.75rem var(--gap-md);
  }
}

/* ─── Page Layout ───────────────────────────────────────────────────────────── */

.page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--gap-lg) var(--gap-md);
}

/* ─── Hero Section ──────────────────────────────────────────────────────────── */

.hero {
  padding: var(--gap-xl) 0 var(--gap-lg);
  text-align: center;
}

.hero__title {
  font-family: var(--font-main);
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: normal;
  letter-spacing: 0.04em;
  color: var(--white);
  line-height: 1.15;
  margin-bottom: var(--gap-sm);
}

.hero__sub {
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── Section ───────────────────────────────────────────────────────────────── */

.section {
  margin-bottom: var(--gap-lg);
}

.section__heading {
  font-family: var(--font-main);
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  font-weight: normal;
  color: var(--text-primary);
  margin-bottom: var(--gap-sm);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.section__text {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 680px;
  margin-bottom: var(--gap-sm);
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap-md);
  margin-top: var(--gap-md);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--gap-md);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.card__title {
  font-family: var(--font-main);
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: var(--gap-xs);
}

.card__label {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 2px 7px;
  margin-bottom: var(--gap-xs);
}

.card__label--placeholder {
  color: var(--text-muted);
  border-color: var(--border);
}

.card__text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ─── Entry Point Buttons (about page) ─────────────────────────────────────── */

.entry-points {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm);
  margin-top: var(--gap-md);
}

.btn {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn:hover,
.btn:focus {
  background: var(--accent);
  color: var(--bg-deep);
  text-decoration: none;
  outline: none;
}

.btn--secondary {
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn--secondary:hover,
.btn--secondary:focus {
  background: var(--border);
  color: var(--text-primary);
}

/* ─── Protocol Layer List ───────────────────────────────────────────────────── */

.protocol-layer {
  display: block;
  text-decoration: none;
  background: var(--bg-panel);
  border-left: 3px solid var(--accent-dim);
  border-radius: 0 4px 4px 0;
  padding: var(--gap-sm) var(--gap-md);
  margin-bottom: var(--gap-sm);
  transition: border-color 0.2s, background 0.2s;
}
.protocol-layer:hover,
.protocol-layer:focus-visible {
  border-left-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.protocol-layer__id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.protocol-layer__name {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.protocol-layer__desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* ─── Protocol Article (generated pages) ────────────────────────────────────── */

/* Protocol shell: 4-column grid on desktop
   Columns: [map 200] [toc 260] [button-gutter 72] [article flex]
   Column 3 is an empty gutter that gives the fixed-position prev
   side-nav button its own dedicated vertical strip. */
.protocol-shell {
  display: grid;
  grid-template-columns: 200px 260px 72px minmax(0, 1fr);
  column-gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--gap-md) var(--gap-md) var(--gap-lg);
}

/* Protocols index page (no TOC sidebar) — simpler 2-column grid */
.protocol-shell:not(:has(.protocol-toc)) {
  grid-template-columns: 200px minmax(0, 1fr);
}

/* ── Protocol TOC (left sidebar) ──────────────────────────────────────────── */

.protocol-toc {
  grid-column: 2;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding-top: var(--gap-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.protocol-toc__toggle {
  display: none; /* visible only on mobile */
}

.protocol-toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  border-left: 1px solid var(--border);
  padding-left: var(--gap-sm);
}

.protocol-toc__list li {
  margin-bottom: 0.35rem;
}

.protocol-toc__list li a {
  color: var(--text-secondary);
  display: block;
  padding: 2px 0;
  transition: color 0.15s;
}

.protocol-toc__list li a:hover,
.protocol-toc__list li a.toc-active {
  color: var(--accent);
  text-decoration: none;
}

.protocol-toc__list .toc__sub {
  padding-left: 0.75rem;
  font-size: 0.78rem;
}

/* ── Protocol Content (main column) ───────────────────────────────────────── */

.protocol-content {
  grid-column: 4;
  min-width: 0;
  max-width: 900px;
}

/* Protocols index (no TOC) — content in column 2 */
.protocol-shell:not(:has(.protocol-toc)) .protocol-content {
  grid-column: 2;
}

/* ── Protocol Toolbar ─────────────────────────────────────────────────────── */

.protocol-toolbar {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
  font-size: 0.85rem;
}

.protocol-toolbar a {
  color: var(--text-secondary);
  transition: color 0.15s;
}

.protocol-toolbar a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ── Protocol Article Typography ──────────────────────────────────────────── */

.protocol-article {
  line-height: 1.75;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.protocol-article h1 {
  font-family: var(--font-main);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: normal;
  color: var(--white);
  letter-spacing: 0.02em;
  margin-bottom: var(--gap-xs);
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--border);
}

.protocol-meta {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  margin-bottom: 1.5em;
}

.protocol-article h2 {
  font-family: var(--font-main);
  font-size: 1.3rem;
  font-weight: normal;
  color: var(--text-primary);
  margin-top: 2em;
  margin-bottom: 0.6em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border);
}

.protocol-article h3 {
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.6em;
  margin-bottom: 0.5em;
}

.protocol-article h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 1.3em;
  margin-bottom: 0.4em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.protocol-article p {
  margin-bottom: 0.85em;
  max-width: 70ch;
}

.protocol-article ul,
.protocol-article ol {
  padding-left: 1.5em;
  margin-bottom: 1em;
}

.protocol-article li {
  margin-bottom: 0.4em;
}

.protocol-article li + li {
  margin-top: 0.2em;
}

.protocol-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.protocol-article blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: 0.6em 1.2em;
  margin: 1.2em 0;
  color: var(--text-secondary);
  background: rgba(212, 175, 55, 0.05);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}

.protocol-article pre {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1em;
  overflow-x: auto;
  font-size: 0.85rem;
  margin-bottom: 1em;
  line-height: 1.5;
}

.protocol-article code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-panel);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.protocol-article strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Protocol Tables ───────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin: 1.2em 0;
  -webkit-overflow-scrolling: touch;
}

.protocol-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 400px;
}

.protocol-table th,
.protocol-table td {
  border: 1px solid var(--border);
  padding: 0.55em 0.85em;
  text-align: left;
}

.protocol-table th {
  background: var(--bg-panel);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.protocol-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* ─── Fixed Side Protocol Navigation (prev / next) ─────────────────────────── */

/* Shared fixed-position overlay that acts as the single containing block
   for both side-nav buttons.  Both children use position: absolute and
   the same top: 50% + translateY(-50%) rule, guaranteeing identical
   vertical centers regardless of individual button height. */
.protocol-side-nav-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;          /* pass clicks through to page */
}

.protocol-side-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;          /* re-enable clicks on buttons */
}

/* Center prev button in the dedicated 72 px gutter column (grid col 3).
   From viewport left: shell-margin + shell-padding(2rem)
     + map(200) + gap(24) + toc(260) + gap(24) + half-gutter(36) = +544 px.
   translate(-50%) horizontally centers the button on that point. */
.protocol-side-nav--prev {
  left: calc(max(2rem, (100vw - 1600px) / 2 + 2rem) + 544px);
  transform: translate(-50%, -50%);
}
.protocol-side-nav--next {
  right: max(0px, calc((100vw - 1600px) / 2));
}

.protocol-side-nav__btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.65rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: rgba(17, 17, 23, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  max-height: 220px;
  overflow: hidden;
}

.protocol-side-nav--prev .protocol-side-nav__btn {
  border-radius: 0 4px 4px 0;
  border-left: none;
}

.protocol-side-nav--next .protocol-side-nav__btn {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.protocol-side-nav__btn:hover,
.protocol-side-nav__btn:focus {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(17, 17, 23, 0.95);
  text-decoration: none;
  outline: none;
}

.protocol-side-nav__btn .nav-arrow {
  font-size: 1rem;
  line-height: 1;
  writing-mode: horizontal-tb;
}

.protocol-side-nav__btn .nav-label {
  white-space: nowrap;
}

.protocol-side-nav__disabled {
  display: none;
}

/* Bottom inline fallback nav (always present for in-flow context) */
.protocol-nav-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-md);
  margin-top: var(--gap-lg);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--border);
}

.protocol-nav-bottom .btn {
  font-size: 0.78rem;
  padding: 0.5rem 1rem;
}

.protocol-nav-bottom__spacer {
  flex: 1;
}

/* ─── Global Protocol Map (left sidebar) ────────────────────────────────────── */

.protocol-map {
  grid-column: 1;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding-top: var(--gap-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.protocol-map__heading {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.protocol-map__layer {
  margin-bottom: 0.6rem;
}

.protocol-map__layer-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  cursor: default;
}

.protocol-map__layer-label--active {
  color: var(--accent);
}

.protocol-map__links {
  list-style: none;
  padding: 0;
  margin: 0 0 0 0.5rem;
  border-left: 1px solid var(--border);
}

.protocol-map__links li {
  margin: 0;
}

.protocol-map__links a {
  display: block;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.protocol-map__links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.protocol-map__links a.pmap-active {
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  margin-left: -1px;
}

/* ─── Protocol In-page TOC heading ──────────────────────────────────────────── */

.protocol-toc__heading {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ─── Protocol page mobile ──────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .protocol-map {
    display: none;
  }

  /* 3-column grid: toc | gutter | content */
  .protocol-shell {
    grid-template-columns: 260px 72px minmax(0, 1fr);
  }
  .protocol-toc    { grid-column: 1; }
  .protocol-content { grid-column: 3; }

  /* Center in gutter: padding(2rem) + toc(260) + gap(24) + half-gutter(36) */
  .protocol-side-nav--prev {
    left: calc(2rem + 320px);
  }
  .protocol-side-nav--next { right: 0; }
}

@media (max-width: 900px) {
  .protocol-shell {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .protocol-toc {
    position: relative;
    top: 0;
    flex: none;
    max-height: none;
    overflow: visible;
    margin-bottom: var(--gap-md);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-panel);
    padding: 0;
  }

  .protocol-toc__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: var(--font-ui);
    padding: 0.75rem 1rem;
    cursor: pointer;
  }

  .protocol-toc__toggle svg {
    transition: transform 0.2s;
  }

  .protocol-toc__toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  .protocol-toc #toc-list {
    display: none;
    padding: 0 1rem 0.75rem;
  }

  .protocol-toc #toc-list.is-open {
    display: block;
  }

  .protocol-toc__list {
    border-left: none;
    padding-left: 0;
  }

  .protocol-content {
    grid-column: unset;
    max-width: 100%;
  }

  /* Side nav → bottom sticky bar on mobile */
  .protocol-side-nav-layer {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
  }

  .protocol-side-nav {
    position: static;
    transform: none;
    pointer-events: auto;
  }

  .protocol-side-nav__btn {
    writing-mode: horizontal-tb;
    padding: 0.55rem 0.75rem;
    font-size: 0.7rem;
    max-height: none;
    border-radius: 4px 4px 0 0;
  }

  .protocol-side-nav--prev .protocol-side-nav__btn {
    border-radius: 0 4px 0 0;
    border-left: none;
    border-bottom: none;
  }

  .protocol-side-nav--next .protocol-side-nav__btn {
    border-radius: 4px 0 0 0;
    border-right: none;
    border-bottom: none;
  }

  .protocol-side-nav__btn .nav-label {
    display: none;
  }
}

/* ─── Converter Page ────────────────────────────────────────────────────────── */

.converter-frame-wrap {
  margin-top: var(--gap-md);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-panel);
}

.converter-frame-wrap iframe {
  width: 100%;
  height: 680px;
  border: none;
  display: block;
}

.converter-launch {
  margin-top: var(--gap-md);
  padding: var(--gap-md);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  flex-wrap: wrap;
}

.converter-launch__text {
  flex: 1;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* ─── Info Note ─────────────────────────────────────────────────────────────── */

.info-note {
  margin-top: var(--gap-md);
  padding: 0.75rem var(--gap-sm);
  border-left: 3px solid var(--accent-alt);
  background: rgba(240, 169, 64, 0.06);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--gap-md);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--gap-xl);
}

/* ─── Divider ────────────────────────────────────────────────────────────────── */

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

/* ─── Utility: visually-hidden (accessibility) ───────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ─── Skip to content link ───────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--accent);
  color: var(--bg-deep);
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  z-index: 200;
  border-radius: 0 0 4px 0;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
  text-decoration: none;
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

/* ─── Index page (splash): hide overflow ─────────────────────────────────────── */

.page-index {
  overflow: hidden;
}

/* ─── Print ──────────────────────────────────────────────────────────────────── */

@media print {
  .site-nav, .site-footer, .skip-link, .enter-btn { display: none; }
  body { background: #fff; color: #111; }
  .protocol-article { line-height: 1.5; }
  .protocol-table th { background: #eee; color: #111; }
  a { color: #111; text-decoration: underline; }
  a::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #666; }
}
