/* =========================================================================
   Volume Stabilizer — Base: reset, typography, layout primitives, chrome
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: auto; /* Lenis owns scrolling */
}

body {
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--ink-2);
  /* The supplied navy paper texture sits beneath the persistent blue gradients. */
  background-color: var(--bg);
  background-image:
    radial-gradient(78rem 56rem at 5% -12%, rgba(91, 173, 247, 0.16), transparent 68%),
    radial-gradient(66rem 54rem at 104% 86%, rgba(56, 112, 255, 0.12), transparent 70%),
    linear-gradient(var(--paper-wash), var(--paper-wash)),
    var(--paper-texture);
  background-position: center;
  background-repeat: no-repeat;
  /* High-resolution texture can now fill the page without a soft, enlarged crop. */
  background-size: auto, auto, auto, cover;
  background-attachment: fixed;
  overflow-x: hidden;
}

/* When Lenis is active it adds .lenis classes; keep native fallback usable */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

::selection { background: rgba(91, 173, 247, 0.32); color: var(--ink); }

/* ---- Headings ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
h2 { line-height: 1.04; }
h3 { letter-spacing: -0.02em; line-height: 1.1; }
p { text-wrap: pretty; }

strong { color: var(--ink); font-weight: 600; }

/* =========================================================================
   Layout primitives
   ========================================================================= */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: clamp(80px, 12vh, 180px);
  z-index: var(--z-content);
}

.lead {
  font-size: var(--t-lead);
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: -0.01em;
}

/* Gradient ink for accent words */
.grad-text {
  background: var(--brand-grad);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--ink-inv);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.95em 1.6em;
  border-radius: var(--r-pill);
  font-weight: 500;
  font-size: var(--t-sm);
  letter-spacing: -0.01em;
  color: var(--btn-fg);
  background: var(--btn-bg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
  will-change: transform;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn--brand {
  --btn-fg: #fff;
  background: var(--btn-grad); /* darker stops so white label clears AA */
  box-shadow: var(--shadow-glow-blue);
}
.btn--brand:hover { box-shadow: 0 22px 60px rgba(56, 112, 255, 0.36); }

/* ---- Official "Download on the Mac App Store" badge ----------------------
   Apple's lockups: black on light surfaces, white on dark. The HERO badge sits
   on the themed page background, so it swaps with the theme (two <img>s toggled
   below). Both the HERO and PRICING badges sit on page-themed surfaces, so both
   use the two-<img> swap (black on light, white on dark). Don't alter the art. */
.btn-appstore {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  border-radius: 9px;
  transition: transform var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
  will-change: transform;
}
.btn-appstore:hover { transform: translateY(-2px); opacity: 0.9; }
.btn-appstore:active { transform: translateY(0) scale(0.98); }
.appstore-badge { display: block; height: 48px; width: auto; }
.appstore-badge--dark { display: none; }
:root[data-theme="dark"] .appstore-badge--light { display: none; }
:root[data-theme="dark"] .appstore-badge--dark { display: block; }

/* =========================================================================
   Top nav (minimizes on scroll — see js)
   ========================================================================= */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 2.4vw, 28px) var(--gutter);
  transition: padding var(--dur) var(--ease-out);
}
.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 10px 14px 10px 18px;
  border-radius: var(--r-pill);
  transition: background var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out),
              backdrop-filter var(--dur) var(--ease-out),
              transform var(--dur) var(--ease-out);
}
.nav.is-stuck .nav__inner {
  background: var(--glass);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--hair);
}
.nav__brand { display: inline-flex; align-items: center; gap: 0.42em; font-size: 1.55rem; line-height: 1; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }
/* Match the App Store CTA's 42px control height for a balanced nav. */
.nav__mark { width: 42px; height: 42px; flex: none; }
.nav__links { display: flex; align-items: center; gap: clamp(14px, 2vw, 30px); }
.nav__link { font-size: var(--t-sm); color: var(--ink-2); transition: color var(--dur-fast); }
.nav__link:hover { color: var(--ink); }
.nav__cta { padding: 0.6em 1.15em; gap: 0.45em; }
/* Keep the CTA label crisp white on the gradient in BOTH themes — without this,
   .nav__link's color (var(--ink-2)) wins by cascade order and dims the text
   (dark in light theme, grey in dark theme). Higher specificity beats it. */
.nav__cta.btn--brand,
.nav__cta.btn--brand:hover { color: #fff; }
/* Hide the text links on phones but KEEP the App Store CTA reachable */
@media (max-width: 720px) { .nav__links .nav__link:not(.nav__cta) { display: none; } }
/* Collapse the CTA label to just "App Store" on narrow screens */
@media (max-width: 560px) { .nav__cta-full { display: none; } }

/* ---- Appearance toggle — single minimal icon button (Apple-style) ----
   Shows ONE glyph for the current mode: sun in light, moon in dark. Both SVGs
   are stacked in one grid cell and crossfade/rotate on theme change. The swap
   logic + circular View-Transition reveal live in theme.js (untouched). */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0; border: 0;
  border-radius: 50%;
  color: var(--ink-2);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.theme-toggle:hover { background: rgba(125, 125, 125, 0.14); color: var(--ink); }
.theme-toggle__icon {
  grid-area: 1 / 1;                 /* stack both glyphs in the same cell */
  width: 18px; height: 18px;
  transition: opacity 0.3s var(--ease-out), transform 0.45s var(--ease-out);
}
/* Visible glyph reflects the CURRENT theme: sun=light, moon=dark. */
.theme-toggle__sun  { opacity: 1; transform: rotate(0) scale(1); }
.theme-toggle__moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }
:root[data-theme="dark"] .theme-toggle__sun  { opacity: 0; transform: rotate(90deg) scale(0.4); }
:root[data-theme="dark"] .theme-toggle__moon { opacity: 1; transform: rotate(0) scale(1); }
@media (prefers-reduced-motion: reduce) { .theme-toggle__icon { transition: opacity 0.2s linear; } }
/* the toggle stays visible on phones (it's not a .nav__link) */

/* =========================================================================
   Accessibility helpers
   ========================================================================= */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 4px;
}
.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 10000;
  transform: translateY(-160%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* Respect reduced motion globally; JS also checks this */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
