/* ============================================================
   Shared site chrome - navigation bar + footer.
   Single source of truth loaded by every page (index, terms, privacy).
   Depends on each page defining the color tokens (--bg, --text, etc.)
   and loading the Tabler icon font.
   ============================================================ */

/* Stop iOS Safari from enlarging text in landscape */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light; }
/* Tell the browser which theme is active so Safari's toolbar/status bar, scrollbars and form controls match the toggle, not the OS setting */
html.dark { color-scheme: dark; }

/* Language visibility - only ever hide the inactive language */
html:not(.lang-es) [data-l="es"] { display: none; }
html.lang-es [data-l="en"] { display: none; }
/* Inline translation pairs: the active one is layout-transparent, so the
   parent (flex buttons, headings) lays out exactly as with a single language */
.t { display: contents; }

/* Side gutters that also clear the camera and rounded corners when a phone
   is on its side (iPhone Duo puts its camera on the long edge). With
   viewport-fit=cover the page runs edge to edge, so every full-width bar
   and content column pads with these instead of a fixed number. */
:root {
  --gutter: 40px;
  --pad-l: max(var(--gutter), env(safe-area-inset-left, 0px));
  --pad-r: max(var(--gutter), env(safe-area-inset-right, 0px));
  --pad-b: env(safe-area-inset-bottom, 0px);
}
@media (max-width: 720px) { :root { --gutter: 20px; } }

/* Reserve nav height before chrome.js injects, to avoid layout shift */
#site-nav { display: block; min-height: 56px; }

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg2);
  border-bottom: 0.5px solid var(--border);
  padding: 0 var(--pad-r) 0 var(--pad-l);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* No backdrop-filter: the background is opaque, so the blur did nothing visible,
     and on iOS Safari it moves the sticky nav onto its own GPU layer while scrolling,
     which drops the buttons' thin borders. */
  transition: background 0.3s;
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.nav-logo span { color: var(--orange); }
.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
  list-style: none;
}
.nav-links a {
  font-size: 13px;
  color: var(--text3);
  text-decoration: none;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  transition: color 0.2s, transform 0.1s;
  display: inline-block;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--orange); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.mode-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  color: var(--text2);
  font-size: 17px;
  transition: color 0.2s, border-color 0.2s, transform 0.1s;
}
.lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 34px;
  padding: 0 11px;
  display: flex; align-items: center; gap: 5px;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  transition: color 0.2s, border-color 0.2s, transform 0.1s;
}
.lang-btn i { font-size: 16px; }
.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  color: var(--text2);
  font-size: 20px;
  transition: color 0.2s;
}
.nav-links a:active { transform: scale(0.92); }
.mode-btn:active, .lang-btn:active, .hamburger:active { transform: scale(0.88); }
@media (hover: hover) {
  .mode-btn:hover, .lang-btn:hover, .hamburger:hover { color: var(--text); border-color: var(--text3); }
}
/* Keyboard focus ring only; taps and clicks get no lingering outline */
.mode-btn:focus, .lang-btn:focus, .hamburger:focus { outline: none; }
.mode-btn:focus-visible, .lang-btn:focus-visible, .hamburger:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
/* 44px touch target without changing the visual size */
.mode-btn::before, .lang-btn::before, .hamburger::before {
  content: ""; position: absolute; inset: -5px;
}

/* ── MOBILE MENU ── */
.mobile-menu {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 99;
  max-height: calc(100vh - 56px);
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
  flex-direction: column;
  background: var(--bg2);
  border-bottom: 0.5px solid var(--border);
  padding: 8px var(--pad-r) calc(16px + var(--pad-b)) var(--pad-l);
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text3);
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border);
  transition: color 0.2s;
}
.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu a:hover, .mobile-menu a.active { color: var(--orange); }

/* ── FOOTER ── */
.site-footer { position: relative; }
/* Top divider only where the page has no section dividers of its own (added by chrome.js) */
.site-footer.has-top-divider::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  margin: 0 auto;
  width: calc(100% - 80px);
  max-width: 880px;
  height: 0.5px;
  background: var(--border);
}
.site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px var(--pad-r) calc(28px + var(--pad-b)) var(--pad-l);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-copy {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  display: flex; align-items: center; gap: 8px;
}
.footer-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.footer-social { display: flex; align-items: center; gap: 6px; }
.social-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg2);
  border: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  font-size: 18px;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.1s;
}
.social-icon:hover { color: var(--text); border-color: var(--text3); }
.social-icon:active { transform: scale(0.88); background: var(--bg3); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text3);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--text); }

/* ── RESPONSIVE ── */
/* Below this width the full link row no longer fits beside the name and buttons
   (tablets, phones in landscape), so switch to the menu button */
@media (max-width: 960px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
}
/* If the window grows past the menu breakpoint while the menu is open
   (unfolding a foldable, rotating a tablet), don't leave it stranded */
@media (min-width: 961px) {
  .mobile-menu.open { display: none; }
}
@media (max-width: 720px) {
  .site-footer-inner { flex-direction: column; text-align: center; }
  .site-footer-inner > div { justify-content: center; }
  .footer-social { flex-wrap: wrap; }
}
