@import url('https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&family=Noto+Sans+KR:wght@300;400;500&display=swap');

:root {
  --paper: #fdfaf6;
  --paper-tint: #f7f0e8;
  --ink: #3d3733;
  --ink-soft: #7a716a;
  --ink-faint: #a99e95;
  --rose: #c2938b;
  --rose-dark: #9d6a61;
  --line: #e8ddd1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #efe7dd;
  color: var(--ink);
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

.serif, .cover-names, .section-title, .big-date, .venue-name,
.chapter-title, .letter-body, .closing-names, .gate-names {
  font-family: 'Gowun Batang', serif;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: 0 0 50px rgba(80,55,35,0.10);
  overflow-x: hidden;
}

/* ================= 입장 화면 ================= */
.gate-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #f5e9e1 0%, #efdfd3 45%, #e6cfc2 100%);
  padding: 24px;
}
.gate-card {
  background: rgba(255,255,255,0.9);
  border-radius: 4px;
  padding: 56px 32px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(100,70,50,0.16);
  border: 1px solid rgba(255,255,255,0.6);
}
.gate-eyebrow {
  letter-spacing: 0.3em;
  font-size: 0.65rem;
  color: var(--rose-dark);
  margin: 0 0 18px;
}
.gate-names { font-size: 1.7rem; margin: 0 0 20px; letter-spacing: 0.05em; }
.gate-sub { color: var(--ink-soft); font-size: 0.85rem; line-height: 1.8; margin-bottom: 28px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-form input {
  padding: 14px 16px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.3em;
  font-family: inherit;
}
.gate-form input:focus { outline: none; border-color: var(--rose); }
.gate-form button {
  padding: 14px;
  border-radius: 2px;
  border: none;
  background: var(--rose);
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  font-family: inherit;
  cursor: pointer;
}
.gate-form button:active { background: var(--rose-dark); }
.gate-error { color: #b3413a; margin-top: 16px; font-size: 0.8rem; }

/* ================= 표지 ================= */
.cover {
  position: relative;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #dfcbbc;
  animation: slowZoom 24s ease-out forwards;
}
@keyframes slowZoom {
  from { transform: scale(1.12); }
  to   { transform: scale(1); }
}
.cover-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(35,25,20,0.32) 0%, rgba(35,25,20,0.18) 45%, rgba(35,25,20,0.62) 100%);
}
.cover-text {
  position: relative;
  text-align: center;
  color: #fff;
  padding: 0 32px;
  animation: fadeUp 1.6s ease-out both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cover-eyebrow {
  letter-spacing: 0.42em;
  font-size: 0.62rem;
  margin: 0 0 26px;
  opacity: 0.85;
}
.cover-names {
  font-size: 2.1rem;
  margin: 0;
  line-height: 1.9;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}
.cover-names span { display: block; }
.cover-amp {
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  opacity: 0.8;
  font-family: 'Noto Sans KR', sans-serif;
  margin: 4px 0;
}
.cover-rule {
  width: 40px;
  height: 1px;
  background: rgba(255,255,255,0.6);
  margin: 26px auto;
}
.cover-date {
  font-size: 1rem;
  letter-spacing: 0.28em;
  margin: 0 0 10px;
}
.cover-venue {
  font-size: 0.78rem;
  opacity: 0.85;
  margin: 0;
  letter-spacing: 0.04em;
}
.scroll-cue {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 44px;
  background: rgba(255,255,255,0.35);
  overflow: hidden;
}
.scroll-cue span {
  display: block;
  width: 100%;
  height: 14px;
  background: #fff;
  animation: cueDrop 2.2s ease-in-out infinite;
}
@keyframes cueDrop {
  0%   { transform: translateY(-14px); opacity: 0; }
  40%  { opacity: 1; }
  100% { transform: translateY(44px); opacity: 0; }
}

/* ================= 공통 섹션 ================= */
.section {
  padding: 76px 32px;
  text-align: center;
}
.section-tint { background: var(--paper-tint); }
.label {
  font-size: 0.6rem;
  letter-spacing: 0.36em;
  color: var(--rose-dark);
  margin: 0 0 12px;
}
.section-title {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: 0.08em;
  font-weight: 400;
}
.ornament {
  color: var(--rose);
  font-size: 0.9rem;
  margin: 20px 0 28px;
  opacity: 0.7;
}
.body-text {
  white-space: pre-line;
  line-height: 2.5;
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 0;
  letter-spacing: 0.01em;
}
.signature {
  margin-top: 34px;
  font-size: 0.85rem;
  color: var(--ink-faint);
  letter-spacing: 0.14em;
}

/* ---- 달력 ---- */
.big-date {
  font-size: 1.05rem;
  margin: 24px 0 32px;
  color: var(--ink);
  letter-spacing: 0.03em;
}
.calendar {
  max-width: 300px;
  margin: 0 auto;
  padding: 22px 12px;
  background: #fff;
  border: 1px solid var(--line);
}
.cal-head, .cal-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-head {
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.cal-dow {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.cal-day {
  font-size: 0.82rem;
  padding: 9px 0;
  color: var(--ink-soft);
  position: relative;
}
.cal-dow.sun, .cal-day.sun { color: #c58a84; }
.cal-day.marked {
  color: #fff;
  font-weight: 500;
}
.cal-day.marked::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--rose);
  transform: translate(-50%, -50%);
  z-index: -1;
}
.cal-row { position: relative; z-index: 0; }
.dday {
  display: inline-block;
  margin-top: 28px;
  padding: 9px 24px;
  border: 1px solid var(--rose);
  color: var(--rose-dark);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  border-radius: 999px;
}

/* ---- 오시는 길 ---- */
.venue-name { font-size: 1.1rem; margin: 0 0 10px; letter-spacing: 0.03em; }
.venue-address { color: var(--ink-soft); font-size: 0.85rem; margin: 0 0 26px; line-height: 1.8; }
.venue-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip-btn {
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
}
.chip-btn:active { background: var(--paper-tint); }

/* ================= 앨범 ================= */
.album { padding: 76px 0 60px; }
.album-intro { text-align: center; padding: 0 32px; }
.album-count {
  color: var(--ink-faint);
  font-size: 0.78rem;
  line-height: 1.9;
  margin: 0 0 8px;
}
.chapter { margin-top: 48px; }
.chapter-head { text-align: center; margin-bottom: 16px; padding: 0 32px; }
.chapter-title {
  font-size: 1.05rem;
  margin: 0 0 6px;
  font-weight: 400;
  letter-spacing: 0.1em;
  position: relative;
  display: inline-block;
  padding: 0 18px;
}
.chapter-title::before, .chapter-title::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 14px;
  height: 1px;
  background: var(--line);
}
.chapter-title::before { left: -6px; }
.chapter-title::after { right: -6px; }
.chapter-sub { font-size: 0.72rem; color: var(--ink-faint); margin: 0; letter-spacing: 0.06em; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 0 3px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #e8ded4;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}
.gallery-item:active img { transform: scale(1.04); }
.play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  background: rgba(0,0,0,0.22);
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
}
.empty-gallery { color: var(--ink-faint); font-size: 0.85rem; text-align: center; padding: 20px 32px; }

/* ================= 부모님께 ================= */
.letter {
  background: #fff;
  border: 1px solid var(--line);
  padding: 34px 26px;
  margin-bottom: 18px;
  text-align: center;
}
.letter-to {
  font-size: 0.8rem;
  color: var(--rose-dark);
  letter-spacing: 0.14em;
  margin: 0 0 22px;
}
.letter-body {
  white-space: pre-line;
  line-height: 2.4;
  font-size: 0.9rem;
  color: var(--ink);
  margin: 0;
}
.letter-from {
  margin: 24px 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
}

/* ================= 맺음말 ================= */
.closing { padding-bottom: 96px; }
.closing-names {
  margin: 34px 0 6px;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
}
.closing-date {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
  letter-spacing: 0.2em;
}

/* ================= 스크롤 등장 =================
   기본값은 "보이는 것"이다. 스크립트가 켜졌을 때만(.js) 숨겼다가 나타낸다 —
   이렇게 해두면 자바스크립트가 어떤 이유로든 안 돌아도 글이 안 사라진다. */
.reveal { opacity: 1; }
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1.1s ease, transform 1.1s ease;
}
.js .reveal.shown { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .cover-photo { animation: none; }
  .scroll-cue span { animation: none; }
}

/* ================= 배경음악 단추 ================= */
.bgm-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(40,30,25,0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bgm-icon { display: block; opacity: 0.75; }
.bgm-toggle.playing .bgm-icon {
  opacity: 1;
  animation: bgmSpin 3.2s linear infinite;
}
@keyframes bgmSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .bgm-toggle.playing .bgm-icon { animation: none; }
}

/* ================= 크게 보기 ================= */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20,15,12,0.95);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* hidden 속성이 display:flex 에 지므로 여기서 명시적으로 감춘다.
   이게 없으면 라이트박스가 처음부터 화면을 덮는다. */
.lightbox[hidden] { display: none; }
.lb-media {
  max-width: 92vw;
  max-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-media img, .lb-media video {
  max-width: 92vw;
  max-height: 72vh;
  object-fit: contain;
}
.lb-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  padding: 12px;
  font-family: inherit;
  cursor: pointer;
  z-index: 2;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 2.2rem;
  padding: 12px 16px;
  cursor: pointer;
  z-index: 2;
}
.lb-prev { left: 2px; }
.lb-next { right: 2px; }
.lb-actions {
  position: absolute;
  bottom: 26px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 2;
}
.lb-save {
  display: inline-block;
  background: var(--rose);
  color: #fff;
  padding: 12px 26px;
  border: none;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}
.lb-save:disabled { opacity: 0.6; }
.lb-hint {
  display: block;
  margin-top: 12px;
  color: rgba(255,255,255,0.55);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  line-height: 1.7;
}

/* ================= 관리 화면 ================= */
.manage-page { padding: 40px 24px 70px; text-align: center; }
.manage-hint { color: var(--ink-soft); font-size: 0.8rem; margin-bottom: 22px; line-height: 1.8; }
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  padding: 24px 20px;
  border: 1px dashed var(--line);
  background: #fff;
  text-align: left;
}
.upload-form label { font-size: 0.75rem; color: var(--ink-soft); letter-spacing: 0.08em; }
.upload-form select, .upload-form input[type=file] {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  width: 100%;
}
.upload-form button {
  padding: 13px 24px;
  border-radius: 999px;
  border: none;
  background: var(--rose);
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.upload-form button:disabled { opacity: 0.5; }
.upload-status { color: var(--rose-dark); font-size: 0.8rem; margin-top: 14px; }
.manage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.manage-item {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
}
.manage-thumb { position: relative; aspect-ratio: 1/1; overflow: hidden; background: #e8ded4; }
.manage-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.manage-item select {
  width: 100%;
  margin-top: 6px;
  font-family: inherit;
  font-size: 0.72rem;
  padding: 5px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.delete-btn {
  width: 100%;
  margin-top: 4px;
  background: none;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 5px;
  cursor: pointer;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field input[type=text], .field textarea {
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.9;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  width: 100%;
  resize: vertical;
}
.field-note { font-size: 0.68rem; color: var(--ink-faint); margin: 0; }
.manage-item.is-cover { border-color: var(--rose); box-shadow: 0 0 0 1px var(--rose); }
.cover-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--rose);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}
.cover-btn {
  width: 100%;
  margin-top: 6px;
  background: #fff;
  color: var(--rose-dark);
  border: 1px solid var(--rose);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 5px;
  cursor: pointer;
}
.manage-back { margin-top: 36px; }
.manage-back a { color: var(--ink-soft); font-size: 0.8rem; }
