/* Abditex — site stylesheet
 *
 * Design system tokens, base element styles, and shared layout primitives.
 *
 * Sections:
 *   0. Fonts
 *   1. Tokens (custom properties)
 *   2. Reset and base
 *   3. Typography
 *   4. Layout primitives
 *   5. Components
 *   6. Utilities
 *   7. Accessibility
 */

/* ============================================================
 * 0. Fonts — Satoshi (Fontshare). Self-hosted, subsetted WOFF2.
 *    Place files in /assets/fonts/. Until they exist, the site falls
 *    back to the system stack declared in --font-body.
 * ============================================================ */

@font-face {
  font-family: "Satoshi";
  src: url("/assets/fonts/Satoshi-Variable.woff2") format("woff2-variations"),
       url("/assets/fonts/Satoshi-Variable.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
 * 1. Tokens
 * ============================================================ */

:root {
  /* Backgrounds */
  --bg-primary: #0C0C0E;
  --bg-secondary: #141418;
  --bg-tertiary: #1C1C22;

  /* Text */
  --text-primary: #F0EDE8;
  --text-secondary: #9A9690;
  --text-tertiary: #6B6660;

  /* Accent */
  --accent-gold: #C9A84C;
  --accent-gold-hover: #D4B65E;
  --accent-gold-muted: rgba(201, 168, 76, 0.15);

  /* Borders */
  --border-subtle: rgba(240, 237, 232, 0.08);
  --border-visible: rgba(240, 237, 232, 0.15);

  /* Status */
  --color-success: #4A9D6E;
  --color-error: #C75450;

  /* Type — Satoshi for both display and body; weight carries the hierarchy.
   * Falls back to a system sans stack until the WOFF2 lands in /assets/fonts/. */
  --font-display: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI",
                  system-ui, sans-serif;
  --font-body: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI",
               system-ui, sans-serif;

  /* Type scale (desktop). Mobile overrides below. */
  --fs-hero: 80px;
  --fs-h1: 56px;
  --fs-h2: 40px;
  --fs-h3: 28px;
  --fs-body-lg: 22px;
  --fs-body: 19px;
  --fs-small: 15px;
  --fs-micro: 13px;

  --lh-tight: 1.1;
  --lh-snug: 1.25;
  --lh-body: 1.65;

  --ls-display: -0.02em;
  --ls-body: 0;
  --ls-caps: 0.08em;

  /* Spacing — 8px grid */
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 32px;
  --s-6: 48px;
  --s-8: 64px;
  --s-12: 96px;
  --s-16: 128px;

  /* Layout */
  --content-max: 1200px;
  --section-pad-y: 120px;
  --section-pad-x: 32px;

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 160ms;
  --dur-med: 280ms;
}

@media (max-width: 768px) {
  :root {
    --fs-hero: 44px;
    --fs-h1: 36px;
    --fs-h2: 28px;
    --fs-h3: 22px;
    --fs-body-lg: 19px;
    --fs-body: 17px;
    --section-pad-y: 64px;
    --section-pad-x: 24px;
  }
}

/* ============================================================
 * 2. Reset and base
 * ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; height: auto; }

a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-visible);
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) var(--ease-out),
              text-decoration-color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--accent-gold); text-decoration-color: var(--accent-gold); }

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--s-6) 0;
}

/* ============================================================
 * 3. Typography
 * ============================================================ */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  margin: 0 0 var(--s-3);
  color: var(--text-primary);
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: -0.01em; }
h4 { font-size: var(--fs-body-lg); font-weight: 600; letter-spacing: 0; }

.hero-heading {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  font-weight: 700;
  margin: 0;
}

p { margin: 0 0 var(--s-3); }
p.lead { font-size: var(--fs-body-lg); color: var(--text-primary); }

small, .text-small { font-size: var(--fs-small); color: var(--text-secondary); }
.text-micro { font-size: var(--fs-micro); color: var(--text-tertiary); }
.text-muted { color: var(--text-secondary); }

.eyebrow {
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 var(--s-2);
}

/* ============================================================
 * 4. Layout primitives
 * ============================================================ */

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding-left: var(--section-pad-x);
  padding-right: var(--section-pad-x);
}

.container-narrow {
  max-width: 760px;
  margin: 0 auto;
  padding-left: var(--section-pad-x);
  padding-right: var(--section-pad-x);
}

section.section {
  padding-top: var(--section-pad-y);
  padding-bottom: var(--section-pad-y);
}

.stack > * + * { margin-top: var(--s-3); }
.stack-lg > * + * { margin-top: var(--s-6); }

/* ============================================================
 * 5. Components
 * ============================================================ */

.btn {
  display: inline-block;
  padding: 14px 28px;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 2px;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.btn-primary {
  background: var(--accent-gold);
  color: var(--bg-primary);
}
.btn-primary:hover { background: var(--accent-gold-hover); color: var(--bg-primary); }
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-visible);
}
.btn-ghost:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

.badge {
  display: inline-block;
  font-size: var(--fs-micro);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 2px;
}
.badge-free { color: var(--text-secondary); border: 1px solid var(--border-visible); }
.badge-pro { color: var(--accent-gold); background: var(--accent-gold-muted); }

/* Store badges — fixed-height, image-based.
 * Placeholder: rendered as simple text frames until SVG assets are added. */
.store-badges {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.store-badge {
  display: inline-flex;
  align-items: center;
  height: 56px;
  padding: 0 24px;
  border: 1px solid var(--border-visible);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--fs-small);
}
.store-badge:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

/* ============================================================
 * 6. Utilities
 * ============================================================ */

.center { text-align: center; }
.gold { color: var(--accent-gold); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
 * 7. Accessibility
 * ============================================================ */

:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
  border-radius: 2px;
}

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

/* ============================================================
 * Site chrome — header, footer
 * ============================================================ */

.site-header {
  padding: var(--s-3) var(--section-pad-x);
  border-bottom: 1px solid var(--border-subtle);
}
.site-header .wordmark {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text-primary);
}
.site-header .wordmark:hover { color: var(--accent-gold); }

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--s-6) var(--section-pad-x);
  color: var(--text-secondary);
  font-size: var(--fs-small);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-3); }
.site-footer nav a { color: var(--text-secondary); text-decoration: none; }
.site-footer nav a:hover { color: var(--accent-gold); }
.site-footer .footer-note { color: var(--text-tertiary); font-size: var(--fs-micro); }

/* ============================================================
 * Homepage — 4-beat problem-solution arc + close
 *
 * Per spec/website/website.md §"Homepage — scroll-driven narrative"
 * and ADR-024 (which superseded ADR-022 §1/§3; the four-beat arc
 * from §2 is retained). Each beat is self-contained: a headline +
 * one app-screenshot panel. Beats 1-3 share a pinned hero section
 * and crossfade as the user scrolls; Beat 4 is normal flow; Beat
 * 5 closes.
 *
 * Without JS / with reduced motion: every beat reads as a normal
 * full-height section in document order with its screenshot shown
 * statically, no choreography.
 * ============================================================ */

.beat {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--section-pad-y) var(--section-pad-x);
  position: relative;
}

/* ---- Hero arc (Beats 1–3) ------------------------------------ */
.hero-arc {
  /* JS sets the height to 3 viewports (or 300vh) and pins
   * .hero-pinned. Without JS, this collapses to one viewport
   * and each beat-frame just stacks below it in flow. */
  position: relative;
  min-height: 100vh;
}
.hero-pinned {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}
.hero-arc.is-enhanced {
  height: 300vh;
}

/* ---- Screenshot panel (shared) ------------------------------- */
.screen-panel { margin: 0; flex: 0 0 auto; }
.screen-panel img {
  display: block;
  width: auto;
  height: min(72vh, 620px);
  max-width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  background: var(--bg-secondary);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
@media (max-width: 900px) {
  .screen-panel img { height: auto; width: min(70vw, 320px); }
}

/* Beat frames stack in the pinned region; scroll.js crossfades
 * whole frames (headline + screenshot together). */
.beat-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--section-pad-y) var(--section-pad-x);
}
.beat-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: var(--s-8);
  max-width: var(--content-max);
  width: 100%;
}
.beat-inner .beat-content { max-width: 640px; }
.beat-inner .screen-panel { justify-self: end; }
@media (max-width: 900px) {
  .beat-inner {
    grid-template-columns: 1fr;
    gap: var(--s-6);
    text-align: center;
    justify-items: center;
  }
  .beat-inner .screen-panel { justify-self: center; }
}

/* In enhanced mode each frame starts hidden; GSAP reveals.
 * In fallback (no JS) all frames stack normally. */
.hero-arc.is-enhanced .beat-frame { opacity: 0; }
.hero-arc.is-enhanced .beat-1-frame { opacity: 1; }

.hero-arc:not(.is-enhanced) .hero-pinned {
  display: block;
  height: auto;
  overflow: visible;
}
.hero-arc:not(.is-enhanced) .beat-frame {
  position: static;
  min-height: 100vh;
}

/* Typography for beat headlines — Apple-assertive sizing. */
.hero-arc .hero-heading,
.beat-4 .hero-heading,
.beat-close .hero-heading {
  font-size: clamp(40px, 7vw, 104px);
  line-height: 1.03;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0;
}
.beat-frame .eyebrow { margin-bottom: var(--s-3); }
.beat-support {
  margin-top: var(--s-4);
  font-size: var(--fs-body-lg);
  color: var(--text-secondary);
  max-width: 560px;
}
@media (max-width: 900px) {
  .beat-support { margin-left: auto; margin-right: auto; }
}

/* Beat 3 — privacy commitments carry the rhetorical weight. */
.beat-3-frame .hero-heading {
  font-size: clamp(32px, 5vw, 72px);
  margin-bottom: var(--s-4);
}
.commitments {
  list-style: none;
  padding: 0;
  margin: var(--s-4) 0 0;
  display: grid;
  gap: var(--s-3);
  text-align: left;
  max-width: 560px;
}
@media (max-width: 900px) {
  .commitments { margin-left: auto; margin-right: auto; }
}
.commitments li {
  font-family: var(--font-display);
  font-size: clamp(16px, 1.6vw, 21px);
  line-height: 1.4;
  color: var(--text-secondary);
  padding-left: var(--s-3);
  border-left: 2px solid var(--accent-gold-muted);
}

/* ---- Beat 4 — Pro resolution --------------------------------- */
.beat-4 {
  background: var(--bg-primary);
}
.beat-4-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: var(--s-8);
}
.beat-4-layout .screen-panel { justify-self: center; }
@media (max-width: 900px) {
  .beat-4-layout {
    grid-template-columns: 1fr;
    gap: var(--s-6);
    text-align: center;
    justify-items: center;
  }
}
.beat-4-copy .beat-support {
  max-width: 560px;
  margin: var(--s-3) 0 0;
}
.beat-4-copy .store-badges { margin-top: var(--s-6); }
@media (max-width: 900px) {
  .beat-4-copy .beat-support { margin-left: auto; margin-right: auto; }
  .beat-4-copy .store-badges { justify-content: center; }
}

/* ---- Beat 5 — Close ------------------------------------------ */
.beat-close {
  flex-direction: column;
  text-align: center;
}
.beat-close .store-badges {
  justify-content: center;
  margin-top: var(--s-6);
}
.beat-close .close-note {
  color: var(--text-secondary);
  margin-top: var(--s-4);
}

/* ---- Reduced motion ------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .hero-arc.is-enhanced { height: auto; }
  .hero-arc.is-enhanced .hero-pinned { height: auto; display: block; overflow: visible; }
  .hero-arc.is-enhanced .beat-frame {
    position: static;
    opacity: 1 !important;
    min-height: 100vh;
  }
}
