/* Lexo landing page — design tokens sourced from /design.md */

:root {
  /* Colors — light */
  --primary: #E2613A;
  --on-primary: #FFFFFF;
  --primary-container: #FBE9E1;
  --on-primary-container: #7A2A12;
  --surface: #FAFAF7;
  --on-surface: #15161A;
  --on-surface-variant: #6B6F76;
  --surface-container-lowest: #FFFFFF;
  --surface-container-high: #F5F4EF;
  --outline: #E4E2DD;
  --outline-variant: #EFEDE8;
  --lang-en-text: #1F3A8A;
  --lang-en-bg: #E5ECFB;
  --lang-pt-text: #7A2A12;
  --lang-pt-bg: #FBE9E1;
  --hero-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.027);

  /* Type families */
  --font-display: 'Fraunces', 'Times New Roman', Georgia, serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Spacing scale (4-based) */
  --s-xs: 4px;
  --s-sm: 8px;
  --s-md: 12px;
  --s-lg: 16px;
  --s-xl: 20px;
  --s-xxl: 24px;
  --s-xxxl: 32px;
  --s-xxxxl: 48px;
  --s-xxxxxl: 64px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #F08461;
    --on-primary: #3A1B11;
    --primary-container: #3A1B11;
    --on-primary-container: #FBD8C6;
    --surface: #0F1012;
    --on-surface: #F2F1ED;
    --on-surface-variant: #9A9DA4;
    --surface-container-lowest: #0A0B0D;
    --surface-container-high: #1F2024;
    --outline: #2A2B30;
    --outline-variant: #1F2024;
    --lang-en-text: #B8C7F0;
    --lang-en-bg: #1B2547;
    --lang-pt-text: #FBD8C6;
    --lang-pt-bg: #3A1B11;
    --hero-card-shadow: none;
  }
}

* { box-sizing: border-box; }

html {
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-size: 15px;
  line-height: 22px;
  font-weight: 400;
}

a {
  color: var(--primary);
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--s-xl);
}

/* Wider container for the hero section so the demo card can sit beside the
   text on desktop. Prose sections stay at .container's narrower width for
   readable line length. */
.container-wide {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--s-xl);
}

/* Header */
.site-header {
  padding-top: var(--s-xxl);
  padding-bottom: var(--s-xl);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-lg);
  text-decoration: none;
  color: var(--on-surface);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.brand img {
  width: 72px;
  height: 72px;
  display: block;
}

/* Typography helpers */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 1.32px;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  margin: 0 0 var(--s-lg);
}

.display {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 48px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--on-surface);
  margin: 0 0 var(--s-xxl);
}

.lead {
  font-size: 17px;
  line-height: 26px;
  color: var(--on-surface-variant);
  margin: 0 0 var(--s-xxxl);
  max-width: 52ch;
}

/* Hero — single column on mobile, side-by-side with the demo card on desktop */
.hero-grid {
  padding-top: var(--s-xxxl);
  padding-bottom: var(--s-xxxxxl);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-xxxxl);
  align-items: center;
}

@media (min-width: 840px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--s-xxxxxl);
    padding-top: var(--s-xxxxxl);
    padding-bottom: 96px;
  }
}

.hero-text .lead {
  margin-bottom: var(--s-xxl);
}

.cta-row {
  margin: 0;
}

.pill-coming-soon {
  display: inline-flex;
  align-items: center;
  gap: var(--s-sm);
  padding: 14px 20px;
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.075px;
  cursor: default;
  user-select: none;
}

/* Demo card stack — mirrors the app's review flow:
   1. Card rises from peek-near to front (source visible).
   2. The whole card flips on its Y-axis (200ms — design.md `switcher`).
   3. Card sits in front with target visible.
   4. Card swipes off (380ms — design.md `cardSettleLong`) — right = Easy,
      left = Hard. Hard/Easy buttons live below the stack and stay static
      (matching ReviewCardStage: tapping a button triggers the same fly-off).
   5. The next card rises into place; the new peek-far card fades in behind.
   Two peek cards visible at all times. Pure CSS, no JS. */

.card-area {
  display: flex;
  flex-direction: column;
  gap: var(--s-lg);
}

.card-stack {
  position: relative;
  min-height: 220px;
}

@media (min-width: 840px) {
  .card-stack {
    min-height: 240px;
  }
}

/* The slot owns position + rise/swipe motion. Anchored to the bottom of the
   stack so peek cards can shift upward into the room above the front card. */
.card-slot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 196px;
  perspective: 1200px;
  animation: card-cycle 9s infinite ease-out;
  will-change: transform, opacity;
}

@media (min-width: 840px) {
  .card-slot { height: 216px; }
}

.card-slot--1 { animation-delay: 0s; }
.card-slot--2 {
  animation-delay: -3s;
  animation-name: card-cycle-left;
}
.card-slot--3 { animation-delay: -6s; }

/* The 3D flipper holds both card faces; it rotates around Y to flip. */
.card-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  animation: card-flip 9s infinite ease-in-out;
  will-change: transform;
}

.card-slot--1 .card-flipper { animation-delay: 0s; }
.card-slot--2 .card-flipper { animation-delay: -3s; }
.card-slot--3 .card-flipper { animation-delay: -6s; }

/* Both faces of the card share the visible card styling. */
.card-content {
  position: absolute;
  inset: 0;
  background: var(--surface-container-lowest);
  border-radius: var(--r-xl);
  padding: var(--s-xxl);
  box-shadow: var(--hero-card-shadow);
  display: flex;
  flex-direction: column;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

@media (min-width: 840px) {
  .card-content {
    padding: var(--s-xxxl);
  }
}

.card-content--back {
  transform: rotateY(180deg);
}

.card-pills {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-bottom: var(--s-xxl);
  flex-shrink: 0;
}

.card-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
}

.card-body .card-input,
.card-body .card-result {
  margin: 0;
}

.card-actions {
  display: flex;
  gap: var(--s-sm);
  flex-shrink: 0;
}

.card-btn {
  flex: 1;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: -0.075px;
  text-align: center;
  user-select: none;
}

.card-btn--hard {
  background: var(--surface-container-high);
  color: var(--on-surface);
}

.card-btn--easy {
  background: var(--primary);
  color: var(--on-primary);
}

button.card-btn {
  border: 0;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 120ms ease-out, transform 120ms ease-out;
}

button.card-btn:hover {
  transform: translateY(-1px);
}

button.card-btn:active {
  transform: translateY(0);
}

button.card-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button.card-btn--easy:hover {
  background: var(--inverse-primary, var(--primary));
  filter: brightness(0.95);
}

button.card-btn--hard:hover {
  background: var(--surface-container-highest);
}

/* Interactive mode — engaged on first click. Replaces auto-keyframes with
   class-driven positions + transitions. The script in /app.js toggles
   .is-front / .is-peek-near / .is-peek-far / .is-swiping-{right,left} on
   slots and .is-flipped on the front slot's flipper. */
.card-area.is-interactive .card-slot {
  animation: none;
  transition: transform 220ms ease-out, opacity 220ms ease-out;
}

.card-area.is-interactive .card-flipper {
  animation: none;
  transition: transform 200ms ease-in-out;
}

.card-area.is-interactive .card-slot.is-front {
  transform: translateY(0) scale(1);
  opacity: 1;
  z-index: 3;
}

.card-area.is-interactive .card-slot.is-front .card-content {
  cursor: pointer;
}

.card-area.is-interactive .card-slot.is-peek-near {
  transform: translateY(-12px) scale(0.96);
  opacity: 0.65;
  z-index: 2;
  pointer-events: none;
}

.card-area.is-interactive .card-slot.is-peek-far {
  transform: translateY(-24px) scale(0.92);
  opacity: 0.4;
  z-index: 1;
  pointer-events: none;
}

.card-area.is-interactive .card-slot.is-swiping-right {
  transform: translateX(110%) rotate(7deg);
  opacity: 0;
  transition: transform 380ms ease-out, opacity 380ms ease-out;
  z-index: 3;
}

.card-area.is-interactive .card-slot.is-swiping-left {
  transform: translateX(-110%) rotate(-7deg);
  opacity: 0;
  transition: transform 380ms ease-out, opacity 380ms ease-out;
  z-index: 3;
}

.card-area.is-interactive .card-flipper.is-flipped {
  transform: rotateY(180deg);
}

/* Slot motion over a 9s cycle. Each card moves through:
   peek-far (z=1) → peek-near (z=2) → front (z=3) → swipe off → invisible reset.
   With three slots staggered -3s and -6s, the stack always shows
   one front card plus two peeks behind. */
@keyframes card-cycle {
  /* Snap into peek-far position at the loop boundary (opacity 0 so the
     reset from the previous swipe-off is invisible). */
  0% {
    transform: translateY(-24px) scale(0.92);
    opacity: 0;
    z-index: 1;
  }
  2%, 32% {
    transform: translateY(-24px) scale(0.92);
    opacity: 0.4;
    z-index: 1;
  }
  /* Shift to peek-near (~180ms). */
  34%, 65% {
    transform: translateY(-12px) scale(0.96);
    opacity: 0.65;
    z-index: 2;
  }
  /* Rise to front (~180ms). */
  67%, 95% {
    transform: translateY(0) scale(1);
    opacity: 1;
    z-index: 3;
  }
  /* Swipe off right (Easy) — 360ms, ≈ design.md cardSettleLong (380ms). */
  99% {
    transform: translateX(110%) rotate(7deg);
    opacity: 0;
    z-index: 3;
  }
  100% {
    transform: translateY(-24px) scale(0.92);
    opacity: 0;
    z-index: 1;
  }
}

/* Same as card-cycle but swipes left (Hard) instead of right (Easy). */
@keyframes card-cycle-left {
  0% {
    transform: translateY(-24px) scale(0.92);
    opacity: 0;
    z-index: 1;
  }
  2%, 32% {
    transform: translateY(-24px) scale(0.92);
    opacity: 0.4;
    z-index: 1;
  }
  34%, 65% {
    transform: translateY(-12px) scale(0.96);
    opacity: 0.65;
    z-index: 2;
  }
  67%, 95% {
    transform: translateY(0) scale(1);
    opacity: 1;
    z-index: 3;
  }
  99% {
    transform: translateX(-110%) rotate(-7deg);
    opacity: 0;
    z-index: 3;
  }
  100% {
    transform: translateY(-24px) scale(0.92);
    opacity: 0;
    z-index: 1;
  }
}

/* Flipper Y-rotation. Source held 67-80% (≈1.17s), flip 80-82% (~180ms,
   matching design.md `switcher: 200ms`), target held 82-95% (≈1.17s).
   Snap-reset 99→0% happens while the card is off-screen at opacity 0. */
@keyframes card-flip {
  0%, 80% { transform: rotateY(0deg); }
  82%, 100% { transform: rotateY(180deg); }
}

@media (prefers-reduced-motion: reduce) {
  /* Auto-mode fallback: static single card, no flip/swipe loop. */
  .card-area:not(.is-interactive) .card-stack { min-height: 0; }
  .card-area:not(.is-interactive) .card-slot {
    position: static;
    animation: none;
    opacity: 1;
    transform: none;
  }
  .card-area:not(.is-interactive) .card-flipper {
    animation: none;
    transform: none;
    height: auto;
  }
  .card-area:not(.is-interactive) .card-content {
    position: static;
  }
  .card-area:not(.is-interactive) .card-content--back { display: none; }
  .card-area:not(.is-interactive) .card-slot--2,
  .card-area:not(.is-interactive) .card-slot--3 { display: none; }

  /* Interactive-mode fallback: keep functionality but kill the transitions
     so flips and swipes are instant. */
  .card-area.is-interactive .card-slot,
  .card-area.is-interactive .card-flipper {
    transition: none;
  }
}

.lang-pill--neutral {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}

.card-pills {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
  margin-bottom: var(--s-xxl);
}

.lang-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.lang-pill--en {
  background: var(--lang-en-bg);
  color: var(--lang-en-text);
}

.lang-pill--pt {
  background: var(--lang-pt-bg);
  color: var(--lang-pt-text);
}

.card-arrow {
  color: var(--on-surface-variant);
  font-size: 14px;
  line-height: 1;
}

.card-input {
  font-size: 22px;
  font-weight: 500;
  line-height: 30px;
  letter-spacing: -0.22px;
  color: var(--on-surface);
  margin: 0 0 var(--s-lg);
}

.card-result {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 38px;
  letter-spacing: -0.30px;
  color: var(--on-surface);
  margin: 0;
}

/* Features — 3-up shelf on desktop, stacked column on mobile. */
.features {
  padding-top: var(--s-xxxl);
  padding-bottom: var(--s-xxxxxl);
}

.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-xxxl);
}

@media (min-width: 840px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-xxxxl);
  }
}

.feature {
  margin: 0;
}

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--primary-container);
  color: var(--on-primary-container);
  margin-bottom: var(--s-lg);
}

.feature-icon svg {
  width: 22px;
  height: 22px;
}

.feature-text {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--on-surface-variant);
}

.feature-text strong {
  font-weight: 600;
  color: var(--on-surface);
}

/* Languages */
.languages {
  padding-bottom: var(--s-xxxxxl);
}

.language-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-sm);
  margin: 0 0 var(--s-lg);
}

.language-pills .lang-pill {
  padding: 6px 14px;
  font-size: 14px;
  /* Flat treatment in this section — all ten languages read as equals.
     EN/PT bespoke colors are still used in the card-stack demo above. */
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}

.languages-caption {
  margin: 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--on-surface-variant);
}

/* Footer */
.site-footer {
  padding-top: var(--s-xxxl);
  padding-bottom: var(--s-xxxl);
  border-top: 1px solid var(--outline);
  color: var(--on-surface-variant);
  font-size: 13px;
  line-height: 18px;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--on-surface-variant);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--on-surface);
  text-decoration: underline;
}

/* Privacy page */
.prose {
  padding-top: var(--s-xxxl);
  padding-bottom: var(--s-xxxxl);
}

.prose h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 38px;
  letter-spacing: -0.3px;
  color: var(--on-surface);
  margin: 0 0 var(--s-sm);
}

.prose .updated {
  color: var(--on-surface-variant);
  font-size: 13px;
  margin: 0 0 var(--s-xxxl);
}

.prose h2 {
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: -0.085px;
  color: var(--on-surface);
  margin: var(--s-xxxl) 0 var(--s-md);
}

.prose p,
.prose li {
  font-size: 15px;
  line-height: 22px;
  color: var(--on-surface);
  margin: 0 0 var(--s-md);
}

.prose ul {
  padding-left: var(--s-xl);
  margin: 0 0 var(--s-md);
}

.prose li {
  margin: 0 0 var(--s-sm);
}

.prose a {
  color: var(--primary);
  text-decoration: none;
}

.prose a:hover {
  text-decoration: underline;
}
