/* ===== Design tokens — light =====
   Dual convention:
   - --color-X (hex):       for plain CSS and arbitrary Tailwind classes without opacity
   - --color-X-rgb (R G B): for Tailwind aliases 'avelia-X' used with opacity modifier slash-N
   Do NOT mix: bg-[color:var(--x)]/40 does not work — use bg-avelia-x/40 instead.
===== */
:root {
  --color-bg: #F5F7F6;
  --color-surface: #FFFFFF;
  --color-surface-alt: #FAFBFA;
  --color-text: #1A4940;
  --color-text-muted: #4F6660;
  --color-text-heading: #12382F;
  --color-primary: #2E7D6D;
  --color-primary-hover: #246357;
  --color-mint: #DFF5EE;
  --color-accent: #7DC6E6;
  --color-salmon: #F7B6A8;
  --color-salmon-deep: #B0563E;
  --color-border: #E1ECE8;
  --color-focus: #7DC6E6;
  --color-danger: #E53E3E;

  --color-bg-rgb: 245 247 246;
  --color-surface-rgb: 255 255 255;
  --color-surface-alt-rgb: 250 251 250;
  --color-border-rgb: 225 236 232;
  --color-primary-rgb: 46 125 109;
  --color-mint-rgb: 223 245 238;
  --color-salmon-rgb: 247 182 168;
  --color-text-muted-rgb: 79 102 96;

  --shadow-soft: 0 1px 3px rgba(46, 125, 109, 0.06), 0 1px 2px rgba(46, 125, 109, 0.04);
  --shadow-elevated: 0 8px 24px rgba(46, 125, 109, 0.10), 0 2px 6px rgba(46, 125, 109, 0.06);
  --easing-soft: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== Design tokens — dark ===== */
html.dark,
:root.dark {
  --color-bg: #0F1A18;
  --color-surface: #162523;
  --color-surface-alt: #1D302C;
  --color-text: #DFF5EE;
  --color-text-muted: #94B0A8;
  --color-text-heading: #DFF5EE;
  --color-primary: #5BA999;
  --color-primary-hover: #7AC2B0;
  --color-mint: #1D302C;
  --color-accent: #9DD4EC;
  --color-salmon: #F9C5B8;
  --color-salmon-deep: #F9C5B8;
  --color-border: #243A35;
  --color-danger: #FF6B6B;

  --color-bg-rgb: 15 26 24;
  --color-surface-rgb: 22 37 35;
  --color-surface-alt-rgb: 29 48 44;
  --color-border-rgb: 36 58 53;
  --color-primary-rgb: 91 169 153;
  --color-mint-rgb: 29 48 44;
  --color-salmon-rgb: 249 197 184;
  --color-text-muted-rgb: 148 176 168;

  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* ===== Base ===== */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  color: var(--color-text-heading);
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
}

::selection {
  background: var(--color-mint);
  color: var(--color-text-heading);
}

/* Remove default focus ring only when not keyboard-focused */
:focus:not(:focus-visible) {
  outline: none;
}

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

/* ===== Skip link ===== */
.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 9999;
  padding: 0.625rem 1rem;
  background: var(--color-primary);
  color: #FFFFFF;
  font-weight: 600;
  border-radius: 6px;
  box-shadow: var(--shadow-elevated);
  transform: translateY(-150%);
  transition: transform 200ms var(--easing-soft);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* ===== Scroll reveal — progressive enhancement =====
   .reveal es visible por default (sin JS, sin animación).
   main.js agrega .is-revealing cuando arranca (oculta + prepara animación).
   IntersectionObserver agrega .is-visible al entrar en viewport (reveals con fade-up).
   Si JS falla por cualquier motivo, .is-revealing nunca se aplica → contenido queda visible. */
.reveal.is-revealing {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 700ms var(--easing-soft), transform 700ms var(--easing-soft);
}

.reveal.is-revealing.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal.is-revealing {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ===== Hero highlight (U4) =====
   Marker salmon detrás del verbo "Avelia respira" en el H1 del hero.
   Editorial: una franja cálida en el tercio inferior del texto que aporta
   energía emocional sin competir con el verde primario del título. */
.hero-highlight {
  position: relative;
  background-image: linear-gradient(
    180deg,
    transparent 0%,
    transparent 62%,
    rgb(var(--color-salmon-rgb) / 0.42) 62%,
    rgb(var(--color-salmon-rgb) / 0.42) 92%,
    transparent 92%
  );
  background-repeat: no-repeat;
  padding: 0 0.04em;
}

html.dark .hero-highlight {
  background-image: linear-gradient(
    180deg,
    transparent 0%,
    transparent 62%,
    rgb(var(--color-salmon-rgb) / 0.28) 62%,
    rgb(var(--color-salmon-rgb) / 0.28) 92%,
    transparent 92%
  );
}

/* ===== Editorial details ===== */
.editorial-rule {
  position: relative;
  height: 1px;
  background: currentColor;
  opacity: 0.15;
  border: 0;
}

.editorial-rule::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
  opacity: 1;
}

.text-balance {
  text-wrap: balance;
}

.text-pretty {
  text-wrap: pretty;
}

/* ===== Numerics ===== */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ===== Paper grain overlay ===== */
body {
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  opacity: 0.025;
  mix-blend-mode: multiply;
}

html.dark body::before {
  opacity: 0.05;
  mix-blend-mode: screen;
}

body > * {
  position: relative;
  z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    /* keep grain — it's static, not motion */
  }
}

/* ===== Card hover lift (U2) ===== */
@media (hover: hover) {
  .reveal.rounded-3xl:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
    transition: transform 240ms var(--easing-soft), box-shadow 240ms var(--easing-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal.rounded-3xl:hover {
    transform: none;
    transition: none;
  }
}

/* ===== Drop cap en #story (U3) =====
   Salmon en lugar de primary para diferenciar la "voz personal" del resto:
   marca el quiebre narrativo (historia de Matías) con calidez visual sin
   romper el ritmo verde de la landing. */
#story .font-serif > p:first-of-type::first-letter {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 3.6em;
  line-height: 0.9;
  float: left;
  padding: 0.05em 0.14em 0 0;
  color: var(--color-salmon-deep);
  font-weight: 600;
  font-feature-settings: "dlig", "ss01";
}

/* ===== Features bilingual TOGGLE =====
   La sección #features es bilingüe via toggle ES/EN — solo un idioma visible a la vez.

   Cómo funciona:
   - El <section id="features" data-lang="es"> arranca con data-lang="es" hardcoded.
   - Cada wrapper de contenido lleva `lang="es"` o `lang="en"` (mismas clases visuales).
   - CSS oculta el idioma que no matchea con data-lang.
   - JS (js/features-lang.js) actualiza data-lang + aria-pressed de los botones; persiste en localStorage.
   - Los botones del switch no llevan lang attr para no auto-ocultarse.

   .features-new-mark     → pill "Nuevo / New" inline al lado de un item de la versión actual.
   .features-version-pill → pill grande "Nuevo · vX · Mes" en el bloque destacado.
   .lang-pill             → cada botón del segmented control ES/EN.
*/

/* Hide non-active language (default state: ES) */
#features[data-lang="es"] [lang="en"],
#features:not([data-lang]) [lang="en"] {
  display: none;
}

/* When EN is active, hide ES content */
#features[data-lang="en"] [lang="es"] {
  display: none;
}

.features-new-mark {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.5rem;
  border-radius: 9999px;
  background: rgb(var(--color-salmon-rgb) / 0.65);
  color: var(--color-text-heading);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 0.18em;
  white-space: nowrap;
}

html.dark .features-new-mark {
  background: rgb(var(--color-salmon-rgb) / 0.35);
  color: var(--color-text);
}

.features-version-pill {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Segmented control ES/EN */
.features-lang-switch .lang-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: color 200ms var(--easing-soft), background-color 200ms var(--easing-soft);
}

.features-lang-switch .lang-pill[aria-pressed="true"] {
  background: var(--color-primary);
  color: #FFFFFF;
}

@media (hover: hover) {
  .features-lang-switch .lang-pill:hover:not([aria-pressed="true"]) {
    color: var(--color-primary);
  }
}

.features-lang-switch .lang-pill:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* En el bloque destacado de la versión actual, el hover-lift global no debe activarse:
   es un aside fijo de presentación, no una card del grid de categorías. */
@media (hover: hover) {
  #features aside.reveal.rounded-3xl:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ===== Screens showcase: marco sutil tipo "device frame" (U7) =====
   El Tailwind CDN no resuelve `shadow-[var(--shadow-soft)]` con valores
   multi-shadow, así que aplicamos sombra y un acento "device" desde acá. */
#screens figure > div {
  box-shadow: var(--shadow-soft);
  transition: transform 280ms var(--easing-soft),
              box-shadow 280ms var(--easing-soft);
}

@media (hover: hover) {
  #screens figure:hover > div {
    transform: translateY(-3px);
    box-shadow: var(--shadow-elevated);
  }
}

@media (prefers-reduced-motion: reduce) {
  #screens figure > div,
  #screens figure:hover > div {
    transform: none;
    transition: none;
  }
}

/* ===== CTA primario: hover lift (U6) =====
   Aplicar a los 2 CTAs App Store que quedan (hero + #cta-app). El lift sutil
   (1px) + shadow elevated mejora el feedback en hover sin volverse circense.
   El shadow base se aplica acá porque Tailwind CDN no procesa
   `shadow-[var(--shadow-soft)]` arbitrary con valores multi-shadow separados
   por coma. */
.cta-primary {
  box-shadow: var(--shadow-soft);
  transition: background-color 200ms var(--easing-soft),
              transform 200ms var(--easing-soft),
              box-shadow 200ms var(--easing-soft);
  will-change: transform;
}

@media (hover: hover) {
  .cta-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-elevated);
  }
}

.cta-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-soft);
  transition-duration: 80ms;
}

@media (prefers-reduced-motion: reduce) {
  .cta-primary,
  .cta-primary:hover,
  .cta-primary:active {
    transform: none;
    transition: background-color 200ms var(--easing-soft);
  }
}

/* ===== Waitlist form: spinner + feedback (U5) ===== */
[data-waitlist-submit] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
}

[data-waitlist-submit] .form-spinner {
  display: inline-block;
  animation: avelia-spin 800ms linear infinite;
  transform-origin: center;
}

@keyframes avelia-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  [data-waitlist-submit] .form-spinner {
    animation: none;
    opacity: 0.8;
  }
}

#email-feedback.feedback-message {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: 9999px;
  border: 1px solid transparent;
}

#email-feedback.feedback-success {
  background: rgb(var(--color-mint-rgb) / 0.55);
  border-color: rgb(var(--color-primary-rgb) / 0.25);
  animation: avelia-feedback-in 280ms var(--easing-soft);
}

html.dark #email-feedback.feedback-success {
  background: rgb(var(--color-mint-rgb) / 0.45);
}

#email-feedback.feedback-error {
  background: rgb(229 62 62 / 0.08);
  border-color: rgb(229 62 62 / 0.25);
}

#email-feedback .feedback-icon {
  flex-shrink: 0;
}

@keyframes avelia-feedback-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  #email-feedback.feedback-success {
    animation: none;
  }
}
