/* ==========================================================================
   Design tokens — Carta para Paz
   Paleta: lavanda pastel + crema + ciruela (dirección visual, refinable)
   ========================================================================== */

:root {
  /* Color — paleta rosa pergamino */
  --color-bg:            #FBE7EE;
  --color-lavender:      #E3A7BD;
  --color-lavender-soft: #F3D3DF;
  --color-plum:          #7A3F56;
  --color-text:          #3B2A33;
  --color-text-muted:    #8A6B78;
  --color-white-warm:    #FFF9FB;

  /* Tipografía */
  --font-title:  "Playfair Display", "Didot", "Bodoni MT", serif;
  --font-body:   "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --font-script: "Caveat", "Segoe Print", cursive;

  --text-body:   clamp(18px, 4vw, 24px);
  --text-lead:   clamp(22px, 5vw, 30px);
  --text-title:  clamp(32px, 7vw, 56px);

  /* Forma */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  /* Sombra */
  --shadow-soft: 0 12px 40px rgba(110, 65, 84, 0.14);

  /* Easing (open-props) */
  --ease-cubic-out:       cubic-bezier(0.215, 0.61, 0.355, 1);
  --ease-cubic-in-out:    cubic-bezier(0.645, 0.045, 0.355, 1);
  --ease-elastic-out-3:   cubic-bezier(0.5, 1.25, 0.75, 1.25);

  /* Duración */
  --transition-fast:   220ms;
  --transition-normal: 500ms;
  --transition-slow:   1000ms;
}

/* ==========================================================================
   Reset
   ========================================================================== */

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

html, body {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(ellipse at center, rgba(255, 244, 248, 0) 42%, rgba(219, 134, 160, 0.30) 100%),
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(255, 236, 240, 0.55) 0%, rgba(251, 231, 238, 0) 100%),
    var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    display: none;
  }
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   Layout base
   ========================================================================== */

.experience {
  min-height: 100dvh;
}

.scene {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  padding: clamp(24px, 6vw, 48px);
  padding-top: calc(clamp(24px, 6vw, 48px) + env(safe-area-inset-top, 0px));
  padding-bottom: calc(clamp(24px, 6vw, 48px) + env(safe-area-inset-bottom, 0px) + 80px);
}

.scene-inner {
  width: 100%;
  max-width: 560px;
  margin: auto 0;
}

/* ==========================================================================
   Lock screen
   ========================================================================== */

.lock-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  text-align: center;
}

.lock-inner {
  width: 100%;
  max-width: 360px;
}

.lock-title {
  font-family: var(--font-title);
  font-size: var(--text-title);
  font-weight: 600;
  color: var(--color-plum);
}

.lock-subtitle {
  margin-top: 12px;
  font-style: italic;
  color: var(--color-text-muted);
}

.heart-lock {
  display: flex;
  justify-content: center;
  margin: 40px auto;
}

.heart-shape {
  fill: var(--color-lavender);
}

.heart-hole {
  fill: var(--color-plum);
}

.heart-key {
  fill: var(--color-white-warm);
}

.dots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 24px 0;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color-lavender);
  transition: background var(--transition-fast) var(--ease-cubic-out);
}

.dot.filled {
  background: var(--color-lavender);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 260px;
  margin: 0 auto;
}

.keypad button {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--color-white-warm);
  color: var(--color-plum);
  font-family: var(--font-title);
  font-size: 20px;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-fast) var(--ease-cubic-out), background var(--transition-fast);
}

.keypad button:active {
  transform: scale(0.94);
  background: var(--color-lavender-soft);
}

.keypad button:focus-visible {
  outline: 2px solid var(--color-lavender);
  outline-offset: 2px;
}

.hint {
  margin-top: 28px;
  font-size: 16px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.hint-text {
  margin-top: 8px;
  font-style: italic;
  color: var(--color-lavender);
}

/* ==========================================================================
   Floating UI
   ========================================================================== */

.floating-ui {
  position: fixed;
  right: 20px;
  top: calc(20px + env(safe-area-inset-top, 0px));
  z-index: 40;
}

.fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-plum);
  color: var(--color-white-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-fast) var(--ease-cubic-out);
}

.fab:active {
  transform: scale(0.94);
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(48, 42, 51, 0.55);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--color-white-warm);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-soft);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-lavender-soft);
}

.modal-title {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 600;
  color: var(--color-plum);
}

.modal-note {
  margin: 8px 0 20px;
  font-style: italic;
  color: var(--color-text-muted);
}

.spotify-embed {
  min-height: 152px;
}

.spotify-embed iframe {
  width: 100%;
  border-radius: var(--radius-md);
  border: none;
}

/* ==========================================================================
   Scene content
   ========================================================================== */

.scene-title {
  font-family: var(--font-title);
  font-size: var(--text-title);
  font-weight: 600;
  color: var(--color-plum);
  margin-bottom: 24px;
  text-align: center;
  letter-spacing: 0.02em;
}

.block {
  font-size: var(--text-body);
  line-height: 1.7;
  margin-bottom: 1.1em;
  color: var(--color-text);
}

.block:last-child {
  margin-bottom: 0;
}

.scene-quote {
  font-style: italic;
  font-size: var(--text-lead);
  line-height: 1.6;
  color: var(--color-plum);
  padding-left: 20px;
  border-left: 2px solid var(--color-lavender);
  margin-bottom: 28px;
}

.greeting {
  font-family: var(--font-title);
  font-style: italic;
  font-size: clamp(30px, 7vw, 42px);
  color: var(--color-plum);
  margin-bottom: 20px;
}

.signature-closing {
  font-family: var(--font-body);
  font-size: var(--text-lead);
  color: var(--color-text-muted);
}

.signature-name {
  font-family: var(--font-body);
  font-size: 16px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-top: 10px;
}

.signature-for {
  font-family: var(--font-script);
  font-size: clamp(40px, 9vw, 60px);
  color: var(--color-plum);
  margin-top: 6px;
}

.signature-for strong {
  font-weight: 700;
}

.signature-date {
  font-family: var(--font-body);
  color: var(--color-text-muted);
  margin-top: 14px;
}

.silence-mark {
  font-size: clamp(40px, 10vw, 72px);
  color: var(--color-lavender);
  text-align: center;
}

.photo {
  margin: 32px auto;
  max-width: 340px;
  cursor: pointer;
}

.photo + .photo {
  margin-top: 48px;
}

.scene[data-scene="firma"] .photo {
  max-width: 250px;
  margin: 20px auto 0;
}

.scene[data-scene="firma"] .photo-caption {
  margin-top: 12px;
}

.photo-frame {
  background: var(--color-white-warm);
  padding: 12px;
  border-radius: 4px;
  box-shadow: var(--shadow-soft);
  transform: rotate(var(--tilt, 0deg));
  transition: transform var(--transition-normal) var(--ease-cubic-out);
}

.photo-frame img {
  width: 100%;
  display: block;
  border-radius: 2px;
}

.photo:hover .photo-frame {
  transform: rotate(0deg) scale(1.02);
}

.photo-caption {
  margin-top: 14px;
  text-align: center;
  font-style: italic;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Envelope
   ========================================================================== */

.envelope-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.envelope {
  position: relative;
  width: min(320px, 82vw);
  height: 200px;
  cursor: pointer;
  perspective: 900px;
  display: block;
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: var(--color-lavender-soft);
  border-radius: var(--radius-md);
  z-index: 1;
}

.envelope-front {
  position: absolute;
  inset: 0;
  background: var(--color-lavender);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
  border-radius: var(--radius-md);
  z-index: 3;
}

.letter-paper {
  position: absolute;
  top: 16px;
  left: 18px;
  right: 18px;
  height: 150px;
  background: var(--color-white-warm);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.letter-paper .greeting {
  margin: 0;
}

.envelope-flap {
  position: absolute;
  inset: 0;
  background: var(--color-plum);
  clip-path: polygon(0 0, 100% 0, 50% 55%);
  transform-origin: top;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  z-index: 4;
}

.type-caret::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.15em;
  background: var(--color-plum);
  animation: caret-blink 0.9s steps(1) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

.envelope-hint {
  margin-top: 16px;
  font-style: italic;
  color: var(--color-text-muted);
}

.letter-content {
  width: 100%;
  margin-top: 20px;
}

/* ==========================================================================
   CTA + video + spotify card
   ========================================================================== */

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  border-radius: 999px;
  background: var(--color-plum);
  color: var(--color-white-warm);
  font-family: var(--font-title);
  font-size: 18px;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-soft);
  margin: 12px 0 8px;
  transition: transform var(--transition-fast) var(--ease-cubic-out), background var(--transition-fast);
}

.cta:active {
  transform: scale(0.96);
}

.cta:focus-visible {
  outline: 2px solid var(--color-lavender);
  outline-offset: 2px;
}

.video-wrap {
  margin-top: 20px;
}

.video-wrap video {
  width: 100%;
  border-radius: var(--radius-md);
  background: #000;
  box-shadow: var(--shadow-soft);
}

.spotify-card {
  margin-top: 20px;
  background: var(--color-white-warm);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.spotify-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-plum);
}

.spotify-note {
  font-style: italic;
  color: var(--color-text-muted);
  margin: 4px 0 16px;
}

.spotify-embed {
  min-height: 152px;
}

.spotify-embed iframe {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(24, 20, 28, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 6px;
  box-shadow: var(--shadow-soft);
}

.lightbox-caption {
  margin-top: 18px;
  color: var(--color-white-warm);
  font-style: italic;
  text-align: center;
  font-size: var(--text-body);
}

.lightbox-close {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-white-warm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.scene-nav {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: space-between;
  z-index: 40;
  pointer-events: none;
}

.nav-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-plum);
  color: var(--color-white-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  pointer-events: auto;
  transition: transform var(--transition-fast) var(--ease-cubic-out), opacity var(--transition-fast);
}

.nav-btn:active {
  transform: scale(0.94);
}

.nav-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.nav-btn:focus-visible {
  outline: 2px solid var(--color-lavender);
  outline-offset: 2px;
}

/* ==========================================================================
   Responsive — landscape y desktop
   ========================================================================== */

@media (max-height: 480px) {
  .scene {
    justify-content: flex-start;
  }
  .heart-lock {
    margin: 12px auto;
  }
  .heart-lock svg {
    width: 60px;
    height: 54px;
  }
  .lock-title {
    font-size: 26px;
  }
  .lock-subtitle {
    margin-top: 6px;
  }
  .keypad {
    gap: 8px;
    max-width: 220px;
  }
  .dots {
    margin: 14px 0;
  }
}

@media (min-width: 768px) {
  .scene-inner {
    max-width: 680px;
  }
  .block {
    font-size: 22px;
  }
}

/* ==========================================================================
   Motion — respeto a preferencias del usuario
   ========================================================================== */

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