/* ─────────────────────────────────────────────────────────────────────
   Operforma — responsive site nav chrome (mobile only).

   Progressive enhancement injected by /assets/site-nav.js: a hamburger in
   the existing header, a full-bleed overlay menu, and a thumb-reachable
   sticky bottom conversion CTA. ALL of it is mobile-only (≤600px) — desktop
   keeps its current header untouched. Surface-aware via the
   html[data-site-surface] attribute the script sets from each page's
   <meta name="color-scheme">.

   Tokens come from /assets/tokens.css; the button mirrors .mk-btn. The
   no-JS / crawler fallback is the page footer, which already carries the
   same links.
   ───────────────────────────────────────────────────────────────────── */

/* Surface palettes — one set of component rules, two token maps. */
html[data-site-surface="dark"] {
  --sn-overlay-bg: color-mix(in srgb, var(--ink) 97%, transparent);
  --sn-text: var(--white);
  --sn-muted: var(--grey-mid);
  --sn-line: var(--line-dark);
  --sn-accent: var(--indigo-soft);
  --sn-bar-bg: color-mix(in srgb, var(--surface) 96%, transparent);
  --sn-icon: var(--white);
}
html[data-site-surface="light"] {
  --sn-overlay-bg: color-mix(in srgb, var(--paper) 98%, transparent);
  --sn-text: var(--ink);
  --sn-muted: var(--soft);
  --sn-line: var(--line);
  --sn-accent: var(--accent);
  --sn-bar-bg: color-mix(in srgb, var(--paper) 96%, transparent);
  --sn-icon: var(--ink);
}

/* Everything hidden by default → desktop is completely unaffected. */
.site-hamburger,
.site-nav-overlay,
.site-cta-bar { display: none; }

/* ── Hamburger (lives inside the existing header) ── */
.site-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin: -8px;
  color: var(--sn-icon);
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.site-hamburger svg { display: block; }
.site-hamburger:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 3px; }

/* ── Overlay menu ── */
.site-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  flex-direction: column;
  background: var(--sn-overlay-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.site-nav-overlay.is-open { display: flex; }

.site-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px var(--space-s);
  border-bottom: 1px solid var(--sn-line);
  flex-shrink: 0;
}
.site-nav-close {
  background: none; border: none; cursor: pointer;
  padding: 8px; margin: -8px; color: var(--sn-icon); line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.site-nav-close svg { display: block; }
.site-nav-close:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 3px; }

.site-nav-list {
  list-style: none;
  margin: 0;
  padding: 6px var(--space-s) var(--space-s);
  display: flex;
  flex-direction: column;
}
.site-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  padding: 20px 0;
  border-bottom: 1px solid var(--sn-line);
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--sn-text);
  text-wrap: pretty;
}
.site-nav-link .arr { color: var(--sn-accent); font-family: var(--font-mono); }
.site-nav-link:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 3px; }

.site-nav-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  padding-top: 28px;
}
.site-nav-enter {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sn-accent);
  white-space: nowrap;
}
.site-nav-enter:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 3px; }

/* ── Sticky bottom conversion CTA ── */
.site-cta-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  padding: 12px var(--space-s) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--sn-bar-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--sn-line);
}

/* Shared filled-indigo button (mirrors .mk-btn), used in overlay + bottom bar. */
.site-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  padding: 15px 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--paper);
  background: var(--indigo);
  border: 1px solid var(--indigo);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.site-btn:focus-visible { outline: 2px solid var(--sn-accent); outline-offset: 3px; }
.site-btn--sm { width: auto; min-height: 0; padding: 12px 18px; font-size: 11px; }

/* ── Reveal the mobile chrome only on small screens ── */
@media (max-width: 600px) {
  .site-hamburger { display: inline-flex; }
  .site-cta-bar { display: block; }
  /* The page's own header right-cluster (CTA + language) is replaced by the
     hamburger on mobile; the script tags it .site-desktop-only. */
  .site-desktop-only { display: none !important; }
  /* Clear the fixed bottom bar so the footer stays reachable. */
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  /* The sticky bottom bar is the mobile CTA; suppress the landing page's
     in-page hero + closing buttons (and their button-microcopy) once the bar
     is injected. Gated on .site-nav-ready so a no-JS mobile load keeps them. */
  html.site-nav-ready .mk-section--hero .mk-hero-actions .mk-btn,
  html.site-nav-ready .mk-section--hero .mk-hero-actions .mk-hero-note,
  html.site-nav-ready .mk-section--closing .mk-btn,
  html.site-nav-ready .mk-section--closing .mk-hero-note { display: none; }
  /* Content & essay pages: the sticky bar is the sole mobile CTA, so suppress
     each page's own in-body diagnostic CTAs once the bar is injected.
     .close-link ("Voltar…") stays for navigation; login stays in the overlay. */
  html.site-nav-ready .close-cta,
  html.site-nav-ready .close-note,
  html.site-nav-ready .bib-gate { display: none; }
}

/* Honor reduced motion — no transform/opacity transitions on the chrome. */
@media (prefers-reduced-motion: reduce) {
  .site-hamburger, .site-nav-overlay, .site-cta-bar, .site-btn { transition: none !important; }
}
