/* ============================================================
   layout.css — page structure, grid, responsive
   ============================================================ */

/* ── Background orbs ─────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0;
  will-change: transform;
  background: var(--orb-color, var(--primary));
  transition: background 0.8s ease-in-out;
}

.bg-orb--1 { width: 600px; height: 600px; top: -10%; left: -10%; } /* top-left     */
.bg-orb--2 { width: 500px; height: 500px; top: -10%; right: -10%;} /* top-right    */
.bg-orb--3 { width: 420px; height: 420px; bottom: -10%; left: -10%;} /* bottom-left  */
.bg-orb--4 { width: 460px; height: 460px; bottom: -10%; right: -10%;} /* bottom-right */

/* Ensure all page content sits above orbs */
.nav, main, .footer { position: relative; z-index: 1; }

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body-md);
  color: var(--on-surface);
  background-color: var(--surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  /* Subtle mesh gradient — obsidian base with faint chromatic energy */
  background-image:
    radial-gradient(ellipse at 15% 50%, rgba(202, 152, 255, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(92, 251, 178, 0.03) 0%, transparent 45%),
    radial-gradient(ellipse at 60% 85%, rgba(255, 113, 98, 0.02) 0%, transparent 40%);
  background-attachment: fixed;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse at 15% 50%, rgba(124, 58, 237, 0.04) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(5, 150, 105, 0.03) 0%, transparent 45%);
}

/* ── Nav ──────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 4rem;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--on-surface);
}

.nav-logo-icon {
  width: 3.5rem;
  height: 3.5rem;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.nav-logo-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--on-surface);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  list-style: none;
}

.nav-links a {
  font-family: var(--font-display);
  font-size: var(--text-label-md);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--on-surface-variant);
  transition: color var(--transition-fast);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--on-surface);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ── Main ─────────────────────────────────────────────────── */
main {
  flex: 1;
  padding-top: 4rem; /* nav height */
  display: flex;
  flex-direction: column;
}

/* ── Hero stage — stacks all hero views in the same grid cell ── */
.hero-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  /* No min-height here — fullscreen heroes carry their own min-height so
     result heroes can be short and nerds-outer appears right below them. */
}

/* ── Hero / page sections ─────────────────────────────────── */
.hero {
  /* All heroes share grid cell [1,1] so they overlay each other.
     During a transition the leaving hero stays in flow as a grid sibling —
     the grid row height = max(leaving, entering) so content is never clipped.
     After the leave finishes (display:none) the row collapses to the new hero. */
  grid-row: 1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateZ(0); /* promote to GPU composite layer */
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-8);
}

/* Fullscreen heroes fill the viewport and center their content.
   Applied to idle, loading, url_pick, error — NOT result states,
   so nerds-outer sits right below result cards without a huge gap. */
.hero--fullscreen {
  /* 4rem nav + ~4.5rem footer so the footer stays visible without scrolling */
  min-height: calc(100vh - 8.5rem);
}

.hero--top {
  justify-content: flex-start;
  padding-top: var(--space-16);
}

.container {
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container--narrow {
  max-width: 42rem;
}

/* ── Content pages (how it works, privacy) ────────────────── */
.content-page {
  padding: var(--space-16) var(--space-6) var(--space-20);
}

.content-page h1 {
  font-family: var(--font-display);
  font-size: var(--text-display-md);
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
}

.content-page .lead {
  font-size: var(--text-title-md);
  color: var(--on-surface-variant);
  margin-bottom: var(--space-12);
  line-height: 1.6;
}

.content-page h2 {
  font-family: var(--font-display);
  font-size: var(--text-headline);
  font-weight: 600;
  color: var(--on-surface);
  margin: var(--space-12) 0 var(--space-4);
  letter-spacing: -0.01em;
}

.content-page h3 {
  font-family: var(--font-display);
  font-size: var(--text-title-lg);
  font-weight: 500;
  color: var(--on-surface);
  margin: var(--space-8) 0 var(--space-3);
}

.content-page p {
  color: var(--on-surface-variant);
  line-height: 1.7;
  margin-bottom: var(--space-4);
}

.content-page ul,
.content-page ol {
  color: var(--on-surface-variant);
  line-height: 1.7;
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

.content-page li {
  margin-bottom: var(--space-2);
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  padding: var(--space-6) var(--space-6);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.footer-logo {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--tertiary);
  text-decoration: none;
}

.footer-copy {
  font-size: var(--text-body-sm);
  color: var(--on-surface-disabled);
}

.footer-links {
  display: flex;
  gap: var(--space-8);
  list-style: none;
  justify-content: flex-end;
}

.footer-links a {
  font-family: var(--font-display);
  font-size: var(--text-label-md);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--on-surface-variant);
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--on-surface);
}

.footer-relay-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font-display);
  font-size: var(--text-label-md);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--primary);
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}
.footer-relay-link:hover { opacity: 1; }

/* ── Alpine transition helpers ────────────────────────────── */
[x-cloak] { display: none !important; }

/* Enter: decelerate — fast start, soft landing */
.fade-up-enter {
  transition: opacity 0.28s cubic-bezier(0.2, 0, 0, 1),
              transform 0.28s cubic-bezier(0.2, 0, 0, 1);
  will-change: transform, opacity;
}
.fade-up-enter-start {
  opacity: 0;
  transform: translateY(10px);
}
.fade-up-enter-end {
  opacity: 1;
  transform: translateY(0);
}

/* Leave: accelerate — confident exit, out of the way fast.
   Heroes share a grid cell so the leaving hero overlays the entering one
   while both remain in flow — the grid row holds the larger height. */
.fade-up-leave {
  pointer-events: none;
  transition: opacity 0.16s cubic-bezier(0.4, 0, 1, 1),
              transform 0.16s cubic-bezier(0.4, 0, 1, 1);
  will-change: transform, opacity;
}
.fade-up-leave-start {
  opacity: 1;
  transform: translateY(0);
}
.fade-up-leave-end {
  opacity: 0;
  transform: translateY(-8px);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .hero {
    padding: var(--space-12) var(--space-4);
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-6);
  }

  /* Shrink background orbs on mobile — reduces GPU/battery cost
     (blur is expensive; full-desktop sizes cover the entire phone screen) */
  .bg-orb--1 { width: 260px; height: 260px; }
  .bg-orb--2 { width: 220px; height: 220px; }
  .bg-orb--3 { width: 190px; height: 190px; }
  .bg-orb--4 { width: 210px; height: 210px; }
  .bg-orb    { filter: blur(60px); }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  /* Shorten page-transition animations to near-instant so
     state changes still work, they just don't animate */
  .fade-up-enter {
    transition-duration: 0.01ms !important;
  }
  .fade-up-leave {
    transition-duration: 0.01ms !important;
  }

  /* Stop orbs wandering — color changes via CSS var still work */
  .bg-orb {
    transition: none !important;
  }
}
