/* =========================================================
   두근두근 2주년 ♡  —  style.css
   가독성 > 감정선 > 애니메이션 > 장식
   ========================================================= */

:root {
  --accent: #ff4f9e;            /* 단계별로 JS가 갱신 */
  --accent-strong: #ff2d86;
  --accent-soft: rgba(255, 79, 158, 0.14);

  --card-bg: rgba(255, 255, 255, 0.9);
  --card-border: rgba(255, 255, 255, 0.65);
  --card-shadow: 0 18px 50px rgba(60, 20, 60, 0.18);

  --ink: #2b2440;               /* 카드 위 본문 (항상 어두운 글자) */
  --ink-soft: #5b5278;
  --ink-faint: #8a8199;

  --correct: #14a06a;
  --correct-bg: rgba(20, 160, 106, 0.12);
  --wrong: #d8466f;
  --wrong-bg: rgba(216, 70, 111, 0.10);

  --radius: 24px;
  --radius-sm: 16px;

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, "Segoe UI",
    sans-serif;

  --fade: 0.55s;
}

* { box-sizing: border-box; }

/* hidden 속성은 어떤 display 규칙보다 우선한다.
   (.btn 등이 display:inline-flex 를 지정해 [hidden] 을 덮어쓰지 않도록 — 버튼·안내문구 확실히 숨김) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: #0a0814;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100svh;
}

/* 한국어 줄바꿈 기본값: 단어 단위 보존 */
.title, .title-sub, .eyebrow, .question, .interp, .choice-text,
.pl, .letter p, .letter-to, .more-hint, .btn, .result-badge, .qnum {
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* =========================================================
   배경 (고정) — 두 레이어 크로스페이드로 부드럽게 전환
   ========================================================= */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #0a0814;
}
.sky-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
  will-change: opacity;
}
.sky-layer.on { opacity: 1; }

.sheen {
  position: absolute;
  inset: -20%;
  background: radial-gradient(
    closest-side,
    var(--accent-soft) 0%,
    rgba(255, 255, 255, 0) 70%
  );
  opacity: 0.6;
  transform: translate(0, 0);
  transition: background 1.2s ease;
  pointer-events: none;
  mix-blend-mode: screen;
}

#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    130% 100% at 50% 18%,
    rgba(0, 0, 0, 0) 55%,
    rgba(0, 0, 0, 0.22) 100%
  );
  opacity: 0;
  transition: opacity 1.2s ease;
}

/* =========================================================
   스테이지 / 스크린
   ========================================================= */
.stage { position: relative; z-index: 1; }

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100svh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7vh 20px calc(6vh + env(safe-area-inset-bottom, 0px));
  padding-top: calc(7vh + env(safe-area-inset-top, 0px));
}
.screen.is-active {
  display: flex;
  animation: screenIn var(--fade) ease both;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   카드 (프로스티드 — 배경이 어두워져도 글자 대비 유지)
   ========================================================= */
.card {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow), 0 0 0 6px rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  padding: 30px 24px 26px;
  position: relative;
}

/* =========================================================
   버튼 공통
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.16s ease, box-shadow 0.2s ease,
    background 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.96); }

/* =========================================================
   1) 타이틀
   ========================================================= */
.titlecard { text-align: center; padding: 40px 26px 34px; }

.eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.32em;
  color: var(--accent-strong);
  opacity: 0.85;
}
.title {
  margin: 0;
  font-size: clamp(38px, 12vw, 52px);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: -0.01em;
  background: linear-gradient(140deg, #ff7ab8 0%, #ff4f9e 50%, #c45fd6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ff4f9e;
  filter: drop-shadow(0 4px 14px rgba(255, 95, 168, 0.35));
}
.title-heart {
  display: inline-block;
  -webkit-text-fill-color: #ff5fa8;
  color: #ff5fa8;
  animation: beat 1.5s ease-in-out infinite;
}
.title-sub {
  margin: 16px 0 30px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.btn-start {
  padding: 17px 40px;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(135deg, #ff7ab8, #ff3f93);
  box-shadow: 0 12px 30px rgba(255, 63, 147, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: beatBtn 1.6s ease-in-out infinite;
}
.btn-start span { position: relative; }
.btn-start::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(255, 95, 168, 0.5);
  animation: ring 1.6s ease-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1); }
  45% { transform: scale(1.12); }
  60% { transform: scale(1); }
}
@keyframes beatBtn {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.05); }
  24% { transform: scale(1); }
  36% { transform: scale(1.03); }
  48% { transform: scale(1); }
}
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(255, 95, 168, 0.5); }
  70% { box-shadow: 0 0 0 22px rgba(255, 95, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 95, 168, 0); }
}

/* =========================================================
   2) 프롤로그
   ========================================================= */
.prologuecard { text-align: center; padding: 38px 26px 30px; }
.prologue-text { margin-bottom: 30px; }
.pl {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.7;
  color: var(--ink);
  opacity: 0;
  transform: translateY(8px);
}
.pl-3 { color: var(--ink-soft); font-style: normal; }
.pl-4 { margin-bottom: 0; font-weight: 700; }
.screen.is-active .pl { animation: plIn 0.7s ease forwards; }
.screen.is-active .pl-1 { animation-delay: 0.15s; }
.screen.is-active .pl-2 { animation-delay: 0.75s; }
.screen.is-active .pl-3 { animation-delay: 1.45s; }
.screen.is-active .pl-4 { animation-delay: 2.0s; }
@keyframes plIn {
  to { opacity: 1; transform: translateY(0); }
}
.btn-soft {
  padding: 15px 38px;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, #ff7ab8, #c45fd6);
  box-shadow: 0 10px 26px rgba(196, 95, 214, 0.36);
  opacity: 0;
  animation: plIn 0.7s ease forwards;
  animation-delay: 2.6s;
}

/* =========================================================
   3) 퀴즈
   ========================================================= */
.quizcard {
  animation: cardRise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes cardRise {
  from { opacity: 0; transform: translateY(22px) rotateX(8deg); }
  to   { opacity: 1; transform: translateY(0) rotateX(0); }
}
.quizcard.swap-out {
  animation: cardOut 0.32s ease forwards;
}
@keyframes cardOut {
  to { opacity: 0; transform: translateY(-16px) scale(0.985); }
}

.qmeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.qmeta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 뒤로 — 감성을 해치지 않게 작고 은은하게 (번호 왼쪽) */
.qback {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 8px 6px 4px;
  margin: -4px 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}
.qback:active { transform: scale(0.96); }
.qback:hover { background: rgba(120, 100, 150, 0.08); color: var(--ink); }
.qback-arrow {
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  margin-top: -1px;
}
/* 첫 문제: 보이지 않게 하되 공간은 유지해 번호 위치가 흔들리지 않도록 */
.qback.is-off { visibility: hidden; pointer-events: none; }

.qnum {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
}
.qdots { display: flex; gap: 5px; }
.qdots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(120, 100, 140, 0.25);
  transition: background 0.4s ease, transform 0.4s ease;
}
.qdots i.done { background: var(--accent); opacity: 0.55; }
.qdots i.cur {
  background: var(--accent);
  transform: scale(1.5);
  box-shadow: 0 0 8px var(--accent);
}

.question {
  margin: 0 0 22px;
  font-size: clamp(19px, 5.4vw, 22px);
  font-weight: 800;
  line-height: 1.55;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.choices { display: flex; flex-direction: column; gap: 11px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  min-height: 56px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(120, 100, 150, 0.18);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s ease, border-color 0.2s ease,
    background 0.2s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}
.choice:active { transform: scale(0.985); }

.choice-mark {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(120, 100, 150, 0.35);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: transparent;
  transition: all 0.2s ease;
}
.choice-text { flex: 1; }

.choice.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 6px 18px var(--accent-soft);
}
.choice.selected .choice-mark {
  border-color: var(--accent);
}

.choice.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}
.choice.correct .choice-mark {
  border-color: var(--correct);
  background: var(--correct);
  color: #fff;
}
.choice.wrong-pick {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}
.choice.wrong-pick .choice-mark {
  border-color: var(--wrong);
  background: var(--wrong);
  color: #fff;
}

/* 결과 / 해석 */
.result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed rgba(120, 100, 150, 0.22);
  animation: resultIn 0.4s ease both;
}
@keyframes resultIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 900;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.result-badge.ok { color: var(--correct); background: var(--correct-bg); }
.result-badge.no { color: var(--wrong); background: var(--wrong-bg); }
.result-badge::before {
  font-size: 13px;
  font-weight: 900;
}
.result-badge.ok::before { content: "✓"; }
.result-badge.no::before { content: "✕"; }

.interp {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.82;
  color: var(--ink);
  letter-spacing: -0.003em;
}

.more-hint {
  margin: 16px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-strong);
  text-align: center;
  opacity: 0.9;
  animation: resultIn 0.4s ease both;
}

.btn-next, .btn-reveal {
  width: 100%;
  margin-top: 22px;
  padding: 16px;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 28px var(--accent-soft);
  animation: resultIn 0.45s ease both;
}
.btn-reveal {
  background: linear-gradient(135deg, #8a72d8, #6f5fb0);
  box-shadow: 0 12px 30px rgba(111, 95, 176, 0.4);
  letter-spacing: 0.01em;
}

/* =========================================================
   4) 편지 (클라이맥스)
   ========================================================= */
.screen-letter {
  justify-content: flex-start;
  padding-top: calc(11vh + env(safe-area-inset-top, 0px));
  padding-bottom: calc(14vh + env(safe-area-inset-bottom, 0px));
}
.letter {
  width: 100%;
  max-width: 600px;
  position: relative;
  padding: 30px 26px 40px;
  border-radius: 26px;
  background: linear-gradient(
    180deg,
    rgba(8, 6, 22, 0.35) 0%,
    rgba(6, 5, 16, 0.55) 100%
  );
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.letter.reveal { animation: none; }

.letter-head { text-align: center; margin-bottom: 30px; }
.letter-to {
  margin: 0 0 18px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #ffd9ec;
  text-shadow: 0 0 18px rgba(255, 150, 200, 0.4);
}
.letter-stanza p {
  margin: 4px 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.7;
  color: #e7dcf2;
}

.letter-body {
  color: #ece3f5;
}
.letter-body p {
  margin: 0 0 1.5em;
  font-size: 16.5px;
  font-weight: 400;
  line-height: 1.98;
  letter-spacing: -0.003em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}
.letter-body p.axis {
  color: #fff;
  font-weight: 500;
}
.letter-body p.sign-1 {
  margin-top: 2.2em;
  text-align: center;
  font-size: 17px;
  color: #f3e9fb;
}
.letter-body p.sign-2 {
  margin-bottom: 0;
  text-align: center;
  font-size: 21px;
  font-weight: 700;
  color: #ffd9ec;
  text-shadow: 0 0 22px rgba(255, 150, 200, 0.5);
}

.letter-end {
  margin-top: 26px;
  text-align: center;
  font-size: 26px;
  color: #ff8fc4;
  text-shadow: 0 0 20px rgba(255, 120, 180, 0.6);
  animation: beat 2.4s ease-in-out infinite;
}

/* 처음부터 다시하기 — 밤하늘과 어울리는 은은한 버튼 (편지 맨 아래) */
.letter-restart {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin: 52px auto 8px;       /* 위로 충분한 여백 → 마지막 문장의 여운 확보 */
  padding: 13px 26px;
  min-height: 48px;            /* 모바일에서 누르기 쉬운 크기 */
  border-radius: 999px;
  border: 1px solid rgba(255, 220, 240, 0.4);
  background: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: #ffe3f1;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease;
}
.letter-restart:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 220, 240, 0.6);
}
.letter-restart:active { transform: scale(0.97); }

/* 편지 등장 연출 — 머리말은 진입 시, 본문·♡·다시하기 버튼은 스크롤에 맞춰 떠오름 */
.letter-head, .letter-body > *, .letter-end, .letter-restart {
  opacity: 0;
  transform: translateY(16px);
}
.letter.play .letter-head { animation: letterIn 1.2s ease forwards 0.15s; }
.letter-body > .in, .letter-end.in, .letter-restart.in {
  animation: letterIn 0.95s ease forwards;
}
@keyframes letterIn {
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   반응형
   ========================================================= */
@media (min-width: 480px) {
  .card { padding: 34px 30px 30px; }
}
@media (max-width: 360px) {
  .screen { padding-left: 14px; padding-right: 14px; }
  .card { padding: 26px 18px 22px; }
  .title { font-size: clamp(34px, 13vw, 46px); }
  .pl { font-size: 16.5px; }
  .question { font-size: 19px; }
  .choice { font-size: 15px; padding: 14px; min-height: 52px; }
  .interp { font-size: 15px; }
  .letter-body p { font-size: 15.5px; }
}
@media (min-height: 760px) {
  .screen { justify-content: center; }
}

/* PC에서 과하게 커지지 않도록 */
@media (min-width: 760px) {
  .card { max-width: 460px; }
}

/* =========================================================
   모션 최소화 선호
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.12s !important;
  }
  .pl, .letter-head, .letter-body > *, .letter-end, .letter-restart {
    opacity: 1 !important;
    transform: none !important;
  }
  .btn-start::after { display: none; }
}
