/* Shared enhancements loaded on every page after the page's own styles:
   keyboard focus, small-screen navigation, reduced motion, and the theme toggle.
   Each page defines its own dark colours under html[data-theme="dark"]. */

html[data-theme="dark"] { color-scheme: dark; }

/* ── Keyboard focus ── */
:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}
html[data-theme="dark"] :focus-visible { outline-color: #93c5fd; }

/* ── Skip link ── */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 10000;
  padding: 10px 16px;
  background: #111827;
  color: #fff !important;
  border-radius: 6px;
  font: 600 14px/1.2 system-ui, sans-serif;
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* Visually hidden, still read by screen readers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Media never wider than the screen ── */
img, video, canvas, iframe { max-width: 100%; }

/* ── Theme toggle ── */
.theme-toggle {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #ffffff;
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: background 0.2s, color 0.2s, transform 0.15s;
  padding: 0;
}
.theme-toggle:hover { transform: translateY(-1px); }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle {
  background: #1f2937;
  color: #fbbf24;
  border-color: rgba(255, 255, 255, 0.15);
}
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media print {
  .theme-toggle, .skip-link, .site-bar, .nav-actions { display: none !important; }
}

/* ── Respect reduced-motion preference ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Sidebar search boxes already show their own icon */
#sidebar-search::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

/* Redacted details: the real value has been replaced with a placeholder, blurred for display */
.redacted {
  filter: blur(4px);
  user-select: none;
  cursor: help;
  border-radius: 3px;
}

/* ══ Site header ══
   Same menu on every page. Standalone pages wrap it in <header class="site-bar">;
   the handbook pages keep their own #topbar and put the same <nav class="site-menu"> in it.
   site.js adds the theme button and the Menu button, and puts .nav-compact on the bar
   when the links don't fit on one line, which folds them into a panel. */
.site-bar {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
  padding: 0 32px;
  background: rgba(17, 24, 39, 0.94);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
.site-bar--overlay { position: fixed; left: 0; right: 0; }   /* home page: over the hero */

.nav-logo {
  flex-shrink: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff !important;
  text-decoration: none !important;
  white-space: nowrap;
}
.nav-logo span { color: #3b82f6; }

.site-menu { margin-left: auto; display: flex; align-items: center; min-width: 0; }
.site-menu .nav-links { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.site-menu .nav-links li { margin: 0; }
.site-menu .nav-links a {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 8px 11px;
  border-radius: 6px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.site-menu .nav-links a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.site-menu .nav-links a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.12); }

/* Right side of the bar: sign in (home.ryanpgray.com only), theme, Menu */
.nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.site-menu + .nav-actions { margin-left: 4px; }

.nav-actions .theme-toggle {
  position: static;
  width: 36px;
  height: 36px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: none;
}
.nav-actions .theme-toggle svg { width: 17px; height: 17px; }
.nav-actions .theme-toggle:hover { transform: none; color: #fff; background: rgba(255, 255, 255, 0.08); }
html[data-theme="dark"] .nav-actions .theme-toggle { background: transparent; color: #fbbf24; border-color: rgba(255, 255, 255, 0.16); }

.nav-menu-btn {
  display: none;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: 500 0.82rem/1 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  cursor: pointer;
}
.nav-menu-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* Links don't fit: they fold into a panel under the bar */
.nav-compact .nav-menu-btn { display: inline-flex; }
.nav-compact .site-menu .nav-links {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 8px 16px 20px;
  background: #111827;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}
.nav-compact .site-menu.open .nav-links { display: flex; }
.nav-compact .site-menu .nav-links > li { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.nav-compact .site-menu .nav-links > li:last-child { border-bottom: 0; }
.nav-compact .site-menu .nav-links a { padding: 13px 8px; font-size: 0.95rem; letter-spacing: 0; text-transform: none; }

@media (max-width: 900px) {
  .site-bar { padding: 0 16px; gap: 12px; }

  /* Handbook top bars: the page title matters more than the logo on phones */
  #topbar .nav-logo { display: none; }

  /* Without JavaScript: one swipeable row instead */
  html:not(.js) .site-menu { flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
}
