/* Erudity landing — global styles */

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--page-fg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .35s ease, color .35s ease;
}

/* Theme variables */
body[data-theme="light"] {
  --page-bg: var(--surface-paper);
  --page-fg: var(--ink-900);
  --card-bg: var(--surface-card);
  --card-fg: var(--ink-900);
  --card-sub: var(--ink-500);
  --hairline: rgba(98, 23, 174, 0.12);
  --accent: var(--purple-800);          /* deep purple on light */
  --accent-soft: var(--purple-100);
  --muted: var(--ink-500);
  --muted-pale: var(--ink-300);                  /* #C5C5C5 — matches app paleText (light) */
  --pill-bg: rgb(230, 205, 255);                 /* #E6CDFF — matches app TopicPill (light) */
  --pill-fg: rgb(111, 28, 195);                  /* #6F1CC3 — matches app TopicPill (light) */
  --shadow-card: 0 8px 28px -10px rgba(98,23,174,0.18), 0 2px 6px rgba(20,12,40,0.06);
  --shadow-card-lg: 0 28px 60px -20px rgba(98,23,174,0.30), 0 8px 18px rgba(20,12,40,0.08);
  --grain-strength: 0.04;
}
body[data-theme="dark"] {
  /* Match the Flutter app's neutral dark palette (lib/core/theme/app_colors.dart) */
  --page-bg: var(--surface-night);          /* #121212 */
  --page-fg: var(--ink-100);                /* #E0E0E0 */
  --card-bg: var(--surface-dusk);           /* #1E1E1E */
  --card-fg: var(--ink-100);
  --card-sub: var(--ink-400);               /* #9E9E9E */
  --hairline: rgb(62, 62, 62);              /* #3E3E3E */
  --accent: var(--purple-400);              /* #B070E0 */
  --accent-soft: rgba(176, 112, 224, 0.14);
  --muted: var(--ink-400);
  --muted-pale: rgb(90, 90, 90);            /* #5A5A5A — matches app paleText (dark) */
  --pill-bg: rgba(176, 112, 224, 0.18);     /* tinted purple wash on dark */
  --pill-fg: var(--purple-300);             /* readable purple on dark */
  --shadow-card: 0 12px 30px -12px rgba(0,0,0,0.55), 0 2px 4px rgba(0,0,0,0.35);
  --shadow-card-lg: 0 30px 70px -20px rgba(0,0,0,0.7), 0 10px 24px rgba(0,0,0,0.4);
  --grain-strength: 0.06;
}

/* HEADER */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: color-mix(in srgb, var(--page-bg) 72%, transparent);
  border-bottom: 1px solid var(--hairline);
  transition: background-color .35s ease, border-color .35s ease;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
  color: var(--page-fg);
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-word {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.18em;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.theme-toggle {
  appearance: none;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--page-fg);
  width: 40px; height: 40px;
  border-radius: 999px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.theme-toggle:hover { background: var(--accent-soft); }
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle svg { width: 18px; height: 18px; }

.header-cta {
  appearance: none;
  border: none;
  background: var(--accent);
  color: white;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.header-cta:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -6px color-mix(in srgb, var(--accent) 60%, transparent); }
.header-cta:active { transform: translateY(0) scale(0.98); }

/* HERO */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 140px 24px 80px;
  position: relative;
}
.hero-eyebrow {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 28px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.hero-eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: .55; }
}
.hero h1 {
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: clamp(48px, 9vw, 124px);
  line-height: 0.95;
  letter-spacing: -0.025em;
  max-width: 1300px;
}
.hero h1 .accent {
  color: var(--accent);
  display: block;
  font-weight: 900;
}
.hero-sub {
  margin-top: 32px;
  font-size: clamp(15px, 3.4vw, 22px);
  color: var(--muted);
  max-width: 980px;
  font-weight: 400;
  line-height: 1.5;
}
.hero-scroll {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: .9;
}
.hero-scroll .arrow {
  width: 2px; height: 64px;
  background: linear-gradient(to bottom, var(--muted), transparent);
  animation: scrollHint 2s ease-in-out infinite;
}
@keyframes scrollHint {
  0% { transform: scaleY(0); transform-origin: top; }
  50% { transform: scaleY(1); transform-origin: top; }
  51% { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* HERO STORE BADGES
   Apple/Google badge guidelines: no recoloring, no clipping, no border-radius,
   no filter effects; set height only and let width auto-scale to preserve
   proportions. The 16px flex gap satisfies both Apple's (~1/10 of badge
   height) and Google's (~1/4 of badge height) clear-space requirements. */
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 36px;
}
.hero-badges a {
  display: block;
  transition: transform .2s ease, opacity .2s ease;
}
.hero-badges a:hover { transform: translateY(-2px); }
.hero-badges a:active { transform: translateY(0); opacity: 0.85; }
.hero-badges img {
  display: block;
  height: 52px;
  width: auto;
}

/* ROULETTE SECTION */
.roulette-section {
  padding: 120px 24px 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.section-eyebrow {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}
.roulette-question {
  font-size: clamp(28px, 5.5vw, 80px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.0;
  margin-bottom: 56px;
}
.roulette-shell {
  position: relative;
  width: min(1100px, 96vw);
  height: 168px;
  border-radius: 32px;
  background: var(--card-bg);
  box-shadow: var(--shadow-card-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline);
}
/* Top/bottom fade masks for the slot reel */
.roulette-shell::before,
.roulette-shell::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 56px;
  z-index: 3;
  pointer-events: none;
}
.roulette-shell::before { top: 0; background: linear-gradient(to bottom, var(--card-bg), transparent); }
.roulette-shell::after  { bottom: 0; background: linear-gradient(to top, var(--card-bg), transparent); }

/* highlight band */
.roulette-band {
  position: absolute;
  left: 16px; right: 16px;
  top: 50%;
  transform: translateY(-50%);
  height: 84px;
  border-radius: 18px;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  z-index: 1;
}
.roulette-reel {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.roulette-strip {
  position: absolute;
  left: 0; right: 0;
  /* Place the strip so its first row is centered in the band: top = mid - half-item */
  top: calc(50% - 42px);
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.roulette-band-clip {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Match .roulette-band's horizontal inset so accented text stays inside the band */
  clip-path: inset(calc(50% - 42px) 16px calc(50% - 42px) 16px);
  z-index: 3;
}
.roulette-item-accent { color: var(--accent) !important; opacity: 1 !important; }
.roulette-item {
  position: relative;
  width: 100%;
  height: 84px;
  flex: 0 0 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 2.6vw, 36px);
  font-weight: 900;
  letter-spacing: -0.01em;
  padding: 0 16px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  color: var(--muted);
  opacity: 0.55;
  will-change: transform, opacity;
}
.roulette-item.center { color: var(--accent); }
.roulette-item.dim { color: var(--muted); opacity: 0.45; }

.roulette-cta {
  margin-top: 56px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.btn {
  appearance: none;
  border: none;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 16px;
  padding: 16px 28px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .25s ease, background .2s ease;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -6px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-ghost {
  background: transparent;
  color: var(--page-fg);
  border: 1.5px solid var(--hairline);
}
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-ghost:active { transform: scale(0.98); }

/* SCROLL CARDS SECTION */
.cards-section {
  position: relative;
  padding: 0;
}
.cards-track {
  position: relative;
  /* lvh = "large" viewport height: the URL-bar-hidden value. Stable as the
     mobile address bar shows/hides while scrolling, so the stack doesn't jump. */
  height: 400vh;       /* fallback for older browsers */
  height: 400lvh;
}
.cards-stage {
  position: sticky;
  top: 0;
  height: 100vh;       /* fallback for older browsers */
  height: 100lvh;      /* stable across URL-bar toggles — see .cards-track note */
  width: 100%;
  perspective: 1400px;
  transform-style: preserve-3d;
  overflow: hidden;
  /* Flex column: headline pinned at the top, deck fills the remaining space.
     This lets the two never overlap regardless of viewport height. */
  display: flex;
  flex-direction: column;
  isolation: isolate;  /* clean compositing scope without `contain: paint` */
}
/* Wraps the absolute-positioned cards so the stack stays centered in the
   space below the headline, never under it. */
.cards-deck {
  position: relative;
  flex: 1;
  width: 100%;
  transform-style: preserve-3d;  /* keep 3D context alive for child .fly-card transforms */
}
.fly-card {
  position: absolute;
  left: 50%;
  top: 50%;
  /* Initial sizing for first paint. JS in FlyingCards overrides width/height
     via inline style on mount/resize. */
  width: min(380px, 26vw, 30vh);
  height: min(680px, 46vw, 54vh);
  min-width: 180px;
  min-height: 320px;
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--shadow-card-lg);
  border: 1px solid var(--hairline);
  padding: 16px;
  display: flex;
  flex-direction: column;
  /* All cards stack at the exact same centered position; only the active one
     is visible. Cards yet to be reached default to opacity 0 (hidden behind
     the active card). The CSS transition is the animation — fixed-duration
     and smooth, so flipping classes on scroll always plays to completion.
     rotate(0deg) is explicit so the transition to .is-gone (which adds a
     non-zero rotate) interpolates as a continuous chain. */
  transform: translate3d(-50%, -50%, 0) rotate(0deg);
  opacity: 0;
  transition:
    transform 700ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity  600ms ease-out;
  will-change: transform, opacity;
  pointer-events: none;
}
/* Active card — currently on top of the stack, fully visible. */
.fly-card.is-active {
  opacity: 1;
}
/* Gone — already flown off-screen along its diagonal. --exit-x and --exit-rz
   are set as inline style per card so each card has a different trajectory. */
.fly-card.is-gone {
  transform: translate3d(
    calc(-50% + var(--exit-x, 0vw)),
    calc(-50% - 110vh),
    0
  ) rotate(var(--exit-rz, 0deg));
  opacity: 0;
}
.fly-card-topic {
  align-self: flex-start;
  background: var(--pill-bg);
  color: var(--pill-fg);
  font: 700 14px/1 var(--font-sans);
  padding: 6px 12px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0;
}
.fly-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 0 24px;
  text-align: center;
}
.fly-card-label {
  font: 800 18px/1 var(--font-sans);
  letter-spacing: 1.4px;
  color: var(--muted-pale);
  text-transform: uppercase;
}
.fly-card-q {
  font: 700 22px/1.35 var(--font-sans);
  color: var(--card-fg);
}
/* Headline pinned at the top of the cards stage. Normal flow inside the
   flex-column stage — top padding clears the fixed page header. */
.cards-intro-pinned {
  flex-shrink: 0;
  width: 100%;
  max-width: 1100px;
  padding: 14vh 24px 0;
  margin: 0 auto;
  text-align: center;
  pointer-events: none;
  z-index: 1;
  will-change: opacity;
}

/* DOWNLOAD SECTION
   Same vertical rhythm as the previous mailing section so the page's overall
   pacing (post-cards-animation → call-to-action → footer) is unchanged. */
.download {
  padding: 200px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 5;
  background: var(--page-bg);
}
.download h2 {
  font-size: clamp(30px, 6vw, 88px);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.0;
  margin-bottom: 22px;
  max-width: 1100px;
}
.download h2 .accent { color: var(--accent); }
.download-sub {
  font-size: clamp(16px, 1.3vw, 20px);
  color: var(--muted);
  max-width: 520px;
  margin-bottom: 48px;
}
.download-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 20px;
}
.download-badges a {
  display: block;
  transition: transform .2s ease, opacity .2s ease;
}
.download-badges a:hover { transform: translateY(-2px); }
.download-badges a:active { transform: translateY(0); opacity: 0.85; }
.download-badges img {
  display: block;
  height: 60px;
  width: auto;
}

/* FOOTER */
.site-footer {
  padding: 60px 40px 40px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 32px;
  background: var(--page-bg);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
}
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 360px;
}
.footer-brand .brand { padding: 0; }
.footer-brand p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}
.footer-links {
  display: flex;
  gap: 56px;
  flex-wrap: wrap;
}
.footer-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-col h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.footer-col a {
  color: var(--page-fg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color .2s ease;
}
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
  flex-wrap: wrap;
  gap: 12px;
}

/* RESPONSIVE */
@media (max-width: 720px) {
  .site-header { padding: 16px 20px; }
  .header-cta { display: none; }
  .footer-links { gap: 32px; }
  .footer-row { flex-direction: column; }

  /* Store badges shrink a touch on phones so they don't dominate the hero,
     and the dedicated download section's badges stay comfortably tappable. */
  .hero-badges img { height: 44px; }
  .download-badges img { height: 52px; }

  /* Roulette CTA row: stack the two buttons full-width so each can keep nowrap text. */
  .roulette-cta { flex-direction: column; gap: 12px; align-items: stretch; width: 100%; max-width: 320px; }
  .roulette-cta .btn { width: 100%; justify-content: center; padding: 14px 20px; font-size: 15px; }

  /* Cards proportional and tighter on mobile. Same JS-overrides-CSS strategy
     as desktop — initial CSS values for first paint, JS sets actual size on
     mount. Aspect 36/62 ≈ 0.58.
     On mobile we also pin the card near the top of the deck (small fixed gap
     below the headline) instead of centering it. With centered + flex:1 deck,
     tall phones leave ~110px of dead space between the headline and the card,
     which felt like the cards had been pushed to the bottom of the screen. */
  .fly-card {
    /* Width-only sizing on mobile — vh would resize the card every time the
       browser's address bar shows/hides during scroll. */
    width: min(320px, 68vw);
    height: min(560px, 120vw);
    min-width: 180px;
    min-height: 280px;
    padding: 14px;
    top: 32px;
    transform: translate3d(-50%, 0, 0) rotate(0deg);
  }
  .fly-card.is-gone {
    transform: translate3d(calc(-50% + var(--exit-x, 0vw)), -110vh, 0)
               rotate(var(--exit-rz, 0deg));
  }
  .fly-card-topic { font-size: 12px; padding: 4px 10px; }
  .fly-card-label { font-size: 14px; }
  .fly-card-q    { font-size: 18px; }
  .fly-card-body { gap: 24px; padding: 0 16px; }

  /* Symmetric hero padding — content visually centers on phones (instead of
     the desktop 140px/80px which sits 30px below center on small viewports). */
  .hero { padding: 80px 24px 80px; }

  /* Tighter download section on phones, less space before the footer. */
  .download { padding: 120px 24px 60px; }

  /* Cards-intro headline: tighter padding + smaller header clearance on phones.
     +16px on top so the eyebrow doesn't crowd the fixed header. */
  .cards-intro-pinned { padding: calc(10vh + 16px) 16px 0; }

  /* Disable 3D depth on mobile to avoid Chromium-on-Android tile-rasterization
     bugs with composited 3D layers. The animation still translates/scales/
     rotateZ — just without perspective and without per-card composite layers. */
  .cards-stage { perspective: none; transform-style: flat; }
  .cards-deck  { transform-style: flat; }
  .fly-card    { transform-style: flat; will-change: auto; }
}
