/* ==========================================================================
   PHR · Shared chrome (topbar, mega-menu, footer-legal)
   Loaded by every subpage AFTER editorial.css / subpage.css.
   ========================================================================== */

/* Reserve space for the chrome.js-injected header so it doesn't jump on load.
   Once chrome.js replaces the placeholder, the rendered <header.topbar>
   takes over with its own intrinsic height — and this rule no longer matches. */
[data-chrome="header"] {
  display: block;
  min-height: 62px;
}

/* Accessibility · keyboard focus indicator -----------------------------
   :focus-visible fires for keyboard navigation (Tab), not mouse clicks.
   So sighted mouse users do not see the ring, keyboard users do. */
:focus-visible {
  outline: 2px solid var(--fg, #f1ede4);
  outline-offset: 2px;
  border-radius: 1px;
}

/* Accessibility · screen-reader-only text ------------------------------
   Visually hidden but read by screen readers. Used for hints like
   "(opens in new window)" that should not clutter the visible UI. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Topbar -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--bg, #0a0a0a);
  border-bottom: 1px solid var(--line, #2a2a2a);
  padding-left: var(--pad-x, clamp(20px, 4vw, 48px));
  padding-right: var(--pad-x, clamp(20px, 4vw, 48px));
}
.topbar-inner {
  /* Match the content grid (--max) so logo + nav + lang line up
     with the hero/section edges instead of sticking out. */
  max-width: var(--max, 1480px);
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(20px, 4vw, 64px);
}
.topbar-mark {
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg, #f1ede4);
  text-decoration: none;
  font-weight: 600;
}
.topbar-mark-full { display: inline; }
.topbar-mark-short { display: none; }
@media (max-width: 720px) {
  .topbar-mark-full { display: none; }
  .topbar-mark-short { display: inline; }
}
.topbar-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--fg, #f1ede4);
  animation: topbar-dot-pulse 2.4s ease-in-out infinite;
}
@keyframes topbar-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(241,237,228,0.7); opacity: 1; }
  50% { box-shadow: 0 0 0 7px rgba(241,237,228,0); opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  .topbar-dot { animation: none; }
}
.topbar-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 2vw, 36px);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.topbar-nav a {
  color: var(--fg, #f1ede4);
  text-decoration: none;
  padding: 8px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s ease, opacity 0.18s ease;
  opacity: 0.78;
  position: relative;
  font-weight: 600;
}
.topbar-nav a:hover {
  border-bottom-color: var(--fg, #f1ede4);
  opacity: 1;
}
.topbar-nav a.is-here {
  border-bottom-color: #f1ede4;
  opacity: 1;
  color: #f1ede4;
}
/* mega-menu active item */
.megamenu a.is-here {
  background: transparent;
  color: #f1ede4;
}
.megamenu a.is-here strong {
  color: #f1ede4;
}
.megamenu a.is-here::after {
  content: "● you are here";
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #f1ede4;
  opacity: 1;
}
/* drawer active item */
.mobile-drawer a.is-here {
  font-weight: 700;
  color: #f1ede4;
  border-left: 3px solid #f1ede4;
  padding-left: 12px;
}
.topbar-cta {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg, #f1ede4);
  text-decoration: none;
  border: 1px solid var(--fg, #f1ede4);
  padding: 10px 16px;
  transition: background 0.18s ease, color 0.18s ease;
}
.topbar-cta:hover { background: var(--fg, #f1ede4); color: var(--bg, #0a0a0a); }
.topbar-cta .arrow { font-family: var(--font-display); font-weight: 700; }

/* Mega menu ---------------------------------------------------------- */
.megamenu {
  position: absolute;
  left: 0; right: 0;
  background: var(--bg, #0a0a0a);
  border-bottom: 1px solid var(--line, #2a2a2a);
  box-shadow: 0 24px 48px rgba(0,0,0,0.06);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.megamenu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.megamenu-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 32px clamp(20px, 3vw, 56px) 40px;
  display: grid;
  grid-template-columns: 200px 1fr 1fr 1fr;
  gap: clamp(20px, 3vw, 48px);
  align-items: start;
}
.megamenu-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-soft, #b8b1a3);
}
.megamenu-inner a {
  display: grid;
  gap: 6px;
  text-decoration: none;
  color: var(--fg, #f1ede4);
  padding: 8px 0;
  border-top: 1px solid var(--line, #2a2a2a);
  transition: padding 0.18s ease;
}
.megamenu-inner a:hover { padding-left: 8px; }
.megamenu-inner a strong {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.megamenu-inner a span {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg-soft, #b8b1a3);
  line-height: 1.5;
}

/* Burger button -------------------------------------------------- */
.topbar-burger {
  display: none;
  background: transparent;
  border: 1px solid var(--line, #2a2a2a);
  width: 44px; height: 44px;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.topbar-burger:hover {
  border-color: var(--fg, #f1ede4);
  background: rgba(255,255,255,0.04);
}
.topbar-burger span {
  display: block;
  position: absolute;
  left: 11px; right: 11px;
  height: 1.5px;
  background: var(--fg, #f1ede4);
  transition: transform 0.22s ease, opacity 0.22s ease, top 0.22s ease;
}
.topbar-burger span:nth-child(1) { top: 15px; }
.topbar-burger span:nth-child(2) { top: 21px; width: 16px; right: auto; }
.topbar-burger span:nth-child(3) { top: 27px; }
.topbar-burger.is-open {
  border-color: var(--fg, #f1ede4);
  background: var(--fg, #f1ede4);
}
.topbar-burger.is-open span { background: var(--bg, #0a0a0a); }
.topbar-burger.is-open span:nth-child(1) { top: 21px; transform: rotate(45deg); }
.topbar-burger.is-open span:nth-child(2) { opacity: 0; }
.topbar-burger.is-open span:nth-child(3) { top: 21px; transform: rotate(-45deg); width: auto; right: 11px; }

/* Mobile drawer -------------------------------------------------- */
.mobile-drawer {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg, #0a0a0a);
  z-index: 79;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.26s ease, transform 0.26s ease;
  overflow-y: auto;
  padding-top: 72px;
  -webkit-overflow-scrolling: touch;
}
.mobile-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.mobile-drawer-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px clamp(20px, 5vw, 32px) 64px;
  display: grid;
  gap: 32px;
}

.md-section { display: grid; gap: 0; }

.mobile-drawer-inner a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line, #2a2a2a);
  color: var(--fg, #f1ede4);
  text-decoration: none;
  transition: padding-left 0.18s ease;
}
.mobile-drawer-inner a:hover { padding-left: 6px; }
.mobile-drawer-inner a.is-here .md-name { color: var(--fg-soft, #b8b1a3); }
.mobile-drawer-inner a.is-here .md-arr { color: var(--fg, #f1ede4); }

.md-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(20px, 5vw, 26px);
  letter-spacing: -0.02em;
  line-height: 1.0;
  color: var(--fg, #f1ede4);
}
.md-arr {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg-soft, #b8b1a3);
}

.md-foot {
  display: flex;
  gap: clamp(16px, 4vw, 28px);
  padding-top: 16px;
  border-top: 1px solid var(--line, #2a2a2a);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.md-foot a {
  color: var(--fg-soft, #b8b1a3);
  text-decoration: none;
  padding: 0;
  border: 0;
  display: inline;
}
.md-foot a:hover { color: var(--fg, #f1ede4); padding: 0; }

@media (max-width: 1024px) {
  .megamenu { display: none; }
}
@media (max-width: 1024px) {
  .topbar-inner { grid-template-columns: auto 1fr auto; gap: 16px; }
  .topbar-nav { display: none; }
  .topbar-burger { display: inline-flex; align-items: center; justify-content: center; }
  .topbar-cta { display: none; }
}

/* Footer essays sitemap --------------------------------------------- */
.foot-essays {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid rgba(0,0,0,0.12);
}
.foot-essays h5 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-soft, #b8b1a3);
  margin: 0 0 16px;
  font-weight: 600;
}
.foot-essay-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 32px;
}
.foot-essay-list a {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  color: var(--fg, #f1ede4);
  text-decoration: none;
  display: inline-block;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.foot-essay-list a:hover {
  border-bottom-color: var(--accent, #f1ede4);
  color: var(--accent, #f1ede4);
}
@media (max-width: 900px) {
  .foot-essay-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .foot-essay-list { grid-template-columns: 1fr; gap: 4px; }
}

/* Footer legal trio -------------------------------------------------- */
.foot-bottom .foot-legal {
  display: inline-flex;
  gap: 16px;
}
.foot-bottom .foot-legal a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s ease;
}
.foot-bottom .foot-legal a:hover { border-bottom-color: currentColor; }
@media (max-width: 700px) {
  .foot-bottom { flex-direction: column; gap: 12px; align-items: flex-start; }
}

/* Topbar right cluster (status + lang) -------------------------- */
.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: clamp(28px, 3.5vw, 56px);
}
.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(241,237,228,0.55);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg, #f1ede4);
  font-weight: 600;
  white-space: nowrap;
  background: #000;
}
.topbar-status-square {
  width: 8px; height: 8px;
  background: var(--fg, #f1ede4);
  display: inline-block;
  animation: topbar-status-pulse 2.4s ease-in-out infinite;
}
@keyframes topbar-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@media (prefers-reduced-motion: reduce) {
  .topbar-status-square { animation: none; }
}
@media (max-width: 1024px) {
  .topbar-status { display: none; }
}

/* Language switcher (topbar) ------------------------------------ */
.topbar-lang {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.topbar-lang .lang-link {
  color: var(--fg-soft, #b8b1a3);
  text-decoration: none;
  padding: 4px 6px;
  border-bottom: 2px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
  font-weight: 500;
}
.topbar-lang .lang-link:hover { color: var(--fg, #f1ede4); }
.topbar-lang .lang-link.is-active {
  color: var(--fg, #f1ede4);
  border-bottom-color: var(--fg, #f1ede4);
  font-weight: 700;
}
.topbar-lang .lang-link.is-disabled {
  color: var(--fg-mute, #7a7a7a);
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.topbar-lang .lang-sep {
  color: var(--fg-soft, #b8b1a3);
  opacity: 0.4;
}
@media (max-width: 1024px) {
  .topbar-lang { font-size: 10px; gap: 2px; }
  .topbar-lang .lang-link { padding: 4px 4px; }
}

/* ============================================================
   MOBILE POLISH (universal, applied to every page via chrome.css)
   ============================================================ */

/* Smooth scroll for in-page anchor links (TOC, "back to top", etc.) */
html { scroll-behavior: smooth; }

/* Honor user preference for reduced motion: turn smooth scroll back off */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Kill the iOS/Chrome grey tap-highlight flash on links and buttons */
a, button, [role="button"], .btn, .doc-card, .frq-cell, .e404-door {
  -webkit-tap-highlight-color: transparent;
}

/* Prevent text-size-adjust on iOS rotate (Safari bumps font on landscape) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Never allow horizontal scroll on mobile (catch-all for any rogue overflow) */
@media (max-width: 800px) {
  html, body { overflow-x: hidden; }
}

/* Make sure inline links inside paragraphs are easily tappable on mobile */
@media (max-width: 700px) {
  p a, li a { padding: 2px 0; }
}

/* Mobile-only: reduce the giant hero headings slightly to avoid one-word-per-line */
@media (max-width: 480px) {
  .hero-cinema-title h1 { letter-spacing: -0.03em; }
}
