.search-overlay-static {
  display: none;
}

/* Anchor both search shells to every viewport edge. The dynamic viewport
   height remains a floor for iOS browser chrome, while bottom: 0 prevents a
   visible strip when a browser reports a shorter dynamic viewport on focus. */
.search-overlay-static,
.search-overlay-dynamic {
  inset: 0;
  height: auto;
  min-height: 100dvh;
}

body:has(#search-open:checked):not(:has(.search-overlay-dynamic)) .search-overlay-static {
  display: block;
}

body:has(#search-open:checked) {
  overflow: hidden;
}

/* Hide the community comments FAB when any overlay is active.
   The FAB at z-[120] floats above all overlays (z-[100]–z-[101]). */
body:has(.adaptive-dialog-overlay) .comments-fab,
body:has(#search-open:checked) .comments-fab,
body:has(.hero-lightbox) .comments-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
  transition: opacity 200ms cubic-bezier(0.32, 0.72, 0, 1), transform 200ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* Hide competing fixed-position elements while the search overlay is open.
   iOS Safari's dynamic viewport can leave a gap during chrome animation;
   hiding these prevents them from peeking through. */
body:has(#search-open:checked) .mobile-bottom-nav,
body:has(#search-open:checked) #fap-filter-fab {
  display: none;
}

/* Match the quiet dark boundary used by shared chrome. The token stays
   transparent in light mode, so the 64px mobile navigation keeps stable
   geometry across theme changes. The Classic resting shadow and blur live here
   (not inline) so the more-specific City rule can override them cleanly. */
.mobile-bottom-nav {
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border-dropdown);
  box-shadow: 0 -1px 3px rgb(0 0 0 / 0.06);
}

@media (max-width: 767.98px) {
  main :where(
    a[href],
    button:not(:disabled),
    input:not(:disabled),
    select:not(:disabled),
    textarea:not(:disabled),
    summary,
    [tabindex]:not([tabindex="-1"])
  ) {
    scroll-margin-bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

.site-header-backdrop {
  background: var(--color-surface);
  backdrop-filter: blur(0);
  box-shadow: none;
  transition:
    background 240ms ease,
    backdrop-filter 240ms ease,
    box-shadow 240ms ease;
}

.site-header.scrolled .site-header-backdrop {
  background: color-mix(in srgb, var(--color-surface) 85%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--color-on-surface) 6%, transparent);
}

/* Centered routes are primary navigation. In light mode, lift their resting
   colour above supporting copy without competing with the active emerald. */
@media (prefers-color-scheme: light) {
  :root[data-style="classic"]:not([data-theme="dark"]) .site-header-nav-link:not(.site-header-nav-link--active) {
    color: color-mix(in srgb, var(--color-on-surface) 82%, var(--color-on-surface-variant));
  }
}

:root[data-style="classic"][data-theme="light"] .site-header-nav-link:not(.site-header-nav-link--active) {
  color: color-mix(in srgb, var(--color-on-surface) 82%, var(--color-on-surface-variant));
}

:root[data-style="classic"] .site-header-nav-link:not(.site-header-nav-link--active):hover {
  color: var(--color-secondary);
}

/* Dark surfaces need a resting boundary too. The scroll state still adds the
   translucent blur; this only makes the header edge legible before scrolling. */
@media (prefers-color-scheme: dark) {
  :root[data-style="classic"][data-theme-preference="system"] .site-header-backdrop {
    box-shadow: 0 1px 0 color-mix(in srgb, var(--color-on-surface) 6%, transparent);
  }
}

:root[data-style="classic"][data-theme="dark"] .site-header-backdrop {
  box-shadow: 0 1px 0 color-mix(in srgb, var(--color-on-surface) 6%, transparent);
}

/* In dark mode, the centered routes are primary navigation, not supporting
   metadata. Keep an active route emerald while lifting the other links to the
   full foreground token. */
@media (prefers-color-scheme: dark) {
  :root[data-style="classic"][data-theme-preference="system"] .site-header-nav-link:not(.site-header-nav-link--active) {
    color: var(--color-on-surface);
  }
}

:root[data-style="classic"][data-theme="dark"] .site-header-nav-link:not(.site-header-nav-link--active) {
  color: var(--color-on-surface);
}

@media (prefers-color-scheme: dark) {
  :root[data-style="classic"][data-theme-preference="system"] .site-header-nav-link:not(.site-header-nav-link--active):hover {
    color: var(--color-secondary);
  }
}

:root[data-style="classic"][data-theme="dark"] .site-header-nav-link:not(.site-header-nav-link--active):hover {
  color: var(--color-secondary);
}

.site-header-brand-link {
  height: 40px;
  display: inline-flex;
  align-items: center;
}

/* Search trigger — press feedback. The pill shape itself is Tailwind
   (desktop: variants on the label); only what Tailwind can't express lives
   here. */
.site-header-search-trigger {
  isolation: isolate;
  position: relative;
  transition:
    background-color 180ms ease,
    transform 160ms ease-out;
}

.site-header-search-trigger:active {
  transform: scale(0.97);
}

/* The desktop Classic dark trigger uses the dialog's quiet boundary, keeping
   the prominent search entry distinct from the header surface. */
@media (min-width: 1024px) and (prefers-color-scheme: dark) {
  :root[data-style="classic"][data-theme-preference="system"] .site-header-search-trigger {
    border: 1px solid var(--c-border-dropdown);
  }
}

@media (min-width: 1024px) {
  :root[data-style="classic"][data-theme="dark"] .site-header-search-trigger {
    border: 1px solid var(--c-border-dropdown);
  }
}

/* Discovery nudge — the one-time invitation. A brief green sweep makes the
   search entry visible without changing its resting colour or geometry. */
@property --search-ring-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: -35deg;
}

.site-header-search-trigger--nudge::after {
  --search-ring-angle: -35deg;
  animation: search-trigger-ring 1300ms linear 1 both;
  background: conic-gradient(
    from var(--search-ring-angle),
    transparent 0deg 190deg,
    color-mix(in srgb, var(--color-secondary) 18%, transparent) 220deg,
    color-mix(in srgb, var(--color-secondary) 58%, transparent) 258deg,
    color-mix(in srgb, var(--color-secondary) 76%, white) 276deg,
    color-mix(in srgb, var(--color-secondary) 42%, transparent) 298deg,
    transparent 340deg
  );
  border-radius: inherit;
  content: '';
  inset: 0;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  padding: 2px;
  pointer-events: none;
  position: absolute;
  z-index: 1;
  opacity: 0;
}

@keyframes search-trigger-ring {
  0% {
    --search-ring-angle: -35deg;
    opacity: 0;
  }

  14% {
    opacity: 0.72;
  }

  70% {
    opacity: 0.55;
  }

  100% {
    --search-ring-angle: 325deg;
    opacity: 0;
  }
}

.site-header-nav-link,
.site-header-language-option {
  height: 40px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.site-header-wordmark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  text-box-trim: trim-both;
  text-box-edge: text alphabetic;
}

/* The search bar's placeholder text shares a flex row with the fixed-box
   icon and kbd chip — trim the font's leading so it centers optically,
   same as the nav links beside it. */
.site-header-search-label {
  align-items: center;
  line-height: 1;
  text-box-trim: trim-both;
  text-box-edge: cap alphabetic;
}

/* Search images commonly arrive as JPEGs with a baked white matte. Use the
   shared photo plate and blend contract so their edges disappear in dark mode
   without reducing the phone render to a silhouette. */
.search-result-thumbnail {
  background: var(--c-photo-img-bg);
}

.search-result-thumbnail > img {
  mix-blend-mode: var(--c-photo-blend-mode);
}

.site-header-language-option[aria-pressed="true"] {
  color: var(--color-secondary);
}

.site-header-nav-link,
.site-header-language-option {
  text-box-trim: trim-both;
  text-box-edge: cap alphabetic;
}

/* ── City construction ──────────────────────────────────────────────────
   Root-scoped under :root[data-style="city"] so Classic stays untouched.
   Uses the shared City ink/outline/hard-shadow tokens from city.css. */
:root[data-style="city"] .site-header-backdrop {
  background: color-mix(in srgb, var(--color-surface) 96%, transparent);
  border-bottom: var(--fp-outline-width) solid var(--fp-ink);
  box-sizing: border-box;
}

:root[data-style="city"] .site-header.scrolled .site-header-backdrop {
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--fp-ink) 18%, transparent);
}

:root[data-style="city"] .site-header-nav-link {
  color: var(--color-on-surface);
  position: relative;
}

:root[data-style="city"] .site-header-nav-link--active::after {
  background: var(--color-tertiary);
  border: 1px solid var(--fp-ink);
  bottom: 2px;
  content: '';
  height: 5px;
  left: 0;
  position: absolute;
  right: 0;
}

:root[data-style="city"] .site-header-search-trigger {
  border: var(--fp-outline-width) solid transparent;
}

:root[data-style="city"] .site-header-search-trigger:hover {
  background: var(--color-tertiary);
  border-color: var(--fp-ink);
  color: var(--color-on-tertiary);
}

/* City constructs the desktop search bar like its other outlined chips:
   ink boundary, hard shadow, hover lift, and a press that sinks into the
   page (same convention as .app-button). */
@media (min-width: 1024px) {
  :root[data-style="city"] .site-header-search-trigger {
    background: var(--color-surface);
    border-color: var(--fp-ink);
    box-shadow: 3px 3px 0 color-mix(in srgb, var(--fp-ink) 18%, transparent);
    transition:
      transform 180ms ease,
      box-shadow 180ms ease,
      background-color 180ms ease,
      color 180ms ease;
  }

  :root[data-style="city"] .site-header-search-trigger:hover {
    box-shadow: 5px 5px 0 color-mix(in srgb, var(--fp-ink) 22%, transparent);
    transform: translate(-1px, -2px);
  }

  :root[data-style="city"] .site-header-search-trigger:active {
    box-shadow: 1px 1px 0 color-mix(in srgb, var(--fp-ink) 22%, transparent);
    transform: translate(2px, 2px);
  }

  :root[data-style="city"] .site-header-search-trigger:hover .site-header-search-label {
    color: var(--color-on-tertiary);
  }

  :root[data-style="city"] .site-header-search-kbd {
    background: transparent;
    border: var(--fp-outline-width) solid var(--fp-ink);
    color: inherit;
  }

}

:root[data-style="city"] .mobile-bottom-nav {
  background: color-mix(in srgb, var(--color-surface) 97%, transparent);
  border-top: var(--fp-outline-width) solid var(--fp-ink);
  box-shadow: 0 -4px 0 color-mix(in srgb, var(--fp-ink) 18%, transparent);
  box-sizing: border-box;
}

:root[data-style="city"] .mobile-bottom-nav-tab {
  margin: 5px 3px;
  border-radius: var(--radius-md);
}

:root[data-style="city"] .mobile-bottom-nav-tab--active {
  background: var(--color-tertiary);
  box-shadow: inset 0 0 0 var(--fp-outline-width) var(--fp-ink);
}

:root[data-style="city"] .mobile-bottom-nav-tab--active .mobile-bottom-nav-icon,
:root[data-style="city"] .mobile-bottom-nav-tab--active .mobile-bottom-nav-label {
  color: var(--color-on-tertiary);
}

@media (prefers-reduced-motion: reduce) {
  :root[data-style="city"] .site-header-backdrop,
  :root[data-style="city"] .site-header-nav-link,
  :root[data-style="city"] .site-header-search-trigger {
    transition: none;
  }

  /* The nudge is gated in JS too — this is the CSS backstop. */
  .site-header-search-trigger--nudge::after {
    animation: none;
  }

  /* Press feedback is movement; reduced-motion keeps the color response. */
  .site-header-search-trigger:active {
    transform: none;
  }
}
