/* ==========================================================================
   ribbon.css — shared ribbon upgrades for the AI Lab + article pages.
   Brings the static bundle's header in line with the main site's
   DescentNav/FoyerNav: scroll-spy active state (green glow + arrive bounce),
   the lowercase "menu ⌄" button, and the full-screen menu overlay.
   Relies on each page's existing tokens: --page-bg, --ink, --ink-dim,
   --hairline, --surface. The acid accent is pinned here (the site uses the
   same acid for the nav glow in both themes).
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..600;1,9..144,400..600&display=swap");

:root {
  --ribbon-acid: #C6FF00; /* matches --ob-accent / --theme-accent on the site */
}

/* ---------- nav links: site-exact active state -------------------------- */
/* matches .descent-nav .foyer-nav__links a(.is-active/.is-arriving)        */

nav.hdr-links a {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
}
nav.hdr-links a.is-active {
  color: var(--ink);
}
nav.hdr-links a.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: 50%;
  height: 18px;
  z-index: -1;
  transform: translateY(-50%);
  border-radius: 999px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, color-mix(in srgb, var(--ribbon-acid) 54%, transparent), transparent 70%);
  filter: blur(6px);
  opacity: 0.95;
}
nav.hdr-links a.is-arriving {
  animation: hdr-nav-arrive 520ms cubic-bezier(0.18, 1.24, 0.22, 1);
}
@keyframes hdr-nav-arrive {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  34% { transform: translateY(-5px) rotate(-1.6deg) scale(1.08); }
  68% { transform: translateY(1px) rotate(0.8deg) scale(0.98); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

/* ---------- menu button: matches .foyer-nav__menu-btn (descent variant) -- */

.menu-btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  font-family: "Geist Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 3px 0;
  color: var(--ink-dim);
  cursor: none; /* both AI pages run a custom cursor (cursor field / bot) */
  transition:
    color 180ms cubic-bezier(.2,.8,.2,1),
    text-shadow 180ms cubic-bezier(.2,.8,.2,1),
    transform 220ms cubic-bezier(.2,.8,.2,1);
}
.menu-btn::before {
  content: "";
  position: absolute;
  inset: -10px -12px;
  z-index: -1;
  pointer-events: none;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--ribbon-acid) 48%, transparent), transparent 70%);
  filter: blur(9px);
  opacity: 0;
  transform: scale(0.74);
  transition:
    opacity 200ms cubic-bezier(.2,.8,.2,1),
    transform 240ms cubic-bezier(.2,.8,.2,1);
}
.menu-btn:hover {
  color: var(--ink);
  text-shadow:
    0 0 10px color-mix(in srgb, var(--ribbon-acid) 70%, transparent),
    0 0 22px color-mix(in srgb, var(--ribbon-acid) 35%, transparent);
  transform: translateY(-1px);
}
.menu-btn:hover::before {
  opacity: 1;
  transform: scale(1);
}
.menu-btn span {
  display: inline-block;
  margin-left: 5px;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.menu-btn:hover span {
  transform: translateY(2px);
}
.menu-btn:focus-visible {
  outline: 2px solid var(--ribbon-acid);
  outline-offset: 3px;
}

/* ---------- menu overlay: matches .foyer-menu --------------------------- */

.site-menu {
  position: fixed;
  inset: 0;
  z-index: 60; /* above the page header (40); below the bot cursor (101) */
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.site-menu.open { display: block; }

.site-menu__backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, var(--page-bg) 86%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: none;
}
.site-menu__backdrop:focus-visible { outline: none; }

.site-menu__panel {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 32px;
  padding: 96px 24px 48px;
}

.site-menu__intro {
  font-family: "Fraunces", "Instrument Serif", serif;
  font-style: italic;
  font-weight: 450;
  font-size: clamp(18px, 2.4vw, 24px);
  line-height: 1.3;
  color: var(--ink-dim);
  margin: 0 0 10px;
}
.site-menu__dots {
  font-style: normal;
  font-weight: 600;
  margin-left: 2px;
  color: var(--ribbon-acid);
}
[data-theme="light"] .site-menu__dots { color: #3F7A2E; }
.site-menu__dots span { animation: site-menu-dot 1.6s ease-in-out infinite; }
.site-menu__dots span:nth-child(2) { animation-delay: 0.2s; }
.site-menu__dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes site-menu-dot { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.site-menu__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.site-menu__row a {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: baseline;
  gap: 4px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: var(--ink);
  cursor: none;
}
.site-menu__num {
  font-family: "Geist Mono", monospace;
  font-size: 12px;
  color: var(--ink-dim);
}
.site-menu__name {
  font-family: "Fraunces", "Instrument Serif", serif;
  font-size: clamp(32px, 6vw, 64px);
  line-height: 1;
}
.site-menu__tag {
  grid-column: 2;
  font-family: "Geist", ui-sans-serif, sans-serif;
  font-size: 14px;
  color: var(--ink-dim);
}
.site-menu__row a:hover .site-menu__name,
.site-menu__row a:focus-visible .site-menu__name {
  color: var(--ribbon-acid);
}
[data-theme="light"] .site-menu__row a:hover .site-menu__name,
[data-theme="light"] .site-menu__row a:focus-visible .site-menu__name {
  color: #3F7A2E;
}

.site-menu__off {
  display: flex;
  gap: 20px;
  font-family: "Geist Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
}
.site-menu__off a {
  color: var(--ink-dim);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  cursor: none;
}
.site-menu__off a:hover { color: var(--ink); }

/* keyboard focus rings — matches the site's acid outline */
.site-menu__row a:focus-visible,
.site-menu__off a:focus-visible {
  outline: 2px solid var(--ribbon-acid);
  outline-offset: 3px;
}

/* staggered row reveal on open (the site does this with GSAP) */
.site-menu.open .site-menu__row {
  animation: site-menu-rise 420ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.site-menu.open .site-menu__row:nth-child(1) { animation-delay: 40ms; }
.site-menu.open .site-menu__row:nth-child(2) { animation-delay: 80ms; }
.site-menu.open .site-menu__row:nth-child(3) { animation-delay: 120ms; }
.site-menu.open .site-menu__row:nth-child(4) { animation-delay: 160ms; }
.site-menu.open .site-menu__row:nth-child(5) { animation-delay: 200ms; }
.site-menu.open .site-menu__row:nth-child(6) { animation-delay: 240ms; }
@keyframes site-menu-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .site-menu__dots span { animation: none; opacity: 0.85; }
  .site-menu.open .site-menu__row { animation: none; }
  nav.hdr-links a.is-arriving { animation: none; }
}

@media (max-width: 820px) {
  .menu-btn { display: inline-flex; } /* menu stays available on mobile */
  .site-menu__panel { padding: 72px 20px 40px; }
}

/* small phones: compress the ribbon so logo + links + toggle + menu all fit
   (the header needs ~340px at default sizes — too wide for 320-375px).
   `body`-prefixed selectors out-rank the pages' inline <style>, which loads
   after this sheet and would otherwise win at equal specificity. */
@media (max-width: 480px) {
  body header { padding-left: 12px; padding-right: 12px; }
  body .hdr-right { gap: 8px; }
  body .hdr-section-group { gap: 8px; margin-right: 2px; }
  body nav.hdr-links { gap: 8px; }
  body nav.hdr-links a { font-size: 10px; letter-spacing: 0.08em; }
  body .hdr-logo-img { height: 24px; }
  body .theme-toggle { width: 26px; }
  body .menu-btn { font-size: 0.64rem; letter-spacing: 0.1em; }
  body .site-menu__name { font-size: clamp(26px, 9vw, 40px); }
  body .site-menu__row a { grid-template-columns: 44px 1fr; }
}

/* ---------- theme switch note -------------------------------------------
   The popup that confirms a light/dark switch (and previews it on hover) —
   same styling language as the home globe's tooltip in globals.css.
   `body`-prefixed for the same specificity reason as the block above. */
body .theme-note {
  position: fixed;
  z-index: 70; /* above header (40) and menu (60); below the cursors (100) */
  font-family: "Geist Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 4px 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-3px);
  transition:
    opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
body .theme-note.is-visible {
  opacity: 1;
  transform: translateY(0);
}
