:root {
  --paper: #fff9ef;
  --paper-soft: #fdf4e8;

  --ink: #5b4030;
  --ink-soft: #816b5c;

  --orange: #dc9668;
  --orange-dark: #b87350;

  --line: rgba(126, 86, 60, 0.16);

  --shadow:
    0 28px 80px
    rgba(48, 32, 23, 0.24);

  --radius: 28px;
}


/* =====================================================
   GENERAL
   ===================================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;

  min-width: 320px;
  min-height: 100vh;

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  color: var(--ink);

  background: #f3e6dc;

  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline:
    2px solid
    rgba(196, 126, 87, 0.75);

  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}


/* =====================================================
   FONDO DECORATIVO DE LA PRIMERA VISTA
   ===================================================== */

.ambient {
  position: fixed;

  z-index: -10;

  width: 25rem;
  height: 25rem;

  border-radius: 999px;

  filter: blur(100px);

  opacity: 0.3;

  pointer-events: none;
}

.ambient-one {
  top: -8rem;
  left: -7rem;

  background: #efbd9d;
}

.ambient-two {
  right: -8rem;
  bottom: -8rem;

  background: #d8ccc4;
}

.ambient-three {
  top: 45%;
  left: 50%;

  transform: translate(-50%, -50%);

  background: #f1d7c6;

  opacity: 0.18;
}


/* =====================================================
   PANTALLAS
   ===================================================== */

.screen {
  width: 100%;
  min-height: 100vh;
}


/* =====================================================
   PRIMERA VISTA
   ===================================================== */

.entry-screen,
.closed-screen {
  display: grid;

  place-items: center;

  padding: 24px;

  background:
    radial-gradient(
      circle at 15% 10%,
      rgba(239, 185, 149, 0.38),
      transparent 35rem
    ),

    radial-gradient(
      circle at 90% 90%,
      rgba(143, 132, 127, 0.16),
      transparent 30rem
    ),

    linear-gradient(
      180deg,
      #f9f0e9,
      #f2e5db
    );
}

.entry-card,
.closed-card {
  width: min(100%, 620px);

  padding:
    clamp(42px, 8vw, 72px)
    clamp(26px, 7vw, 60px);

  text-align: center;

  border:
    1px solid
    rgba(118, 84, 65, 0.10);

  border-radius: 28px;

  background:
    rgba(255, 250, 246, 0.84);

  box-shadow:
    0 24px 70px
    rgba(88, 61, 46, 0.12);

  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 18px;

  color: #b77b5b;

  font-family:
    Arial,
    Helvetica,
    sans-serif;

  font-size: 0.72rem;

  font-weight: 700;

  letter-spacing: 0.24em;

  text-transform: uppercase;
}

.entry-card h1,
.closed-card h2 {
  margin: 0;

  color: #503a2e;

  font-weight: 400;

  line-height: 1.08;
}

.entry-card h1 {
  font-size:
    clamp(
      2.5rem,
      9vw,
      4.8rem
    );
}

.entry-copy,
.closed-card p {
  max-width: 440px;

  margin: 26px auto 0;

  color: #806d62;

  font-size: 1.05rem;

  line-height: 1.75;
}


/* =====================================================
   BOTÓN ABRIR
   ===================================================== */

.primary-button {
  margin-top: 36px;

  padding: 15px 35px;

  border: 0;

  border-radius: 999px;

  color: #fffaf6;

  background:
    linear-gradient(
      180deg,
      #dda07b 0%,
      #c98461 100%
    );

  box-shadow:
    0 10px 26px
    rgba(185, 116, 80, 0.20);

  font-family:
    Arial,
    Helvetica,
    sans-serif;

  font-weight: 700;

  cursor: pointer;

  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);

  box-shadow:
    0 14px 30px
    rgba(185, 116, 80, 0.25);
}

.primary-button:active {
  transform: translateY(0);
}


/* =====================================================
   TRANSICIÓN
   ===================================================== */

.entry-screen.is-leaving {
  animation:
    fadeOut
    480ms
    ease
    forwards;
}


/* =====================================================
   SEGUNDA VISTA
   ===================================================== */

.letter-screen {
  position: relative;

  isolation: isolate;

  min-height: 100vh;

  padding:
    60px
    20px
    100px;

  opacity: 0;

  transform:
    translateY(12px);

  overflow: hidden;

  background: #f2e6dc;
}

.letter-screen.is-visible {
  animation:
    revealLetter
    700ms
    ease
    forwards;
}


/* =====================================================
   PELAJE NARANJA
   IZQUIERDA
   ===================================================== */

.letter-screen::before {
  content: "";

  position: absolute;

  z-index: -3;

  top: 0;
  bottom: 0;
  left: 0;

  width: 50%;

  background-image:

    linear-gradient(
      90deg,
      rgba(222, 141, 74, 0.03) 0%,
      rgba(239, 176, 111, 0.03) 65%,
      rgba(255, 243, 224, 0.10) 100%
    ),

    url("/assets/pelaje-naranja.webp");

  background-size:
    100% auto,
    100% auto;

  background-repeat:
    repeat-y,
    repeat-y;

  background-position:
    top center,
    top center;

  filter:
    saturate(1.04)
    brightness(1.02);

  pointer-events: none;
}


/* =====================================================
   PELAJE VACA
   DERECHA
   ===================================================== */

.letter-screen::after {
  content: "";

  position: absolute;

  z-index: -3;

  top: 0;
  bottom: 0;
  right: 0;

  width: 50%;

  background-image:

    linear-gradient(
      90deg,
      rgba(255, 247, 232, 0.12) 0%,
      rgba(255, 255, 255, 0.03) 45%,
      rgba(40, 36, 34, 0.02) 100%
    ),

    url("/assets/pelaje-vaca.webp");

  background-size:
    100% auto,
    100% auto;

  background-repeat:
    repeat-y,
    repeat-y;

  background-position:
    top center,
    top center;

  filter:
    saturate(0.9)
    brightness(1.03);

  pointer-events: none;
}


/* =====================================================
   CARTA
   ===================================================== */

.letter-shell {
  position: relative;

  z-index: 2;

  width:
    min(
      calc(100% - 20px),
      720px
    );

  margin:
    0 auto;

  padding:
    clamp(42px, 7vw, 68px)
    clamp(26px, 7vw, 64px)
    clamp(54px, 8vw, 80px);

  color: var(--ink);

  background:

    repeating-linear-gradient(
      0deg,
      rgba(139, 105, 74, 0.012) 0,
      rgba(139, 105, 74, 0.012) 1px,
      transparent 1px,
      transparent 4px
    ),

    repeating-linear-gradient(
      90deg,
      rgba(169, 123, 85, 0.009) 0,
      rgba(169, 123, 85, 0.009) 1px,
      transparent 1px,
      transparent 5px
    ),

    linear-gradient(
      180deg,
      #fffaf1 0%,
      #fdf5e9 100%
    );

  border:
    1px solid
    rgba(139, 98, 66, 0.11);

  border-radius:
    28px;

  box-shadow:
    0 28px 80px
    rgba(53, 37, 28, 0.27);
}


/* Halo suave */

.letter-shell::before {
  content: "";

  position: absolute;

  z-index: -1;

  inset: -14px;

  border-radius: 38px;

  background:
    rgba(
      255,
      245,
      228,
      0.12
    );

  filter: blur(18px);

  pointer-events: none;
}


/* =====================================================
   ENCABEZADO
   SIN CORAZÓN
   ===================================================== */

.letter-header {
  position: relative;

  padding-bottom: 30px;

  text-align: center;

  border: 0;
}

.letter-header h2 {
  margin: 0;

  color: #664836;

  font-size:
    clamp(
      3.5rem,
      9vw,
      5.7rem
    );

  font-weight: 400;

  line-height: 1;
}


/* =====================================================
   REPRODUCTOR
   ===================================================== */

.voice-card {
  margin:
    4px 0
    48px;

  padding:
    25px
    26px
    22px;

  border:
    1px solid
    rgba(211, 158, 116, 0.30);

  border-radius:
    22px;

  background:
    linear-gradient(
      180deg,
      rgba(255, 239, 221, 0.88),
      rgba(253, 234, 214, 0.75)
    );

  box-shadow:
    0 8px 20px
    rgba(118, 75, 47, 0.09);
}

.voice-card-top {
  display: flex;

  align-items: center;

  justify-content:
    space-between;

  gap: 20px;
}

.voice-title {
  margin: 0;

  color: #644634;

  font-size:
    clamp(
      1.3rem,
      4vw,
      1.7rem
    );
}

.voice-play-button {
  display: grid;

  flex:
    0 0 60px;

  width: 60px;
  height: 60px;

  place-items: center;

  border:
    1px solid
    rgba(166, 101, 66, 0.28);

  border-radius:
    999px;

  color:
    #fff8f1;

  background:
    linear-gradient(
      180deg,
      #e4a57d,
      #d78c61
    );

  box-shadow:
    0 6px 13px
    rgba(137, 80, 51, 0.20);

  cursor: pointer;

  transition:
    transform 170ms ease,
    box-shadow 170ms ease;
}

.voice-play-button:hover {
  transform:
    translateY(-2px);

  box-shadow:
    0 9px 17px
    rgba(137, 80, 51, 0.24);
}

.voice-play-button:active {
  transform:
    translateY(0);
}

.voice-progress-row {
  display: grid;

  grid-template-columns:
    1fr auto;

  align-items: center;

  gap: 18px;

  margin-top: 20px;
}

.voice-progress {
  width: 100%;

  accent-color:
    #d78c61;

  cursor: pointer;
}

.voice-time {
  color:
    #70594a;

  font-size:
    0.84rem;

  white-space:
    nowrap;
}

.voice-status {
  min-height: 1em;

  margin:
    9px 0 0;

  color:
    #947462;

  font-family:
    Arial,
    Helvetica,
    sans-serif;

  font-size:
    0.72rem;
}


/* =====================================================
   TEXTO DE LA CARTA
   ===================================================== */

.letter-body {
  -webkit-user-select: none;
  user-select: none;

  -webkit-touch-callout: none;
}

.letter-body p {
  margin:
    0 0
    1.5em;

  color:
    #634837;

  font-size:
    clamp(
      1.12rem,
      3vw,
      1.3rem
    );

  line-height:
    1.72;

  letter-spacing:
    0.002em;
}

.letter-body p:first-child {
  margin-bottom: 1.25em;
}


/* =====================================================
   FINAL DE LA CARTA
   SIN CORAZÓN
   ===================================================== */

.final-section {
  padding-top: 46px;

  text-align: center;
}

.final-divider {
  display: none;
}

.final-section h3 {
  margin: 0;

  color:
    #624534;

  font-size:
    clamp(
      2.1rem,
      6vw,
      3.3rem
    );

  font-weight: 400;

  line-height: 1.12;
}


/* =====================================================
   BOTÓN CERRAR
   ===================================================== */

.final-button {
  margin-top: 30px;

  min-width: 150px;

  padding:
    14px
    34px;

  border:
    1px solid
    rgba(164, 96, 60, 0.18);

  border-radius:
    999px;

  color:
    #fff9f4;

  background:
    linear-gradient(
      180deg,
      #e3a17a,
      #d58b62
    );

  box-shadow:
    0 8px 16px
    rgba(137, 78, 49, 0.18);

  font-size:
    1.08rem;

  cursor: pointer;

  transition:
    transform 170ms ease,
    box-shadow 170ms ease;
}

.final-button:hover {
  transform:
    translateY(-2px);

  box-shadow:
    0 11px 20px
    rgba(137, 78, 49, 0.22);
}

.final-button:active {
  transform:
    translateY(0);
}


/* =====================================================
   PANTALLA CERRADA
   ===================================================== */

.closed-card h2 {
  font-size:
    clamp(
      2.2rem,
      8vw,
      4.5rem
    );
}


/* =====================================================
   MODAL
   ===================================================== */

.modal-backdrop {
  position: fixed;

  inset: 0;

  z-index: 100;

  display: grid;

  place-items: center;

  padding: 20px;

  background:
    rgba(
      45,
      32,
      26,
      0.55
    );

  backdrop-filter:
    blur(8px);
}

.modal-card {
  width:
    min(
      100%,
      500px
    );

  padding: 32px;

  color:
    var(--ink);

  background:
    #fff9ef;

  border-radius:
    24px;

  box-shadow:
    0 25px 70px
    rgba(40, 27, 20, 0.30);
}

.modal-card h2 {
  margin: 0;

  font-size:
    2rem;

  font-weight:
    400;
}

.modal-card > p:not(.eyebrow):not(.close-status) {
  color:
    var(--ink-soft);

  line-height:
    1.65;
}

.close-status {
  min-height:
    1.2em;

  margin-top:
    16px;

  color:
    var(--orange-dark);

  font-family:
    Arial,
    Helvetica,
    sans-serif;

  font-size:
    0.8rem;
}

.modal-actions {
  display:
    flex;

  justify-content:
    flex-end;

  gap:
    10px;

  margin-top:
    25px;
}

.secondary-button,
.danger-button {
  padding:
    12px
    19px;

  border:
    0;

  border-radius:
    999px;

  font-family:
    Arial,
    Helvetica,
    sans-serif;

  font-weight:
    700;

  cursor:
    pointer;
}

.secondary-button {
  color:
    #5f4739;

  background:
    #f0e3d6;
}

.danger-button {
  color:
    white;

  background:
    #be7855;
}


/* =====================================================
   ANIMACIONES
   ===================================================== */

@keyframes fadeOut {

  to {
    opacity: 0;

    transform:
      scale(0.985);
  }

}

@keyframes revealLetter {

  to {
    opacity: 1;

    transform:
      translateY(0);
  }

}


/* =====================================================
   CELULAR
   ===================================================== */

@media (max-width: 600px) {

  .letter-screen {
    padding:
      24px
      8px
      60px;
  }

  .letter-screen::before,
  .letter-screen::after {
    width: 50%;
  }

  .letter-screen::before {
    background-size:
      140% auto,
      140% auto;

    background-position:
      top center,
      top center;
  }

  .letter-screen::after {
    background-size:
      140% auto,
      140% auto;

    background-position:
      top center,
      top center;
  }

  .letter-shell {
    width:
      calc(100% - 4px);

    padding:
      36px
      21px
      50px;

    border-radius:
      24px;

    box-shadow:
      0 20px 55px
      rgba(51, 35, 27, 0.28);
  }

  .letter-header {
    padding-bottom:
      26px;
  }

  .voice-card {
    padding:
      20px;

    margin-bottom:
      40px;
  }

  .voice-play-button {
    flex-basis:
      54px;

    width:
      54px;

    height:
      54px;
  }

  .voice-progress-row {
    grid-template-columns:
      1fr;
  }

  .voice-time {
    justify-self:
      end;
  }

  .letter-body p {
    font-size:
      1.08rem;

    line-height:
      1.78;
  }

  .modal-actions {
    flex-direction:
      column-reverse;
  }

  .secondary-button,
  .danger-button {
    width: 100%;
  }

}


/* =====================================================
   PANTALLAS GRANDES
   ===================================================== */

@media (min-width: 1200px) {

  .letter-screen {
    padding:
      70px
      30px
      120px;
  }

  .letter-shell {
    width:
      min(
        720px,
        calc(100% - 80px)
      );
  }

}


/* =====================================================
   REDUCIR ANIMACIONES
   ===================================================== */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior:
      auto !important;

    animation-duration:
      0.01ms !important;

    animation-iteration-count:
      1 !important;

    transition-duration:
      0.01ms !important;
  }

}