/* Display controls + compact menu */
:root {
  --accent-ink: #171816;
  --glyph-solid: #171816;
  --glyph-stroke: rgba(23,24,22,.42);
  --glyph-muted: rgba(23,24,22,.28);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 20;
}
.display-control,
.display-menu-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font: 750 .74rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: .04em;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.display-control:active,
.display-menu-button:active { transform: scale(.94); }
.display-control-theme { font-size: 1rem; letter-spacing: 0; }
.display-control-separator { color: var(--muted); opacity: .55; }
.display-menu-wrap { position: relative; }
.display-menu-icon {
  width: 16px;
  height: 11px;
  position: relative;
  display: block;
  border-top: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
}
.display-menu-icon::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1.6px solid currentColor;
  transform: translateY(-50%);
}
.display-menu-popover {
  position: absolute;
  right: -6px;
  top: calc(100% + 1px);
  width: min(124px, calc(100vw - 28px));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--paper) 26%, transparent);
  box-shadow: 0 18px 52px rgba(15,16,13,.20);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.display-menu-popover[hidden] { display: none; }
.display-menu-nav {
  display: grid;
  gap: 1px;
  text-align: center;
}
.display-menu-link {
  display: block;
  padding: 9px 8px;
  border-radius: 10px;
  text-decoration: none;
  text-align: center;
}
.display-menu-link strong {
  display: block;
  font-size: .88rem;
  text-align: center;
  white-space: nowrap;
}
.display-menu-link span { display: none; }

@media (hover: hover) and (pointer: fine) {
  .display-control:hover,
  .display-menu-button:hover { color: var(--ink); background: rgba(255,255,255,.55); }
  .display-menu-link:hover { background: var(--accent-soft); }
}

/* Keep accent badges readable in every theme. */
.route-step,
.workflow-strip span,
.principle-index {
  color: var(--accent-ink);
  text-shadow: none;
  font-weight: 900;
}

/* Glyph contrast contract. Pseudo-elements in styles.css originally used fixed dark RGBA values,
   which disappeared in dark mode. Override them with theme-aware tokens. */
.glyph.board::before { border-color: var(--glyph-stroke); }
.glyph.board::after {
  background: var(--glyph-stroke);
  box-shadow: 0 -10px 0 var(--glyph-stroke), 0 10px 0 var(--glyph-stroke);
}
.glyph.flow::before {
  background: var(--glyph-solid);
  box-shadow: 26px 16px 0 var(--accent), 6px 34px 0 var(--glyph-muted);
}
.glyph.flow::after {
  border-right-color: var(--glyph-stroke);
  border-bottom-color: var(--glyph-stroke);
}

/* Human-aware AI glyph: replace the clipped shield-like mark with a stable orbital symbol. */
.glyph.trust::before {
  inset: auto;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--glyph-stroke);
  border-radius: 50%;
  box-shadow: none;
}
.glyph.trust::after {
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  clip-path: none;
  background: var(--accent);
  box-shadow: -18px 0 0 var(--glyph-solid), 18px 0 0 var(--glyph-solid);
}

/* Theme contract: system → light → dark, persisted by script.js */
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #11120f;
  --ink: #f1eee5;
  --muted: #bbb8af;
  --line: rgba(241,238,229,.16);
  --accent: #ffd84d;
  --accent-soft: rgba(255,216,77,.12);
  --panel: rgba(255,255,255,.05);
  --shadow: 0 18px 60px rgba(0,0,0,.24);
  --glyph-solid: #f1eee5;
  --glyph-stroke: rgba(241,238,229,.62);
  --glyph-muted: rgba(241,238,229,.34);
}
:root[data-theme='dark'] body {
  background:
    radial-gradient(circle at 82% 9%, rgba(255,216,77,.065), transparent 24rem),
    radial-gradient(circle at 12% 82%, rgba(255,216,77,.035), transparent 20rem),
    linear-gradient(var(--paper), var(--paper));
}
:root[data-theme='dark'] body::before {
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
}
:root[data-theme='dark'] .hero-copy { color: #d4d1c9; }
:root[data-theme='dark'] .system-map {
  background:
    radial-gradient(circle at center, rgba(255,216,77,.06), transparent 38%),
    linear-gradient(rgba(255,255,255,.025), rgba(255,255,255,.025));
}
:root[data-theme='dark'] .hero-kicker,
:root[data-theme='dark'] .hero-tags li,
:root[data-theme='dark'] .tag-list li,
:root[data-theme='dark'] .signal-pills li,
:root[data-theme='dark'] .panel-card,
:root[data-theme='dark'] .focus-card,
:root[data-theme='dark'] .route-card,
:root[data-theme='dark'] .principle-card,
:root[data-theme='dark'] .workflow-strip article,
:root[data-theme='dark'] .human-band,
:root[data-theme='dark'] .map-node {
  background-color: rgba(255,255,255,.05);
}
:root[data-theme='dark'] .map-node.center {
  color: var(--accent-ink) !important;
  background: var(--accent) !important;
  border-color: rgba(23,24,22,.2);
  text-shadow: none;
}
:root[data-theme='dark'] .button.primary { background: #f1eee5; color: #171816; }
:root[data-theme='dark'] .display-menu-popover { background: rgba(17,18,15,.26); box-shadow: 0 20px 58px rgba(0,0,0,.40); }
:root[data-theme='dark'] .glyph {
  background: linear-gradient(135deg, rgba(255,216,77,.12), rgba(255,255,255,.045));
  border-color: rgba(241,238,229,.12);
}
:root[data-theme='dark'] .map-node:not(.center):hover,
:root[data-theme='dark'] .map-node:not(.center):focus-visible { background: rgba(255,255,255,.09) !important; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #11120f;
    --ink: #f1eee5;
    --muted: #bbb8af;
    --line: rgba(241,238,229,.16);
    --accent: #ffd84d;
    --accent-soft: rgba(255,216,77,.12);
    --panel: rgba(255,255,255,.05);
    --shadow: 0 18px 60px rgba(0,0,0,.24);
    --glyph-solid: #f1eee5;
    --glyph-stroke: rgba(241,238,229,.62);
    --glyph-muted: rgba(241,238,229,.34);
  }
  :root:not([data-theme]) body {
    background:
      radial-gradient(circle at 82% 9%, rgba(255,216,77,.065), transparent 24rem),
      radial-gradient(circle at 12% 82%, rgba(255,216,77,.035), transparent 20rem),
      linear-gradient(var(--paper), var(--paper));
  }
  :root:not([data-theme]) body::before {
    background-image:
      linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  }
  :root:not([data-theme]) .hero-copy { color: #d4d1c9; }
  :root:not([data-theme]) .system-map {
    background:
      radial-gradient(circle at center, rgba(255,216,77,.06), transparent 38%),
      linear-gradient(rgba(255,255,255,.025), rgba(255,255,255,.025));
  }
  :root:not([data-theme]) .hero-kicker,
  :root:not([data-theme]) .hero-tags li,
  :root:not([data-theme]) .tag-list li,
  :root:not([data-theme]) .signal-pills li,
  :root:not([data-theme]) .panel-card,
  :root:not([data-theme]) .focus-card,
  :root:not([data-theme]) .route-card,
  :root:not([data-theme]) .principle-card,
  :root:not([data-theme]) .workflow-strip article,
  :root:not([data-theme]) .human-band,
  :root:not([data-theme]) .map-node { background-color: rgba(255,255,255,.05); }
  :root:not([data-theme]) .map-node.center {
    color: var(--accent-ink) !important;
    background: var(--accent) !important;
    border-color: rgba(23,24,22,.2);
    text-shadow: none;
  }
  :root:not([data-theme]) .button.primary { background: #f1eee5; color: #171816; }
  :root:not([data-theme]) .display-menu-popover { background: rgba(17,18,15,.26); }
  :root:not([data-theme]) .glyph {
    background: linear-gradient(135deg, rgba(255,216,77,.12), rgba(255,255,255,.045));
    border-color: rgba(241,238,229,.12);
  }
  :root:not([data-theme]) .map-node:not(.center):hover,
  :root:not([data-theme]) .map-node:not(.center):focus-visible { background: rgba(255,255,255,.09) !important; }
}

/* Coarse pointers should not keep a faux hover bubble after tapping. */
@media (hover: none), (pointer: coarse) {
  .display-control:hover,
  .display-menu-button:hover {
    color: var(--muted);
    background: transparent;
  }
  .display-menu-link:hover { background: transparent; }
}

@media (max-width: 520px) {
  .site-header { min-height: 72px; }
  .header-actions { gap: 2px; }
  .display-control,
  .display-menu-button {
    min-width: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .display-control-separator { margin-inline: -5px; }
  .display-menu-popover { width: min(120px, calc(100vw - 28px)); }
}

/* Structural narrow pass v0.2: vary the visual language and reduce mobile height. */
.route-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}
.route-grid::before {
  content: '';
  position: absolute;
  left: 20px;
  right: 20px;
  top: 20px;
  height: 1px;
  background: var(--line);
}
.route-card {
  position: relative;
  min-height: 0;
  padding: 0 28px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.route-card:last-child { padding-right: 0; }
.route-card h3 { margin-bottom: 6px; }
.route-card p { margin-bottom: 0; }
.route-step { position: relative; z-index: 1; margin-bottom: 14px; }

.principle-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 0;
}
.principle-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  align-content: start;
  padding: 18px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.principle-index {
  width: 32px;
  height: 32px;
  margin: 0;
  grid-row: 1 / span 2;
  font-size: .72rem;
}
.principle-card h3 { margin: 1px 0 6px; }
.principle-card p { margin: 0; }

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.workflow-strip article {
  padding: 15px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.workflow-strip article + article { border-left: 1px solid var(--line); }
.workflow-strip span {
  width: 28px;
  height: 28px;
  margin-bottom: 9px;
  font-size: .67rem;
}
.workflow-strip h3 { margin-bottom: 3px; font-size: 1rem; }
.workflow-strip p { margin: 0; font-size: .8rem; }

.human-band {
  margin-top: 24px;
  padding: 18px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  grid-template-columns: 180px 1fr;
}

:root[data-theme='dark'] .route-card,
:root[data-theme='dark'] .principle-card,
:root[data-theme='dark'] .workflow-strip article,
:root[data-theme='dark'] .human-band,
:root:not([data-theme]) .route-card,
:root:not([data-theme]) .principle-card,
:root:not([data-theme]) .workflow-strip article,
:root:not([data-theme]) .human-band {
  background: transparent;
  box-shadow: none;
}

@media (max-width: 620px) {
  .section { padding: 56px 0; }
  .section-heading,
  .section-heading.compact { margin-bottom: 26px; }

  .focus-grid { gap: 12px; }
  .focus-card {
    min-height: 0;
    padding: 16px;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    column-gap: 14px;
    align-items: start;
  }
  .focus-card .glyph {
    grid-column: 1;
    grid-row: 1 / span 4;
    margin: 0;
  }
  .focus-card > .micro,
  .focus-card > h3,
  .focus-card > p,
  .focus-card > .tag-list { grid-column: 2; }
  .focus-card > .micro { margin-bottom: 6px; }
  .focus-card > h3 { margin-bottom: 7px; }
  .focus-card > p { margin-bottom: 0; }
  .focus-card > .tag-list {
    margin-top: 12px;
    gap: 7px;
  }
  .focus-card .tag-list li { padding: 6px 9px; }

  .route-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .route-grid::before {
    left: 19px;
    right: auto;
    top: 18px;
    bottom: 16px;
    width: 1px;
    height: auto;
  }
  .route-card,
  .route-card:last-child {
    min-height: 88px;
    padding: 0 0 24px 62px;
  }
  .route-card:last-child { min-height: 58px; padding-bottom: 0; }
  .route-step {
    position: absolute;
    left: 0;
    top: 0;
    width: 38px;
    height: 38px;
    margin: 0;
    font-size: .72rem;
  }
  .route-card h3 { padding-top: 2px; }

  .principle-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .principle-card {
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 11px;
    padding-top: 14px;
  }
  .principle-index { width: 30px; height: 30px; }

  .workflow-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 24px;
  }
  .workflow-strip article { padding: 11px 4px; text-align: center; }
  .workflow-strip span { width: 24px; height: 24px; margin-bottom: 6px; font-size: .6rem; }
  .workflow-strip h3 { margin: 0; font-size: .76rem; letter-spacing: -.02em; }
  .workflow-strip p { display: none; }

  .human-band {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
  }
  .human-band .signal-pills { margin-top: 0; gap: 7px; }
  .human-band .signal-pills li { padding: 6px 9px; }
}

@media (max-width: 520px) {
  .section { padding: 52px 0; }
  .section-heading,
  .section-heading.compact { margin-bottom: 24px; }
}
