/* ============================================================
   echohive "Open Lab" chrome: theme tokens, header, menu, footer,
   mobile dock. Loaded on every page that uses base_growth.html.

   Everything here is namespaced (.eh-*, --eh-*) so it can sit on
   top of the legacy Open Ledger / Instrument stylesheets that
   articles and experiences still use, without either side leaking.

   Themes: light and dark. The page follows the visitor's system
   setting unless they pick one with the header toggle (remembered
   on this device). Pages with a fixed palette set data-theme and
   data-theme-lock on <html>; the toggle is hidden there.
   See strategy/website-redesign-2026-09-29.md.
   ============================================================ */

/* ---------- tokens: light (default) ---------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --eh-bg: #f7f5f0;
  --eh-bg-2: #efece5;
  --eh-surface: #ffffff;
  --eh-surface-2: #f4f2ed;
  --eh-ink: #15161a;
  --eh-ink-2: #3b3e45;
  --eh-muted: #5f636b;
  --eh-line: #e3ded4;
  --eh-line-2: #cfc8ba;
  --eh-link: #2141c9;
  --eh-cta: #15161a;
  --eh-cta-ink: #ffffff;
  --eh-cta-hover: #2141c9;
  --eh-cta-hover-ink: #ffffff;
  --eh-hive: #f2a81d;
  --eh-hive-ink: #7a4b00;
  --eh-hive-soft: #fcefd2;
  --eh-ai: #2141c9;
  --eh-mk: #955700;
  --eh-mi: #2a7550;
  --eh-ai-soft: #e7ebfb;
  --eh-mk-soft: #f8ecda;
  --eh-mi-soft: #e2f1e8;
  --eh-good: #2a7550;
  --eh-stage: #0f1014;
  --eh-stage-2: #181a1f;
  --eh-stage-ink: #f3f0e9;
  --eh-stage-muted: #a9adb5;
  --eh-stage-line: rgba(255, 255, 255, .12);
  --eh-head-bg: rgba(247, 245, 240, .86);
  --eh-shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 14px 34px -20px rgba(20, 20, 30, .28);
  --eh-shadow-lg: 0 2px 4px rgba(20, 20, 30, .05), 0 30px 60px -30px rgba(20, 20, 30, .35);
  --eh-focus: #2141c9;
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --eh-bg: #0e0f12;
    --eh-bg-2: #131418;
    --eh-surface: #17191d;
    --eh-surface-2: #1e2025;
    --eh-ink: #f1eee7;
    --eh-ink-2: #d2cfc8;
    --eh-muted: #a3a6ad;
    --eh-line: #26282e;
    --eh-line-2: #383b43;
    --eh-link: #9aaeff;
    --eh-cta: #f1eee7;
    --eh-cta-ink: #111216;
    --eh-cta-hover: #9aaeff;
    --eh-cta-hover-ink: #0e0f12;
    --eh-hive: #ffbf3c;
    --eh-hive-ink: #ffcb66;
    --eh-hive-soft: rgba(255, 191, 60, .12);
    --eh-ai: #9aaeff;
    --eh-mk: #f2b660;
    --eh-mi: #72d3a4;
    --eh-ai-soft: rgba(154, 174, 255, .12);
    --eh-mk-soft: rgba(242, 182, 96, .12);
    --eh-mi-soft: rgba(114, 211, 164, .12);
    --eh-good: #72d3a4;
    --eh-stage: #08090b;
    --eh-stage-2: #111317;
    --eh-stage-line: rgba(255, 255, 255, .1);
    --eh-head-bg: rgba(14, 15, 18, .82);
    --eh-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -22px rgba(0, 0, 0, .8);
    --eh-shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 30px 70px -30px rgba(0, 0, 0, .9);
    --eh-focus: #9aaeff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --eh-bg: #0e0f12;
  --eh-bg-2: #131418;
  --eh-surface: #17191d;
  --eh-surface-2: #1e2025;
  --eh-ink: #f1eee7;
  --eh-ink-2: #d2cfc8;
  --eh-muted: #a3a6ad;
  --eh-line: #26282e;
  --eh-line-2: #383b43;
  --eh-link: #9aaeff;
  --eh-cta: #f1eee7;
  --eh-cta-ink: #111216;
  --eh-cta-hover: #9aaeff;
  --eh-cta-hover-ink: #0e0f12;
  --eh-hive: #ffbf3c;
  --eh-hive-ink: #ffcb66;
  --eh-hive-soft: rgba(255, 191, 60, .12);
  --eh-ai: #9aaeff;
  --eh-mk: #f2b660;
  --eh-mi: #72d3a4;
  --eh-ai-soft: rgba(154, 174, 255, .12);
  --eh-mk-soft: rgba(242, 182, 96, .12);
  --eh-mi-soft: rgba(114, 211, 164, .12);
  --eh-good: #72d3a4;
  --eh-stage: #08090b;
  --eh-stage-2: #111317;
  --eh-stage-line: rgba(255, 255, 255, .1);
  --eh-head-bg: rgba(14, 15, 18, .82);
  --eh-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -22px rgba(0, 0, 0, .8);
  --eh-shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 30px 70px -30px rgba(0, 0, 0, .9);
  --eh-focus: #9aaeff;
}

/* ---------- shared, theme independent ---------- */
:root {
  --eh-serif: "Iowan Old Style", Charter, "Bitstream Charter", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --eh-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --eh-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --eh-wrap: 1200px;
  --eh-gutter: 24px;
  --eh-head-h: 64px;
  --eh-r-sm: 10px;
  --eh-r: 16px;
  --eh-r-lg: 22px;
  --eh-ease: cubic-bezier(.2, .7, .2, 1);
}
@media (max-width: 560px) { :root { --eh-gutter: 16px; --eh-head-h: 58px; } }

.eh-wrap { width: min(var(--eh-wrap), 100% - 2 * var(--eh-gutter)); margin-inline: auto; }
.eh-vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- skip link ---------- */
.eh-skip {
  position: absolute; left: 12px; top: -60px; z-index: 400;
  padding: 10px 16px; border-radius: var(--eh-r-sm);
  background: var(--eh-cta); color: var(--eh-cta-ink) !important;
  font: 600 15px/1.2 var(--eh-sans); text-decoration: none;
}
.eh-skip:focus { top: 12px; outline: 3px solid var(--eh-focus); outline-offset: 2px; }

/* ---------- buttons (shared by chrome and pages) ---------- */
.eh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 12px 20px; border-radius: 12px;
  border: 1px solid transparent;
  font: 600 16px/1.25 var(--eh-sans); letter-spacing: -.005em;
  text-decoration: none !important; text-align: center; white-space: normal;
  cursor: pointer; transition: background-color .18s var(--eh-ease), color .18s var(--eh-ease),
    border-color .18s var(--eh-ease), transform .18s var(--eh-ease), box-shadow .18s var(--eh-ease);
}
.eh-btn:focus-visible { outline: 3px solid var(--eh-focus); outline-offset: 3px; }
.eh-btn-primary { background: var(--eh-cta); color: var(--eh-cta-ink) !important; }
.eh-btn-primary:hover { background: var(--eh-cta-hover); color: var(--eh-cta-hover-ink) !important; transform: translateY(-1px); }
.eh-btn-secondary { background: transparent; color: var(--eh-ink) !important; border-color: var(--eh-line-2); }
.eh-btn-secondary:hover { border-color: var(--eh-ink); background: var(--eh-surface); }
.eh-btn-quiet { background: transparent; color: var(--eh-ink) !important; padding-inline: 8px; min-height: 44px; }
.eh-btn-quiet:hover { color: var(--eh-link) !important; }
.eh-btn-sm { min-height: 40px; padding: 8px 14px; font-size: 14.5px; border-radius: 10px; }
.eh-btn-lg { min-height: 54px; padding: 14px 24px; font-size: 17px; }
.eh-btn-block { width: 100%; }
.eh-btn .eh-arrow { transition: transform .18s var(--eh-ease); }
.eh-btn:hover .eh-arrow { transform: translateX(2px); }
.eh-btn .eh-meta { font: 500 13px/1 var(--eh-mono); opacity: .72; letter-spacing: 0; }

/* ---------- header ---------- */
.eh-head {
  position: sticky; top: 0; z-index: 200;
  background: var(--eh-head-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  color: var(--eh-ink);
  font-family: var(--eh-sans);
  transition: border-color .2s var(--eh-ease), box-shadow .2s var(--eh-ease);
}
html.eh-scrolled .eh-head { border-bottom-color: var(--eh-line); }
.eh-head-row {
  display: flex; align-items: center; gap: 20px;
  height: var(--eh-head-h);
}
.eh-brand {
  display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0;
  color: var(--eh-ink) !important; text-decoration: none !important;
  font: 500 21px/1 var(--eh-serif); letter-spacing: -.01em;
  min-height: 44px;
}
.eh-brand svg { color: var(--eh-hive); flex-shrink: 0; }
.eh-brand:focus-visible { outline: 3px solid var(--eh-focus); outline-offset: 4px; border-radius: 6px; }

.eh-nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.eh-nav > a {
  position: relative; display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--eh-ink-2) !important; text-decoration: none !important;
  font: 500 15px/1 var(--eh-sans); white-space: nowrap;
}
.eh-nav > a:hover { color: var(--eh-ink) !important; background: var(--eh-surface-2); }
.eh-nav > a:focus-visible { outline: 3px solid var(--eh-focus); outline-offset: 1px; }
.eh-nav > a[aria-current="page"] { color: var(--eh-ink) !important; }
.eh-nav > a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 7px;
  height: 2px; border-radius: 2px; background: var(--eh-hive);
}
.eh-nav-desc { display: none; }

.eh-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.eh-join { min-height: 42px; padding: 9px 16px; font-size: 15px; border-radius: 11px; }
.eh-join .eh-join-from { font-weight: 500; opacity: .75; }

.eh-icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 11px; border: 1px solid var(--eh-line-2); background: transparent;
  color: var(--eh-ink); cursor: pointer; padding: 0;
  transition: border-color .18s var(--eh-ease), background-color .18s var(--eh-ease);
}
.eh-icon-btn:hover { border-color: var(--eh-ink); background: var(--eh-surface); }
.eh-icon-btn:focus-visible { outline: 3px solid var(--eh-focus); outline-offset: 2px; }
.eh-icon-btn svg { width: 19px; height: 19px; }

/* Theme toggle: the icon shows the theme you would switch to. */
.eh-theme .eh-sun { display: none; }
:root[data-theme="dark"] .eh-theme .eh-sun { display: block; }
:root[data-theme="dark"] .eh-theme .eh-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .eh-theme .eh-sun { display: block; }
  :root:not([data-theme="light"]) .eh-theme .eh-moon { display: none; }
}
:root[data-theme-lock] .eh-theme, :root[data-theme-lock] .eh-theme-row { display: none !important; }
html:not(.js) .eh-theme, html:not(.js) .eh-theme-row { display: none !important; }

.eh-menu-btn { display: none; gap: 8px; width: auto; padding: 0 12px; font: 600 14.5px/1 var(--eh-sans); }
.eh-menu-btn .eh-menu-icon { display: grid; gap: 4px; width: 16px; }
.eh-menu-btn .eh-menu-icon i { display: block; height: 1.6px; border-radius: 2px; background: currentColor; transition: transform .2s var(--eh-ease), opacity .2s; }
.eh-menu-btn[aria-expanded="true"] .eh-menu-icon i:nth-child(1) { transform: translateY(5.6px) rotate(45deg); }
.eh-menu-btn[aria-expanded="true"] .eh-menu-icon i:nth-child(2) { opacity: 0; }
.eh-menu-btn[aria-expanded="true"] .eh-menu-icon i:nth-child(3) { transform: translateY(-5.6px) rotate(-45deg); }
.eh-sheet-extra { display: none; }

@media (max-width: 1120px) and (min-width: 1001px) {
  .eh-nav > a { padding-inline: 9px; font-size: 14.5px; }
  .eh-join .eh-join-from { display: none; }
  .eh-head-row { gap: 12px; }
}

/* Mobile and tablet: the nav becomes a sheet under the header. */
@media (max-width: 1000px) {
  .js .eh-menu-btn { display: inline-flex; }
  .js .eh-actions { margin-left: auto; }
  .js .eh-nav {
    position: fixed; left: 0; right: 0; top: var(--eh-head-h); bottom: 0;
    display: none; flex-direction: column; align-items: stretch; gap: 0;
    margin: 0; padding: 12px var(--eh-gutter) calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--eh-bg); border-top: 1px solid var(--eh-line);
  }
  .js .eh-nav.is-open { display: flex; animation: eh-sheet .22s var(--eh-ease); }
  .js .eh-nav > a {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px;
    min-height: 64px; padding: 12px 4px; border-radius: 0;
    border-bottom: 1px solid var(--eh-line);
    font: 500 21px/1.2 var(--eh-serif); color: var(--eh-ink) !important;
    white-space: normal;
  }
  .js .eh-nav > a:hover { background: transparent; }
  .js .eh-nav > a::before { content: "→"; grid-column: 2; grid-row: 1 / span 2; font: 400 18px/1 var(--eh-sans); color: var(--eh-muted); }
  .js .eh-nav > a[aria-current="page"]::after { left: 4px; right: auto; top: 16px; bottom: 16px; width: 3px; height: auto; margin-left: -12px; }
  .js .eh-nav .eh-nav-desc { display: block; grid-column: 1; font: 400 14px/1.4 var(--eh-sans); color: var(--eh-muted); }
  .js .eh-sheet-extra { display: grid; gap: 12px; margin-top: 20px; }
  .eh-theme-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 56px; padding: 6px 4px; font: 500 15px/1.3 var(--eh-sans); color: var(--eh-ink-2);
  }
  .eh-actions .eh-theme { display: none; }
  html.eh-menu-open { overflow: hidden; }
  /* backdrop-filter would make the header the containing block of the fixed
     sheet, so the open menu trades the blur for a solid bar. */
  html.eh-menu-open .eh-head { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--eh-bg); border-bottom-color: var(--eh-line); }
  /* Without JavaScript the links stay reachable as a scrolling row. */
  html:not(.js) .eh-head-row { flex-wrap: wrap; height: auto; padding-block: 8px; }
  html:not(.js) .eh-nav { order: 3; width: 100%; overflow-x: auto; margin: 0; }
}
@media (max-width: 420px) {
  .eh-menu-btn .eh-menu-label { display: none; }
  .eh-menu-btn { width: 42px; padding: 0; justify-content: center; }
  .eh-join { padding-inline: 13px; }
  .eh-brand { font-size: 19px; gap: 8px; }
  .eh-head-row { gap: 12px; }
}
@keyframes eh-sheet { from { transform: translateY(-6px); } to { transform: none; } }

/* ---------- mobile dock: the persistent primary action ---------- */
.eh-dock {
  position: fixed; z-index: 150; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: none; align-items: center; gap: 8px; padding: 8px;
  border-radius: 18px; border: 1px solid var(--eh-line);
  background: var(--eh-head-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  box-shadow: var(--eh-shadow-lg);
  transform: translateY(calc(100% + 40px)); transition: transform .28s var(--eh-ease);
  font-family: var(--eh-sans);
}
.eh-dock .eh-btn { flex: 1; min-height: 50px; }
.eh-dock-note { display: block; font: 500 12px/1.2 var(--eh-mono); opacity: .7; }
.eh-dock-close {
  flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: var(--eh-muted); cursor: pointer; font: 400 22px/1 var(--eh-sans);
}
.eh-dock-close:focus-visible { outline: 3px solid var(--eh-focus); outline-offset: 1px; }
@media (max-width: 1000px) { .js .eh-dock { display: flex; } }
.eh-dock.is-visible { transform: none; }

/* ---------- footer ---------- */
.eh-foot {
  margin-top: 0; padding: 64px 0 calc(40px + env(safe-area-inset-bottom));
  background: var(--eh-bg-2); color: var(--eh-ink-2);
  border-top: 1px solid var(--eh-line);
  font: 400 15px/1.6 var(--eh-sans);
}
.eh-foot a:not(.eh-btn) { color: var(--eh-ink-2); text-decoration: none; }
.eh-foot a:not(.eh-btn):hover { color: var(--eh-ink); text-decoration: underline; text-underline-offset: 3px; }
.eh-foot a:focus-visible { outline: 3px solid var(--eh-focus); outline-offset: 2px; border-radius: 4px; }
.eh-foot-top { display: grid; grid-template-columns: 1.3fr repeat(3, minmax(0, 1fr)); gap: 40px; }
.eh-foot-lead p { margin: 14px 0 20px; max-width: 34ch; color: var(--eh-muted); }
.eh-foot-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.eh-foot h2 {
  margin: 6px 0 14px; font: 600 12px/1.2 var(--eh-mono); letter-spacing: .08em;
  text-transform: uppercase; color: var(--eh-muted);
}
.eh-foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.eh-foot li a { display: inline-flex; align-items: center; gap: .3em; min-height: 36px; }
.eh-foot-fine {
  margin: 48px 0 0; padding-top: 24px; border-top: 1px solid var(--eh-line);
  font-size: 13px; line-height: 1.6; color: var(--eh-muted);
}
.eh-foot-base { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; font-size: 13px; color: var(--eh-muted); }
@media (max-width: 900px) {
  .eh-foot-top { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 24px; }
  .eh-foot-lead { grid-column: 1 / -1; }
}
@media (max-width: 1000px) { .eh-foot { padding-bottom: calc(104px + env(safe-area-inset-bottom)); } }

/* Legacy pages size sticky reading maps from --head-h; keep them flush with this header. */
body.ledger-site { --head-h: var(--eh-head-h); }

@media (prefers-reduced-motion: reduce) {
  .eh-btn, .eh-head, .eh-dock, .eh-btn .eh-arrow, .eh-menu-btn .eh-menu-icon i { transition: none !important; }
  .js .eh-nav.is-open { animation: none; }
  .eh-btn-primary:hover { transform: none; }
}
