/* Estilos de la landing. Solo los carga dist/index.html, después de tokens, styles y map.css.
   Todo con tokens de tokens.css; nada por tema. Mobile-first: min-width 700, 1024 y 1440. */
/* Mientras #route-init decide (`pending`) o ya redirige (`leaving`) no se pinta contenido: se ve
   solo el --bg de :root, sin destello y sin un fotograma de la landing. */
:root[data-route] body {
  visibility: hidden;
}

/* Los enlaces internos (`#agente`, `#precio`…) desplazan suave solo con el movimiento activo: la regla
   exige las dos cosas (`data-motion` lo apaga el toggle y `prefers-reduced-motion` lo apaga el sistema,
   y styles.css ya lo pone en `auto` en ese caso). */
@media (prefers-reduced-motion: no-preference) {
  :root[data-motion='active'] {
    scroll-behavior: smooth;
  }
}

/* ---- Contenedor ---- */
:root {
  --page-margin: var(--space-4);
  --header-h: calc(var(--target-min) + var(--space-3));
  --field-h: calc(var(--target-min) + var(--space-1));
  --stage-size: min(176px, 21svh);
}
@media (min-width: 700px) {
  :root {
    --page-margin: var(--space-6);
    --stage-size: min(240px, 26svh);
  }
}
@media (min-width: 1024px) {
  :root {
    --page-margin: var(--space-10);
    --stage-size: min(100%, calc(100svh - var(--header-h) - 2 * var(--space-8)), 600px);
  }
}
.landing-header,
.landing-main,
.landing-footer {
  width: min(100% - 2 * var(--page-margin), var(--content-max));
  margin-inline: auto;
}

/* ---- Iconos del sprite ---- */
.button-icon,
.field-error-icon,
.notice-icon,
.notice .icon,
.faq-chevron {
  flex: none;
  width: var(--icon-md);
  height: var(--icon-md);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: var(--icon-stroke);
}

/* ---- Cabecera ---- */
.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--header-h);
}
.landing-nav {
  display: none;
}
@media (min-width: 1024px) {
  .landing-nav {
    display: flex;
    gap: var(--space-6);
  }
  .landing-nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--target-min);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
  }
  .landing-nav a:hover {
    color: var(--text);
  }
}

/* ---- Cuerpo ---- */
.landing-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  max-width: none;
  margin-block: 0;
  padding: 0 0 var(--space-12);
}
@media (min-width: 1024px) {
  .landing-main {
    gap: var(--space-16);
    padding-bottom: var(--space-16);
  }
}
.lead {
  max-width: 36rem;
  color: var(--text-secondary);
  font-size: var(--text-md);
}
@media (min-width: 1024px) {
  .lead {
    font-size: var(--text-lg);
  }
}

/* ---- 1. Portada ---- */
.hero {
  display: grid;
  gap: var(--space-4);
  grid-template-areas: 'stage' 'copy';
}
.hero-copy {
  grid-area: copy;
  min-width: 0;
}
.hero h1 {
  font-size: var(--text-3xl);
}
.hero .lead {
  margin-top: var(--space-2);
}
/* Degradado de marca en «el camino.» (landing.md §5.5): la única excepción a MASTER §4.5, regla 5.
   Respaldo sólido; el degradado y el texto transparente solo existen donde `background-clip: text`
   funciona, y en colores forzados la frase toma el color del sistema. */
.heading-gradient {
  color: var(--accent);
  white-space: nowrap;
}
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .heading-gradient {
    background-image: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}
@media (forced-colors: active) {
  /* `color: CanvasText` hace falta: con solo `currentColor` Chromium resuelve el relleno contra el
     `color: transparent` del autor y la frase queda invisible (medido en verify:landing). */
  .heading-gradient {
    background-image: none;
    color: CanvasText;
    -webkit-text-fill-color: currentColor;
  }
}
.heading-gradient::selection {
  background: var(--accent);
  color: var(--accent-contrast);
  -webkit-text-fill-color: var(--accent-contrast);
}
/* Escenario de la esfera (MASTER §12.20, landing.md §5.2 y §5.3): una caja cuadrada con el fondo del
   mapa y su resplandor único (§4.5, regla 4), sin borde. `isolation` mantiene a `.map-sphere`
   (`--z-map-sphere`, negativo) por encima del fondo del escenario y por debajo de su botón; sin esa
   capa la red quedaba detrás del fondo. Re-enlaza el anillo de foco al del mapa, como `.semantic-map`:
   el escenario es oscuro en los dos temas y el anillo de la página no contrasta ahí. Sin JS muestra
   el fondo y el resplandor, sin red. */
.sphere-stage {
  --focus-ring: var(--map-focus-ring);
  grid-area: stage;
  position: relative;
  isolation: isolate;
  justify-self: center;
  align-self: center;
  width: var(--stage-size);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background-color: var(--map-bg);
  background-image: radial-gradient(
    ellipse at 50% 48%,
    color-mix(in srgb, var(--map-accent) 10%, transparent),
    transparent 60%
  );
}
/* Botón de movimiento del escenario: el patrón de los controles de zoom del mapa (superficie opaca
   del mapa, borde `--map-ring-inactive`), en la esquina inferior derecha. */
.stage-motion {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  z-index: var(--z-map-controls);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--target-min);
  height: var(--target-min);
  padding: 0;
  border: 1px solid var(--map-ring-inactive);
  border-radius: var(--radius-sm);
  background: var(--map-surface);
  color: var(--map-text);
}
.stage-motion:hover:not(:disabled) {
  background: color-mix(in srgb, var(--map-accent) 14%, var(--map-surface));
}
.stage-motion-icon {
  flex: none;
  width: var(--icon-lg);
  height: var(--icon-lg);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: var(--icon-stroke);
}
.agent-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 36rem;
  margin-top: var(--space-4);
  padding: var(--space-4);
  /* La cabecera no es fija: sin este margen, «Escribir mi tema» o `#agente` dejan el formulario
     pegado al borde superior del viewport. */
  scroll-margin-top: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
}
.agent-form .form-field {
  margin: 0;
}
.agent-form .form-field label {
  margin-bottom: var(--space-1);
}
.agent-form input {
  min-height: var(--field-h);
}
.agent-form input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}
.agent-submit {
  width: 100%;
  min-height: var(--field-h);
  margin-top: var(--space-1);
}
.form-note {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
/* Error de un campo (MASTER §12.16): borde de 2 px y mensaje en --warning con su icono; el color no es
   el único canal (el icono y el texto lo dicen). El relleno baja 1 px para que el texto no se mueva
   cuando el borde pasa de 1 a 2. El borde se queda en --warning también con el foco: el anillo de
   foco va aparte, en el outline. */
.agent-form input[aria-invalid='true'] {
  padding: calc(var(--space-3) - 1px);
  border-width: 2px;
  border-color: var(--warning);
}
.field-error {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-1) 0 0;
  color: var(--warning);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.field-error[hidden] {
  display: none;
}
.field-error-icon {
  margin-top: calc((1lh - var(--icon-md)) / 2);
}
/* Aviso «en breve» (landing.md §6.4): informativo, ni ámbar ni coral ni verde. */
.notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-accent);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}
.notice-icon {
  margin-top: calc((1lh - var(--icon-md)) / 2);
  color: var(--accent);
}
/* El aviso de un pedido que no salió (landing.md §19.1): ámbar, como los errores del campo. */
.notice.warning .icon {
  margin-top: calc((1lh - var(--icon-md)) / 2);
  color: var(--warning);
}
.notice p {
  margin: 0;
}
.notice-title {
  color: var(--text);
  font-weight: 700;
}
.notice-text {
  margin-top: var(--space-1);
  color: var(--text-secondary);
}
.notice-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}
@media (min-width: 700px) {
  .stage-motion {
    right: var(--space-4);
    bottom: var(--space-4);
  }
  .hero-copy {
    width: 100%;
    max-width: 36rem;
    margin-inline: auto;
    text-align: center;
  }
  .hero .lead {
    margin-inline: auto;
  }
  .hero h1 {
    font-size: var(--text-4xl);
    line-height: var(--leading-4xl);
  }
  .agent-form {
    padding: var(--space-5);
  }
  .agent-submit {
    align-self: flex-start;
    width: auto;
  }
}
@media (min-width: 1024px) {
  .hero {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 'copy stage';
    gap: var(--space-12);
    padding-block: var(--space-8);
  }
  .hero-copy {
    align-self: center;
    max-width: none;
    margin-inline: 0;
    text-align: left;
  }
  .hero .lead {
    margin-inline: 0;
  }
}
@media (min-width: 1440px) {
  .hero h1 {
    font-size: var(--text-display);
    line-height: var(--leading-display);
  }
  .hero .lead {
    margin-top: var(--space-4);
  }
  .agent-form {
    margin-top: var(--space-8);
  }
}
.stage-motion[hidden],
.footer-motion[hidden] {
  display: none;
}

/* ---- Bloques 2 a 8 ---- */
.landing-block {
  display: grid;
  gap: var(--space-6);
  align-content: start;
}
.landing-block p,
.final-call p {
  color: var(--text-secondary);
}
.landing-block h3 + p {
  margin-top: var(--space-2);
}
.landing-block .price-line {
  color: var(--text);
  font-weight: 500;
}

/* 2. Cómo funciona */
.steps,
.state-samples,
.pieces,
.audience-cards,
.principles {
  display: grid;
  gap: var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}
/* La separación entre pasos es la que la línea tiene que cruzar: la lee el ::before de cada paso. */
.steps {
  --steps-gap: var(--space-6);
  gap: var(--steps-gap);
}
.step {
  position: relative;
  display: grid;
  align-content: start;
  grid-template-columns: var(--space-10) 1fr;
  gap: var(--space-4);
}
/* Línea entre los círculos (MASTER §12.18): 1.6 px en --border-strong, de un círculo al siguiente, y un
   pulso en --accent (12 % del largo, como el dash 12 88 del pulso de conexión del mapa) que la recorre
   en --dur-pulse. Vertical bajo 1024 px y horizontal desde 1024. Decorativa: es un pseudoelemento. */
.step:not(:last-child)::before {
  content: '';
  position: absolute;
  top: calc(var(--space-10) + var(--space-1));
  bottom: calc(var(--space-1) - var(--steps-gap));
  left: calc(var(--space-10) / 2 - 0.8px);
  width: 1.6px;
  background-color: var(--border-strong);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 100% 12%;
  animation: step-pulse-down var(--dur-pulse) var(--ease-linear) infinite;
  animation-play-state: var(--pulse-play-state);
}
@keyframes step-pulse-down {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 100%;
  }
}
@keyframes step-pulse-across {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 100% 0;
  }
}
/* Con movimiento reducido la línea queda quieta y visible, sin pulso. */
:root[data-motion='reduced'] .step::before {
  animation: none;
  background-image: none;
}
@media (prefers-reduced-motion: reduce) {
  .step::before {
    background-image: none;
  }
}
.step-number {
  display: grid;
  place-items: center;
  width: var(--space-10);
  height: var(--space-10);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}

/* 3. El mapa por dentro */
/* Panel de muestras (MASTER §12.15): siempre sobre --map-bg, el fondo para el que están calculados los
   contrastes de --node-* y --map-*; en el tema verde queda oscuro (bosque) sin regla por tema. El
   anillo de foco se vuelve a enlazar al del mapa, como en .sphere-stage. */
.state-panel {
  --focus-ring: var(--map-focus-ring);
  padding: var(--space-4);
  border: 1px solid var(--map-border);
  border-radius: var(--radius-lg);
  background: var(--map-bg);
}
/* Las asignaciones --node-* de cada estado, el halo y el arco viven en map.css; aquí solo el tamaño
   (el de una habilidad, MASTER §12.4.6) y la disposición. */
.state-sample {
  --orb-size: 56px;
  --badge-size: 22px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.state-sample .semantic-orb {
  margin-bottom: 0;
}
.state-copy {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
}
.state-copy strong {
  color: var(--map-text);
  font-weight: 700;
}
.state-copy span {
  color: var(--map-text-muted);
}
.route-card {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}

/* 4. Para quién es */
.card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* 5. Precio */
.price-grid {
  display: grid;
  gap: var(--space-4);
}
.price-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}
.price-card h3 {
  font-size: var(--text-xl);
  font-weight: 700;
}

/* 6. Principios */
.principles h3 {
  font-size: var(--text-md);
  font-weight: 700;
}
.principles p {
  font-size: var(--text-sm);
}

/* 7. Preguntas frecuentes */
.faq-item {
  border-bottom: 1px solid var(--border);
}
.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--target-min);
  padding-block: var(--space-3);
  color: var(--text);
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.faq-item summary::-webkit-details-marker {
  display: none;
}
.faq-item summary:hover {
  color: var(--accent);
}
.faq-chevron {
  color: var(--text-secondary);
  transition: transform var(--dur-fast) var(--ease-out);
}
.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
}
:root[data-motion='reduced'] .faq-chevron {
  transition: none;
}
.faq-answer {
  display: grid;
  gap: var(--space-2);
  max-width: var(--measure);
  padding-bottom: var(--space-4);
}

/* 8. Llamada final */
.final-call {
  display: grid;
  gap: var(--space-4);
  justify-items: center;
  padding: var(--space-12) var(--space-4);
  border-block: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}
.final-call p {
  max-width: var(--measure);
}
.button-row {
  display: grid;
  gap: var(--space-3);
  width: 100%;
}

/* ---- Revelado de los bloques 2 a 8 (MASTER §9.7) ----
   El estado oculto lo pone landing.js, y solo si va a animar: sin JS, sin IntersectionObserver, con
   movimiento reducido o al llegar por un ancla el atributo no existe y el bloque se ve. Cuando el
   atributo se quita no queda transición, así que ese cambio es instantáneo. */
[data-reveal] {
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
}
[data-reveal='pending'] {
  opacity: 0;
  transform: translateY(var(--space-4));
}

/* ---- Pie ---- */
/* El toggle de movimiento del pie va sobre --bg, no sobre --map-bg: `.motion-toggle` (map.css) lleva
   colores del mapa, claros en los dos temas, y con el --bg claro del tema verde no contrastan (medido:
   1.03:1). Esta variante usa tokens de página y deja intacta la forma del toggle. */
.footer-motion {
  border-color: var(--border-strong);
  color: var(--text);
}
.footer-motion::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.footer-motion[aria-pressed='false']::before {
  background: transparent;
  border: 2px solid var(--text-muted);
  box-shadow: none;
}
.footer-motion:disabled {
  color: var(--text-muted);
}
.landing-footer {
  display: grid;
  gap: var(--space-4);
  padding-block: var(--space-8);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.footer-about,
.footer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
}
.footer-mark {
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
}

@media (min-width: 700px) {
  .steps {
    --steps-gap: var(--space-8);
  }
  .state-panel {
    padding: var(--space-6);
  }
  .state-samples {
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  }
  .state-sample {
    --orb-size: 72px;
    --badge-size: 24px;
    flex-direction: column;
    align-items: flex-start;
  }
  .card {
    padding: var(--space-5);
  }
  .price-grid {
    grid-template-columns: 1fr 1fr;
  }
  .principles {
    grid-template-columns: 1fr 1fr;
  }
  .button-row {
    display: flex;
    justify-content: center;
    width: auto;
  }
}
@media (min-width: 1024px) {
  .steps,
  .audience-cards,
  .pieces {
    grid-template-columns: repeat(3, 1fr);
  }
  .step {
    grid-template-columns: none;
    justify-items: start;
  }
  .step:not(:last-child)::before {
    top: calc(var(--space-10) / 2 - 0.8px);
    right: calc(var(--space-2) - var(--steps-gap));
    bottom: auto;
    left: calc(var(--space-10) + var(--space-2));
    width: auto;
    height: 1.6px;
    background-size: 12% 100%;
    animation-name: step-pulse-across;
  }
  .state-samples {
    grid-template-columns: repeat(5, 1fr);
  }
  .price-grid {
    width: 100%;
    max-width: 56rem;
    margin-inline: auto;
  }
  .price-card {
    padding: var(--space-6);
  }
  .price-card h3 {
    font-size: var(--text-2xl);
  }
  .principles {
    grid-template-columns: repeat(4, 1fr);
  }
  .faq {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
  }
  .final-call {
    padding-block: var(--space-16);
  }
  .landing-footer {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}
