/* Shared topnav + footer styles. One copy used by every page on graycloud.app.
 *
 * Consumed via:
 *   - styles.css     (app/dev pages: @import url("./nav.css"); at the top)
 *   - index.html     (marketing: <link rel="stylesheet" href="/nav.css">)
 *
 * CSS variables this file expects: --bar-bg, --bar-ink, --bar-ink-strong,
 * --pad-x, --ink-3. Each consumer defines them at :root.
 *
 * Navbar/footer width is owned here (--maxw-nav) so brand position is
 * identical across every page, independent of each page's body --maxw.
 */

:root {
  --maxw-nav: 64rem; /* 1024px - matches marketing */
}

/* ---------- Top nav ---------- */
.topnav {
  background: var(--bar-bg);
  color: var(--bar-ink);
  position: relative; z-index: 100;
  /* Pin typography so brand + links render identically across pages
     whose body sets different line-height / letter-spacing / features. */
  line-height: 1.45;
  letter-spacing: normal;
  font-feature-settings: "tnum" 1, "ss01" 1;
}
.topnav-inner {
  max-width: var(--maxw-nav);
  margin: 0 auto;
  padding: 14px var(--pad-x);
  display: flex; align-items: center; gap: 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--bar-ink-strong);
  font-weight: 300;
  font-size: 17px;
  letter-spacing: 0.2px;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 22%; display: block; object-fit: cover; }
.brand-word { font-weight: 600; }
.topnav-links {
  display: flex; align-items: center; gap: clamp(16px, 2.5vw, 32px);
  margin-left: auto;
  font-size: 15px;
  font-weight: 500;
}
.topnav-links a {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--bar-ink);
  text-decoration: none;
  transition: color 0.15s;
  position: relative;
}
.topnav-links a:hover { color: var(--bar-ink-strong); text-decoration: none; }
.topnav-links a:not(.topnav-cta).active { color: var(--bar-ink-strong); }
.topnav-links a:not(.topnav-cta).active::after,
.topnav-links a:not(.topnav-cta):hover::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -6px;
  height: 2px;
  background: #3568A8;
  border-radius: 2px;
}

/* Marketing CTA pill - only rendered by the `marketing` topnav variant,
 * but defined here so every page that loads nav.css can style it. */
.topnav-cta {
  display: inline-flex; align-items: center;
  background: #ffffff;
  color: #111 !important;
  padding: 8px 14px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  line-height: 1.2;
  border: none;
  transition: background 0.15s, scale 0.12s ease;
}
.topnav-cta:hover { text-decoration: none; background: #e8e8e8; }
.topnav-cta:active { scale: 0.96; }

/* Compact "Download" pill rendered on every page except the landing.
 * Sits to the right of the search field; opt in via download="true" on the
 * TOPNAV:START marker (see scripts/partials.mjs). */
.topnav-download {
  height: 36px;
  padding: 0 16px;
  font-size: 13.5px;
  white-space: nowrap;
}
@media (max-width: 380px) {
  .topnav-download { padding: 0 12px; font-size: 13px; }
}

/* ---------- Topnav: search variant (used on /forecast) ----------
 * Pill-shaped search field centered between the brand and the waitlist CTA:
 *   [GPS icon button] [text input] [submit icon button]
 *
 * Centering uses a 1fr auto 1fr grid on .topnav-inner so the search-group
 * sits dead-center regardless of asymmetry between brand and CTA widths.
 * The .topnav-mobile-panel wrapper uses display:contents on desktop, so its
 * children (the search-group and the download CTA) participate in the grid
 * as columns 2 and 3. Below 720px the panel becomes a slide-down sheet and
 * the inner row reverts to flex (see the ≤720px block further down).
 *
 * Submits to /forecast?q=…; the GPS button is wired in /nav-search.js. */
.topnav--search .topnav-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.topnav--search .brand { justify-self: start; }
.topnav--search .topnav-search-group { justify-self: center; }
.topnav--search .topnav-download { justify-self: end; }
.topnav-search-group {
  display: inline-flex; align-items: center; gap: 0;
  min-width: 0;
}
.topnav-search {
  /* Fluid static width: floors at 320px so the pill stays usable at the 720px
     mobile-panel breakpoint, scales with viewport, and caps at 420px so it
     never crowds the surrounding chrome on wide screens. No focus-expansion
     and no content-adaptive sizing — a single value across all states. */
  width: clamp(320px, 32vw, 420px);
  min-width: 0;
  display: flex; align-items: center;
  height: 36px;
  padding: 0 4px 0 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.topnav-search:focus-within {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}
@media (prefers-reduced-motion: reduce) {
  .topnav-search { transition: none; }
}
/* Standalone GPS button - sibling of the search pill so it reads as its
   own affordance, not an in-input adornment. No chrome at rest; a subtle
   border + fill appears on hover. */
.topnav-search-gps {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--bar-ink);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, scale 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.topnav-search-gps:hover,
.topnav-search-gps:active,
.topnav-search-gps[aria-busy="true"] {
  color: var(--accent);
}
.topnav-search-gps:active { scale: 0.92; }
.topnav-search-gps[aria-busy="true"] {
  pointer-events: none;
}
.topnav-search-gps[aria-busy="true"] svg { animation: nav-search-spin 1.1s linear infinite; }
@keyframes nav-search-spin { to { transform: rotate(360deg); } }
.topnav-search-gps svg { width: 18px; height: 18px; display: block; }

/* Submit button stays inside the pill. */
.topnav-search-submit {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  background: rgba(255,255,255,0.10);
  border: 0;
  color: var(--bar-ink-strong);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, scale 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.topnav-search-submit:hover { background: #fff; color: #111; }
.topnav-search-submit:active { scale: 0.92; }
.topnav-search-submit svg { width: 18px; height: 18px; display: block; }
.topnav-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 4px;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--bar-ink-strong);
  font: inherit;
  font-size: 14.5px;
  font-weight: 400;
  letter-spacing: -0.005em;
}
.topnav-search-input::placeholder { color: var(--bar-ink); opacity: 0.75; }

/* Desktop: float the GPS-error status below the topnav-inner row via absolute
   positioning so it never wraps mid-flex. Constrained to the topnav-inner
   max-width + same side padding so the right-aligned text lines up with the
   search pill above. The mobile rule inside the ≤720px breakpoint puts it
   back in normal flow inside the panel. */
.topnav-search-status {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2 * var(--pad-x));
  max-width: var(--maxw-nav);
  margin: 0;
  padding: 6px 0 10px;
  font-size: 12.5px;
  color: var(--ink-3, rgba(255,255,255,0.6));
  text-align: right;
}
.topnav-search-status[data-tone="error"] { color: #f4a8a8; }

/* Predictive dropdown anchored under the search pill. Visually inherits from
   the pill (same border family, glass background) so it reads as a continuation
   of the input, not a separate surface. */
.topnav-search { position: relative; }
.topnav-search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: rgba(20, 20, 22, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: topnav-suggest-in 140ms ease-out;
}
.topnav-search-suggest[hidden] { display: none; }
.topnav-search-suggest-item {
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.12s ease;
}
.topnav-search-suggest-item:hover,
.topnav-search-suggest-item[aria-selected="true"] {
  background: rgba(127, 165, 214, 0.14);
}
.topnav-search-suggest-item .suggest-primary {
  font-size: 14px;
  color: var(--bar-ink-strong);
  letter-spacing: -0.005em;
}
.topnav-search-suggest-item .suggest-secondary {
  font-size: 12px;
  color: var(--ink-3, rgba(255, 255, 255, 0.6));
}
.topnav-search-suggest-empty,
.topnav-search-suggest-error {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink-3, rgba(255, 255, 255, 0.6));
}
.topnav-search-suggest-error { color: #f4a8a8; }
.topnav-search-suggest-header {
  padding: 8px 12px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3, rgba(255, 255, 255, 0.5));
  cursor: default;
  user-select: none;
}
.topnav-search-suggest-header:not(:first-child) {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
@keyframes topnav-suggest-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .topnav-search-suggest { animation: none; }
  .topnav-search-suggest-item { transition: none; }
}

/* Mobile-menu wrapper. On desktop this element is invisible to layout
   (`display: contents`) so its children — the search group and the GPS-error
   status pill — participate in the .topnav-inner flexbox exactly as they did
   before the mobile-menu wrap was introduced. On mobile (≤720px, in the rule
   block below) it becomes a slide-down panel under the header. */
.topnav-mobile-panel { display: contents; }

/* Tightest viewports: tighten the topnav side padding and the search input
   font so the slide-down panel fits comfortably on small phones. */
@media (max-width: 480px) {
  .topnav--search .topnav-inner { padding-inline: clamp(12px, 4vw, 16px); }
  .topnav-search-input { font-size: 14px; }
  .topnav-search-input::placeholder { font-size: 13.5px; }
}

/* iPhone SE / very narrow: trim the brand wordmark down so the input keeps
   a usable typing area. The icon still anchors the brand. */
@media (max-width: 380px) {
  .topnav--search .brand-word { font-size: 15px; }
  .topnav--search .brand-mark { width: 28px; height: 28px; }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--bar-bg);
  color: var(--bar-ink);
  padding: 88px var(--pad-x) 24px;
  font-size: 14px;
  font-weight: 300;
  /* Pin typography (same reason as .topnav). */
  line-height: 1.45;
  letter-spacing: normal;
  font-feature-settings: "tnum" 1, "ss01" 1;
  /* Lets .footer-copy::before bleed full-width without triggering page scroll. */
  overflow-x: clip;
}
.footer-inner {
  max-width: var(--maxw-nav);
  margin: 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 40px;
}
.brand--footer {
  font-size: 28px;
  color: var(--bar-ink-strong);
}
.brand--footer .brand-mark { width: 48px; height: 48px; }
.footer-lead {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.footer-cta-headline {
  margin: 0;
  font-size: clamp(17px, 1.9vw, 20px);
  font-weight: 300;
  color: var(--bar-ink-strong);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.footer-cta-sublink {
  display: inline-block;
  margin-top: 4px;
  /* Muted derived from the on-dark ink (--bar-ink), not the on-light
     --ink-3 — on the footer's #1a1a1a background, the page-level muted
     token would render dark-on-dark and disappear. */
  color: color-mix(in oklab, var(--bar-ink) 60%, transparent);
  font-size: 17px;
  font-weight: 400;
}
.footer-cta-sublink:hover { color: var(--bar-ink-strong); text-decoration: none; }
.footer-links {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 56px;
  text-align: right;
  color: var(--bar-ink);
}
.footer-links:has(.footer-col) { grid-template-columns: auto auto auto; gap: 8px 88px; }
.footer-col { display: grid; gap: 8px; align-content: start; }
.footer-col-heading {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bar-ink-strong);
}
.footer-links a { color: var(--bar-ink); text-decoration: none; }
.footer-links a:hover { color: var(--bar-ink-strong); text-decoration: none; }
.footer-copy {
  position: relative;
  max-width: var(--maxw-nav);
  margin: 112px auto 0;
  padding-top: 24px;
  text-align: left;
  font-size: 12px;
  /* On-dark muted — same reason as .footer-cta-sublink above. */
  color: color-mix(in oklab, var(--bar-ink) 60%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-copy-text { flex: 1 1 auto; min-width: 0; }
.footer-copy a {
  color: var(--bar-ink-strong, #fff);
  text-decoration: none;
}
.footer-copy a:hover { text-decoration: underline; }
.footer-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: color-mix(in oklab, var(--bar-ink) 70%, transparent);
}
.footer-social:hover { color: var(--bar-ink-strong, #fff); text-decoration: none; }
.footer-social svg { width: 14px; height: 14px; display: block; }
.footer-copy::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* ---------- Mobile nav toggle (hamburger) ----------
 * Hidden on desktop; revealed at <=720px. The bars use a single :before/:after
 * pseudo trick so the icon morphs to an X without an SVG swap. */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  margin: -4px -8px -4px 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--bar-ink-strong);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--bar-ink-strong);
  outline-offset: 2px;
}
.nav-toggle-icon {
  position: relative;
  display: block;
  width: 22px; height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: background-color 150ms ease-out;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute; left: 0;
  width: 22px; height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 150ms ease-out, top 150ms ease-out;
}
.nav-toggle-icon::before { top: -7px; }
.nav-toggle-icon::after  { top:  7px; }
.nav-open .nav-toggle-icon { background: transparent; }
.nav-open .nav-toggle-icon::before { top: 0; transform: rotate(45deg); }
.nav-open .nav-toggle-icon::after  { top: 0; transform: rotate(-45deg); }

@media (max-width: 720px) {
  .topnav-inner { gap: 12px; }
  /* Search variant: the desktop grid (1fr auto 1fr) doesn't fit the mobile
     pattern — the mobile-panel goes position:absolute and the nav-toggle
     needs margin-left:auto to land on the right edge. Revert to flex. */
  .topnav--search .topnav-inner { display: flex; }
  .footer-inner { flex-direction: column; gap: 24px; }
  .footer-links { grid-template-columns: 1fr; gap: 24px; text-align: left; }

  /* .topnav-links goes position:absolute below, losing its margin-left:auto.
     Push the toggle to the right edge in its place. */
  .nav-toggle { display: inline-flex; margin-left: auto; }

  /* .topnav-links transforms from inline row -> slide-down panel under header. */
  .topnav-links {
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 4px var(--pad-x) 12px;
    background: var(--bar-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 17px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    visibility: hidden;
    transition:
      opacity 150ms ease-out,
      transform 150ms ease-out,
      visibility 0s linear 150ms;
  }
  .topnav-links a:not(.topnav-cta) {
    display: block;
    padding: 14px 0;
  }
  .topnav-links a:not(.topnav-cta) + a:not(.topnav-cta) {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
  .topnav-links a:not(.topnav-cta).active::after,
  .topnav-links a:not(.topnav-cta):hover::after { display: none; }
  /* CTA inside the dropdown becomes a full-width pill below the links. */
  .topnav-links .topnav-cta {
    margin: 16px 0 4px;
    justify-content: center;
    width: 100%;
    padding: 14px 22px;
    font-size: 15px;
  }
  .nav-open .topnav-links {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition:
      opacity 150ms ease-out,
      transform 150ms ease-out,
      visibility 0s linear 0s;
  }
  /* Lock background scroll while the panel is open. */
  body.nav-open { overflow: hidden; }

  /* Search variant: the .topnav-mobile-panel wrapper switches from
     display:contents (desktop, where its children flow inline) to a
     slide-down panel anchored under the header — same pattern as
     .topnav-links above. The brand + units (if present) + hamburger
     remain inline in the topnav row. */
  .topnav-mobile-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: absolute;
    top: 100%; left: 0; right: 0;
    margin: 0;
    padding: 12px var(--pad-x) 14px;
    background: var(--bar-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    visibility: hidden;
    transition:
      opacity 150ms ease-out,
      transform 150ms ease-out,
      visibility 0s linear 150ms;
  }
  .nav-open .topnav-mobile-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition:
      opacity 150ms ease-out,
      transform 150ms ease-out,
      visibility 0s linear 0s;
  }
  /* The desktop centering (`.topnav-search-group { margin-inline: auto }`)
     would otherwise leak into the column-flex panel. Reset so the
     search-group stacks full-width like the waitlist pill. */
  .topnav-mobile-panel .topnav-search-group {
    width: 100%;
    flex: 0 0 auto;
    margin-inline: 0;
  }
  /* Search pill fills the row inside the panel. */
  .topnav-mobile-panel .topnav-search {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 0;
  }
  /* Status (GPS errors) lives inside the panel on mobile — return it to
     normal flow so it appears below the search row as part of the column
     flex. (Desktop has it absolutely positioned below the topnav-inner.) */
  .topnav-mobile-panel .topnav-search-status {
    position: static;
    transform: none;
    left: auto;
    width: 100%;
    max-width: none;
    padding: 0;
    text-align: left;
  }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .topnav-links,
  .topnav-mobile-panel,
  .nav-toggle-icon,
  .nav-toggle-icon::before,
  .nav-toggle-icon::after { transition: none; }
  .topnav-links { transform: none; }
}

@media print {
  .topnav, .site-footer { display: none; }
}
