/* ==========================================================================
   Star Letter — Cover, chronicle, heart hold and wishes
   Expansion component and layout rules for the cover, chronicle, heartbeat hold and wish map.
   ========================================================================== */

/* ---------- Cover · unsealing the envelope ---------- */
.scene--cover {
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top) + clamp(96px, 14vh, 150px))
    22px
    calc(env(safe-area-inset-bottom) + 58px);
  overflow: hidden;
}

.cover-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(880px, 100%);
  text-align: center;
}

.eyebrow--cover { color: rgba(255, 217, 160, 0.6); }

.cover-title {
  margin: clamp(14px, 2.2vh, 22px) 0 0;
  font-size: clamp(25px, 3.4vw, 44px);
  font-weight: 400;
  line-height: 1.38;
  letter-spacing: 0.08em;
  color: #fff7ef;
  text-shadow: 0 0 40px rgba(255, 217, 160, 0.14);
}

.envelope-cover {
  position: relative;
  display: block;
  width: min(452px, 84vw);
  aspect-ratio: 1.55;
  margin-top: clamp(24px, 4.2vh, 38px);
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 1100px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}

.envelope-cover__paper {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background-color: #fff6ec;
  background-image:
    var(--noise),
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.82), transparent 58%),
    linear-gradient(160deg, rgba(255, 249, 238, 0.95), rgba(242, 224, 200, 0.82));
  background-size: 160px 160px, auto, auto;
  border: 1px solid rgba(186, 145, 96, 0.52);
  box-shadow:
    0 36px 74px rgba(0, 0, 0, 0.46),
    0 0 0 1px rgba(255, 236, 208, 0.14) inset,
    0 0 60px rgba(140, 95, 68, 0.12) inset;
  transform:
    translateY(var(--lift, 0px))
    rotateX(var(--rx, 0deg))
    rotateY(var(--ry, 0deg))
    scale(var(--paper-scale, 1));
  transform-style: preserve-3d;
  transition: transform 0.45s var(--ease-out), box-shadow 0.5s ease;
}

.envelope-cover__paper::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 5;
  border: 1px solid rgba(150, 106, 70, 0.14);
  border-radius: 2px;
  pointer-events: none;
}

.envelope-cover__flap {
  position: absolute;
  z-index: 2;
  inset: 0 0 28% 0;
  background: linear-gradient(180deg, #fffaf1 0%, #f7e9d4 70%, #efddc2 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.95s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s ease 0.4s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backface-visibility: hidden;
}

.envelope-cover__flap::after {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  top: 2px;
  height: calc(100% - 4px);
  border-top: 1px solid rgba(148, 103, 66, 0.13);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  pointer-events: none;
}

.envelope-cover.is-open .envelope-cover__flap {
  transform: rotateX(177deg);
  opacity: 0.22;
}

.envelope-cover.is-open .envelope-cover__paper {
  transform: translateY(0) rotateX(0deg) rotateY(0deg) scale(1);
  box-shadow:
    0 40px 90px rgba(0, 0, 0, 0.5),
    0 0 110px rgba(255, 196, 130, 0.3),
    0 0 170px rgba(255, 196, 130, 0.16);
}

.envelope-cover__glow {
  position: absolute;
  z-index: 1;
  inset: 11% 9% 16%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 26%, rgba(255, 248, 226, 0.95), rgba(255, 204, 148, 0.5) 38%, transparent 72%);
  filter: blur(9px);
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 0.8s ease 0.15s, transform 1.1s var(--ease-out);
  pointer-events: none;
}

.envelope-cover.is-open .envelope-cover__glow {
  opacity: 1;
  transform: scale(1.16);
  filter: blur(7px);
  background: radial-gradient(ellipse at 50% 22%, rgba(255, 252, 238, 0.98), rgba(255, 208, 150, 0.64) 36%, transparent 72%);
  box-shadow: 0 0 80px rgba(255, 196, 130, 0.3);
}

.envelope-cover__address {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  font-family: var(--font-serif);
  font-size: clamp(15px, 1.65vw, 21px);
  letter-spacing: 0.16em;
  padding-left: 0.16em;
  color: #5b3c2f;
  white-space: nowrap;
  transition: opacity 0.4s ease;
}

.envelope-cover.is-open .envelope-cover__address { opacity: 0.35; }

.envelope-cover__stamp {
  position: absolute;
  z-index: 3;
  top: 6%;
  right: 6%;
  width: clamp(26px, 3vw, 36px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(160, 110, 70, 0.4);
  border-radius: 50%;
  background: rgba(255, 248, 236, 0.45);
  color: rgba(160, 110, 70, 0.7);
  font-size: 11px;
  box-shadow: 0 0 0 3px rgba(255, 247, 235, 0.25);
}

.envelope-cover__postmark {
  position: absolute;
  z-index: 3;
  left: 6%;
  bottom: 5.5%;
  font-family: var(--font-latin);
  font-size: clamp(6px, 0.75vw, 8px);
  letter-spacing: 0.28em;
  color: rgba(122, 82, 60, 0.36);
}

.envelope-cover__seal {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 71%;
  width: clamp(52px, 5.6vw, 68px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(-5deg);
  border-radius: 46% 54% 48% 52% / 54% 46% 52% 48%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 36% 28%, #d26067 0%, #b53745 40%, #8e2333 74%, #5f1422 100%);
  box-shadow:
    inset 0 3px 6px rgba(255, 190, 180, 0.35),
    inset 0 -6px 12px rgba(55, 8, 18, 0.5),
    0 8px 18px rgba(40, 8, 12, 0.35);
  color: rgba(255, 224, 205, 0.95);
  font-family: var(--font-serif);
  font-size: clamp(16px, 1.8vw, 21px);
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
  transition: transform 0.55s var(--ease-out), opacity 0.5s ease, box-shadow 0.4s ease;
  animation: coverSealPulse 3.4s ease-in-out infinite;
}

.envelope-cover__seal::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 214, 195, 0.32);
}

.envelope-cover__seal::after {
  content: "";
  position: absolute;
  left: 18%;
  top: 18%;
  width: 22%;
  height: 13%;
  border-radius: 50%;
  background: rgba(255, 228, 210, 0.3);
  transform: rotate(-24deg);
  filter: blur(1px);
}

.envelope-cover__seal > span { position: relative; z-index: 2; }

.seal-crack {
  position: absolute;
  z-index: 3;
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 3px;
  transform: translateX(-50%) rotate(8deg) scaleY(0.2);
  background: linear-gradient(180deg, transparent, rgba(55, 8, 18, 0.98) 18%, rgba(255, 246, 228, 0.95) 50%, rgba(55, 8, 18, 0.98) 82%, transparent);
  filter: drop-shadow(0 0 5px rgba(255, 208, 160, 0.85));
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.28s var(--ease-out);
}

.seal-crack::before,
.seal-crack::after {
  content: "";
  position: absolute;
  width: 1.5px;
  height: 38%;
  background: rgba(55, 8, 18, 0.92);
  left: 0;
  top: 24%;
  transform-origin: top center;
}

.seal-crack::before { transform: rotate(31deg); }
.seal-crack::after { transform: rotate(-34deg); top: 50%; }

.envelope-cover.is-cracking .envelope-cover__seal {
  animation: sealShake 0.4s ease-in-out;
  box-shadow:
    inset 0 3px 6px rgba(255, 190, 180, 0.35),
    inset 0 -6px 12px rgba(55, 8, 18, 0.5),
    0 8px 18px rgba(40, 8, 12, 0.35),
    0 0 34px rgba(255, 182, 138, 0.5);
  filter: brightness(1.18);
}

.envelope-cover.is-cracking .envelope-cover__seal::before {
  border-color: rgba(255, 232, 205, 0.68);
  box-shadow: 0 0 12px rgba(255, 205, 170, 0.5);
}

.envelope-cover.is-cracking .seal-crack {
  opacity: 1;
  transform: translateX(-50%) rotate(8deg) scaleY(1);
}

.envelope-cover.is-open .envelope-cover__seal {
  transform: translate(-50%, -50%) rotate(22deg) scale(1.45);
  opacity: 0;
  animation: none;
}

.envelope-cover:hover .envelope-cover__paper,
.envelope-cover:focus-visible .envelope-cover__paper {
  --lift: -5px;
  --paper-scale: 1.012;
  box-shadow:
    0 40px 86px rgba(0, 0, 0, 0.5),
    0 0 68px rgba(255, 204, 148, 0.2),
    0 0 0 1px rgba(255, 236, 208, 0.2) inset;
}

.envelope-cover:hover .envelope-cover__seal {
  transform: translate(-50%, -50%) rotate(0deg) scale(1.045);
  animation-play-state: paused;
}

.envelope-cover:focus-visible {
  outline: 2px solid rgba(255, 230, 190, 0.92);
  outline-offset: 10px;
  border-radius: 4px;
}

.envelope-cover.is-open { cursor: default; }

.cover-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: clamp(23px, 3.6vh, 32px) 0 0;
  font-size: 11.5px;
  letter-spacing: 0.18em;
  color: rgba(255, 231, 197, 0.74);
}

.pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ffd9a0;
  box-shadow: 0 0 10px rgba(255, 217, 160, 0.65);
  animation: hintPulse 2.6s ease-in-out infinite;
}

.cover-note {
  margin: 12px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: rgba(230, 220, 255, 0.48);
}

/* ---------- Chronicle · cosmic scale ---------- */
.scene--chronicle {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top) + clamp(118px, 17vh, 176px))
    22px
    120px;
  overflow: hidden;
}

.chronicle-inner {
  position: relative;
  z-index: 2;
  width: min(940px, 100%);
  text-align: center;
  margin-top: clamp(6px, 3vh, 26px);
}

.chronicle-copy {
  min-height: 3.5em;
  margin-top: clamp(20px, 3.4vh, 30px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chronicle-line {
  margin: 0 auto;
  max-width: 880px;
  font-size: clamp(23px, 3.1vw, 41px);
  font-weight: 400;
  line-height: 1.52;
  letter-spacing: 0.07em;
  color: var(--text);
  text-shadow: 0 0 44px rgba(255, 217, 160, 0.13);
  opacity: 0;
}

.chronicle-line.is-shown { animation: chronicleLineIn 1.1s var(--ease-out) both; }

.chronicle-ticks {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: clamp(22px, 3.4vh, 32px);
}

.chronicle-ticks i {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 247, 240, 0.2);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.chronicle-ticks i.is-on {
  background: #ffd9a0;
  box-shadow: 0 0 9px rgba(255, 217, 160, 0.65);
}

/* ---------- Heart hold interaction ---------- */
.heart-hold-zone {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 55%;
  width: min(76vw, 680px);
  height: min(48vh, 460px);
  transform: translate(-50%, -50%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.heart-hold {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  min-height: 44px;
  padding: 9px 20px;
  border: 1px solid rgba(255, 217, 160, 0.24);
  border-radius: 999px;
  background: rgba(5, 6, 15, 0.28);
  color: rgba(255, 236, 212, 0.64);
  font-family: var(--font-serif);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease, box-shadow 0.4s ease;
}

.heart-hold:hover,
.heart-hold:focus-visible {
  color: #ffe4b8;
  border-color: rgba(255, 217, 160, 0.62);
  background: rgba(18, 13, 30, 0.5);
}

.scene--heart.is-held .heart-hold {
  color: #fff1d9;
  border-color: rgba(255, 217, 160, 0.82);
  box-shadow: 0 0 34px rgba(255, 122, 168, 0.24);
}

.scene--heart.is-held .heart-glow { animation-duration: 0.62s; }

.scene--heart.is-held .bpm-dot { animation-duration: 0.56s; }

/* ---------- Wishes · constellation ---------- */
.scene--wishes {
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top) + clamp(92px, 13vh, 134px))
    22px
    calc(env(safe-area-inset-bottom) + 84px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.wishes-inner {
  position: relative;
  z-index: 2;
  width: min(1020px, 100%);
  text-align: center;
}

.wishes-head { padding: 0 8px; }

.wishes-title {
  margin: clamp(14px, 2.2vh, 20px) 0 0;
  font-size: clamp(23px, 3vw, 38px);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.07em;
  color: rgba(255, 247, 240, 0.96);
  text-shadow:
    0 0 42px rgba(255, 170, 190, 0.14),
    0 2px 16px rgba(5, 6, 15, 0.68);
}

body[data-scene="wishes"] .moon-wrap { opacity: 0.4; }

.wishes-sub {
  margin: clamp(10px, 1.8vh, 14px) 0 0;
  font-size: clamp(11.5px, 1.2vw, 13px);
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

.wish-map {
  position: relative;
  width: 100%;
  height: clamp(265px, 34vh, 330px);
  margin: clamp(15px, 2.6vh, 24px) auto 0;
}

.wish-map::before {
  content: "";
  position: absolute;
  inset: 6% 10%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(109, 93, 246, 0.09), transparent 64%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 122, 168, 0.045), transparent 72%);
  pointer-events: none;
}

.wish-map__orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 68%;
  height: 56%;
  transform: translate(-50%, -50%) rotate(-8deg);
  border: 1px solid rgba(255, 217, 160, 0.12);
  border-radius: 50%;
  pointer-events: none;
}

.wish-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wish-line {
  fill: none;
  stroke: url(#wishGold);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px rgba(255, 217, 160, 0.45));
  transition: stroke-dashoffset 1.15s var(--ease-out);
}

.wish-line.is-drawn { stroke-dashoffset: 0; }

.wish-heart-line {
  fill: none;
  stroke: url(#wishHeartGrad);
  stroke-width: 0.8;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  filter: drop-shadow(0 0 4px rgba(255, 170, 190, 0.34));
  transition: stroke-dashoffset 2s var(--ease-out), opacity 0.8s ease;
}

.wish-map.is-complete .wish-heart-line {
  stroke-dashoffset: 0;
  opacity: 0.72;
}

.wish-stars { position: absolute; inset: 0; }

.wish-star {
  position: absolute;
  left: var(--wx);
  top: var(--wy);
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 247, 240, 0.55);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s var(--ease-out), color 0.35s ease;
}

.wish-star__glyph {
  position: relative;
  z-index: 2;
  font-size: 15px;
  line-height: 1;
  color: currentColor;
  text-shadow: 0 0 10px rgba(255, 247, 240, 0.2);
  transition: color 0.4s ease, text-shadow 0.4s ease, transform 0.4s var(--ease-out);
}

.wish-star__ring {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255, 217, 160, 0.16);
  transition: border-color 0.4s ease, box-shadow 0.4s ease, inset 0.4s ease;
}

.wish-star__num {
  position: absolute;
  top: 1px;
  right: 0;
  font-family: var(--font-latin);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(255, 217, 160, 0.52);
  transition: color 0.4s ease;
}

.wish-star__name {
  position: absolute;
  top: calc(100% - 6px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: rgba(255, 247, 240, 0.5);
  white-space: nowrap;
  pointer-events: none;
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.wish-star:hover { transform: translate(-50%, -50%) scale(1.08); color: rgba(255, 236, 200, 0.9); }
.wish-star:hover .wish-star__ring { border-color: rgba(255, 217, 160, 0.4); }
.wish-star:hover .wish-star__name { color: rgba(255, 240, 220, 0.8); }

.wish-star:focus-visible {
  outline: 2px solid rgba(255, 230, 190, 0.9);
  outline-offset: 3px;
}

.wish-star.is-lit {
  color: #ffe1b2;
}

.wish-star.is-lit .wish-star__glyph {
  color: #ffe1b2;
  text-shadow: 0 0 12px rgba(255, 217, 160, 0.85), 0 0 30px rgba(255, 122, 168, 0.55);
  animation: starLit 1.2s ease-out;
}

.wish-star.is-lit .wish-star__ring {
  inset: 6px;
  border-color: rgba(255, 217, 160, 0.65);
  box-shadow: 0 0 18px rgba(255, 217, 160, 0.18), 0 0 34px rgba(255, 122, 168, 0.13);
}

.wish-star.is-lit .wish-star__num { color: rgba(255, 217, 160, 0.85); }
.wish-star.is-lit .wish-star__name {
  color: rgba(255, 231, 197, 0.9);
  text-shadow: 0 0 12px rgba(255, 217, 160, 0.2);
}

.wish-star.is-flash { animation: wishFlash 0.65s var(--ease-out); }

.wish-detail {
  position: relative;
  min-height: 78px;
  margin-top: clamp(8px, 1.6vh, 14px);
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.wish-detail__index {
  margin: 0 0 7px;
  font-family: var(--font-latin);
  font-size: 10.5px;
  letter-spacing: 0.26em;
  color: rgba(255, 217, 160, 0.62);
}

.wish-detail__text {
  margin: 0;
  max-width: 660px;
  font-size: clamp(13px, 1.45vw, 15px);
  line-height: 1.75;
  letter-spacing: 0.06em;
  color: rgba(255, 247, 240, 0.82);
}

.wish-detail.is-updated .wish-detail__index,
.wish-detail.is-updated .wish-detail__text {
  animation: wishTextIn 0.7s var(--ease-out) both;
}

.wishes-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.wishes-continue {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.7s var(--ease-out), visibility 0s 0.7s;
}

.wishes-continue.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.7s ease, transform 0.7s var(--ease-out), visibility 0s;
}

.wishes-continue.is-complete {
  border-color: rgba(255, 217, 160, 0.82);
  box-shadow: 0 0 38px rgba(255, 217, 160, 0.18);
  color: #fff1d8;
}

.wishes-skip,
.scene-advance.wishes-skip {
  position: relative;
  left: auto;
  transform: none;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(230, 220, 255, 0.54);
}

.wishes-skip::after { display: none; }
.wishes-skip:hover { color: rgba(255, 231, 197, 0.72); }
