/* El camino — tema nocturne elegante, mobile-first, responsive */

:root {
  /* Fondo y atmósfera */
  --night-deep: #0f0f14;
  --night-mid: #14141c;
  --night-blue: #111827;
  --glow-violet: rgba(139, 120, 180, 0.14);
  --glow-moon: rgba(200, 210, 230, 0.06);

  /* Superficies */
  --surface: rgba(28, 28, 38, 0.55);
  --surface-strong: rgba(34, 34, 46, 0.72);
  --surface-intro: rgba(38, 36, 52, 0.65);

  /* Texto (claros suaves, sin blanco puro) */
  --text-main: #e8e6f0;
  --text-soft: #a8a4b8;
  --text-muted: #7d7890;

  /* Acentos sutiles */
  --accent: #b8a4c8;
  --accent-soft: rgba(184, 164, 200, 0.35);
  --accent-warm: #c9b896;
  --accent-line-start: rgba(184, 164, 200, 0.15);
  --accent-line-end: rgba(201, 184, 150, 0.45);

  --border: rgba(200, 198, 220, 0.1);
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.35);

  --radius-lg: 24px;
  --radius-md: 16px;

  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.35rem;
  --space-5: 1.75rem;
  --space-6: 2.25rem;

  /* Ancho contenido: mobile full, tablet/desktop contenido */
  --content-max: 100%;
  --frame-pad-inline: clamp(1rem, 4vw, 1.5rem);

  --ease-scene: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-scene: 680ms;
  --nav-estimate: 142px;

  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-display: "Cormorant Garamond", "Palatino Linotype", Palatino, Georgia, serif;
}

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

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-main);
  background-color: var(--night-deep);
  /* Degradado nocturno + halos muy suaves */
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, var(--glow-violet), transparent 55%),
    radial-gradient(ellipse 90% 50% at 100% 60%, var(--glow-moon), transparent 45%),
    radial-gradient(ellipse 70% 40% at 0% 80%, rgba(100, 120, 160, 0.08), transparent 50%),
    linear-gradient(168deg, var(--night-deep) 0%, var(--night-blue) 42%, var(--night-mid) 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow-x: hidden;
}

/* Estrellas / polvo: capa fija muy discreta */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 22% 65%, rgba(255, 255, 255, 0.28) 0%, transparent 100%),
    radial-gradient(1px 1px at 38% 12%, rgba(255, 255, 255, 0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 40%, rgba(230, 228, 255, 0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 72% 78%, rgba(255, 255, 255, 0.22) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 30%, rgba(255, 255, 255, 0.32) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 15% 88%, rgba(255, 255, 255, 0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 15%, rgba(255, 255, 255, 0.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 92% 92%, rgba(255, 255, 255, 0.18) 0%, transparent 100%);
  background-size: 100% 100%;
}

/* Luz lunar muy suave */
body::after {
  content: "";
  position: fixed;
  top: -25%;
  left: 50%;
  transform: translateX(-50%);
  width: min(120vw, 720px);
  height: min(55vh, 420px);
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse closest-side, rgba(200, 205, 230, 0.07), transparent 70%);
}

/* Mini reproductor: portada + play/pause (dentro del marco, respeta safe-area) */
.ambient-player {
  --amb-scale: 1;
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-2));
  right: var(--frame-pad-inline);
  left: auto;
  z-index: 30;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  max-width: min(220px, 52vw);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.45rem 0.35rem 0.35rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(18, 18, 26, 0.78);
  color: var(--text-main);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  cursor: pointer;
  text-align: left;
  transform: scale(var(--amb-scale));
  transform-origin: center right;
  opacity: 1;
  transition:
    border-color 280ms ease,
    background 280ms ease,
    transform 0.32s var(--ease-scene),
    opacity 0.38s ease,
    box-shadow 360ms ease;
}

/* Pausado / apagado: sensación más “cerrada”; reproduciendo: un poco más abierto */
.ambient-player--idle:not(.ambient-player--is-pressing),
.ambient-player--off:not(.ambient-player--is-pressing) {
  --amb-scale: 0.94;
  opacity: 0.9;
}

.ambient-player--playing:not(.ambient-player--is-pressing) {
  --amb-scale: 1;
  opacity: 1;
}

.ambient-player--is-pressing {
  --amb-scale: 0.86;
  transition:
    transform 0.08s ease-out,
    box-shadow 0.12s ease,
    opacity 0.12s ease;
}

.ambient-player:hover {
  border-color: rgba(200, 198, 220, 0.16);
  background: rgba(26, 26, 36, 0.88);
}

.ambient-player:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.ambient-player--playing {
  border-color: rgba(201, 184, 150, 0.22);
  box-shadow: 0 0 32px rgba(139, 120, 180, 0.1);
}

.ambient-player--playing:not(.ambient-player--is-pressing) .ambient-player__cover-wrap {
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(201, 184, 150, 0.2);
}

.ambient-player--state-tick .ambient-player__cover-wrap {
  animation: ambientCoverTick 0.45s var(--ease-scene) both;
}

@keyframes ambientCoverTick {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.88);
  }
  70% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

.ambient-player__cover-wrap {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.45s ease;
}

.ambient-player__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: linear-gradient(145deg, rgba(60, 52, 80, 0.5), rgba(30, 28, 40, 0.9));
}

.ambient-player__cover--missing {
  opacity: 0.45;
}

.ambient-player__scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 16, 0.35);
  pointer-events: none;
  transition: background 0.42s ease, opacity 0.42s ease;
}

.ambient-player--playing .ambient-player__scrim {
  background: rgba(10, 10, 16, 0.2);
}

/* Pausa: overlay más “cerrado”, como apagando la luz del disco */
.ambient-player--idle .ambient-player__scrim,
.ambient-player--off .ambient-player__scrim {
  background: rgba(8, 8, 14, 0.58);
}

.ambient-player__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
  pointer-events: none;
  transition:
    opacity 0.38s ease,
    transform 0.38s var(--ease-scene),
    filter 0.38s ease;
}

.ambient-player--playing .ambient-player__icon--play {
  opacity: 0;
  transform: scale(0.85);
}

.ambient-player--playing .ambient-player__icon--pause {
  opacity: 1;
  transform: scale(1);
}

.ambient-player:not(.ambient-player--playing) .ambient-player__icon--pause {
  opacity: 0;
  transform: scale(0.85);
}

.ambient-player:not(.ambient-player--playing) .ambient-player__icon--play {
  opacity: 1;
  transform: scale(1);
}

.ambient-player__meta {
  min-width: 0;
  flex: 1;
  padding-right: 0.25rem;
}

.ambient-player__title {
  display: block;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ambient-player--playing .ambient-player__title {
  color: var(--text-soft);
}

.app-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--content-max);
  min-height: 100dvh;
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-3)) var(--frame-pad-inline)
    calc(env(safe-area-inset-bottom, 0px) + var(--space-3));
  display: flex;
  flex-direction: column;
}

.app-shell {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: calc(100dvh - var(--nav-estimate));
  min-height: calc(100vh - var(--nav-estimate));
  margin: 0 auto;
}

/* Avanzar: escenas inactivas “por debajo”; retroceder: “por encima” */
.scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition:
    opacity var(--duration-scene) var(--ease-scene),
    transform var(--duration-scene) var(--ease-scene);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: var(--space-2);
}

.app-shell[data-flow="back"] .scene:not(.scene--active) {
  transform: translateY(-16px);
}

.scene--active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scene-card {
  width: 100%;
  max-width: 36rem;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 5vw, 2.35rem);
}

.scene--intro .scene-card {
  background: var(--surface-intro);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

/* Escena clave: halo muy suave */
.scene--milestone.scene--active .scene-card {
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(184, 164, 200, 0.12) inset,
    0 0 72px rgba(139, 120, 180, 0.09);
}

/* Microanimación al activar escena */
.scene--active .scene-card {
  animation: cardSettle 720ms var(--ease-scene) both;
}

@keyframes cardSettle {
  from {
    opacity: 0.88;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.eyebrow {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0 0 var(--space-5);
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0.02em;
  color: var(--text-main);
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.35rem, 8vw, 3.15rem);
}

h2 {
  font-size: clamp(1.75rem, 6vw, 2.35rem);
}

.scene-copy {
  margin: 0 0 var(--space-4);
  line-height: 1.78;
  color: var(--text-soft);
  font-size: clamp(1.02rem, 3.4vw, 1.12rem);
  font-weight: 400;
  max-width: 32em;
}

.scene-copy:last-child {
  margin-bottom: 0;
}

.scene-copy--final {
  color: var(--accent-warm);
  font-weight: 500;
  font-style: italic;
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 3.8vw, 1.28rem);
}

.scene-highlight {
  margin-top: var(--space-6);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.scene-highlight__line {
  height: 2px;
  flex: 1;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--accent-line-start),
    var(--accent),
    var(--accent-line-end),
    var(--accent-line-start)
  );
  transform-origin: left;
  animation: lineReveal 2.8s var(--ease-scene) both;
}

.scene-highlight__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--accent-warm), var(--accent));
  box-shadow:
    0 0 0 6px rgba(184, 164, 200, 0.12),
    0 0 20px rgba(184, 164, 200, 0.2);
  animation: pulseSoft 3s ease-in-out infinite;
}

.atmosphere-label {
  margin: 0 0 var(--space-2);
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.92;
}

.intro-actions {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-5);
  width: 100%;
}

.btn--intro-secondary {
  font-weight: 600;
}

.scene-nav {
  position: sticky;
  bottom: 0;
  z-index: 10;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding-top: var(--space-3);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(
    180deg,
    rgba(15, 15, 20, 0) 0%,
    rgba(15, 15, 20, 0.65) 28%,
    rgba(15, 15, 20, 0.92) 100%
  );
  margin-top: auto;
}

.scene-progress {
  margin-bottom: var(--space-3);
  display: grid;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent), var(--accent-warm));
  border-radius: inherit;
  transition: width 480ms var(--ease-scene);
}

.scene-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.btn {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  font-family: var(--font-body);
  font-size: 0.97rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    transform 220ms var(--ease-scene),
    box-shadow 320ms var(--ease-scene),
    opacity 200ms ease,
    background 320ms ease,
    border-color 320ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.btn--primary {
  color: #12121a;
  background: linear-gradient(155deg, #d4c8e0, #c4b8d4);
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.btn--primary:hover:not(:disabled) {
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.14) inset;
}

.btn--ghost {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(200, 198, 220, 0.18);
}

@keyframes lineReveal {
  from {
    transform: scaleX(0.12);
    opacity: 0.25;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

@keyframes pulseSoft {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.12);
    opacity: 0.92;
  }
}

/* Tablet */
@media (min-width: 640px) {
  :root {
    --content-max: 28rem;
    --frame-pad-inline: 1.75rem;
    --nav-estimate: 150px;
  }

  .scene-copy {
    font-size: 1.06rem;
  }
}

@media (min-width: 768px) {
  :root {
    --content-max: 30rem;
    --frame-pad-inline: 2rem;
  }

  .scene-card {
    padding: clamp(1.85rem, 4vw, 2.65rem);
  }
}

/* Desktop: app contenida, marco tipo dispositivo */
@media (min-width: 1024px) {
  :root {
    --content-max: min(34rem, 92vw);
    --nav-estimate: 154px;
  }

  body {
    padding-block: clamp(1.5rem, 4vh, 3rem);
    justify-content: center;
  }

  .app-frame {
    min-height: min(640px, 88dvh);
    max-height: min(900px, 92dvh);
    margin-block: auto;
    padding: clamp(1.75rem, 3vh, 2.5rem) clamp(1.75rem, 3vw, 2.75rem);
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(22, 22, 32, 0.75) 0%, rgba(18, 18, 26, 0.88) 100%);
    box-shadow:
      var(--shadow),
      0 0 0 1px rgba(0, 0, 0, 0.35) inset,
      0 0 80px rgba(100, 90, 140, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .app-shell {
    min-height: min(520px, 58dvh);
  }

  .scene-nav {
    background: linear-gradient(
      180deg,
      rgba(18, 18, 26, 0) 0%,
      rgba(18, 18, 26, 0.85) 35%,
      rgba(18, 18, 26, 0.95) 100%
    );
  }
}

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

  .scene--active .scene-card {
    animation: none;
  }

  .ambient-player--state-tick .ambient-player__cover-wrap {
    animation: none;
  }

  .ambient-player--idle:not(.ambient-player--is-pressing),
  .ambient-player--off:not(.ambient-player--is-pressing) {
    --amb-scale: 1;
    opacity: 1;
  }
}
