/* Reset & base */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%;
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: 'Nanum Pen Script', sans-serif;
  background: #fff;
}

/* ==== 컨테이너 (PC 가로 슬라이드 / 모바일 세로 스택) ==== */
#container {
  display: flex;
  width: 400%; /* 기존 300% → 4섹션으로 400% */
  min-height: 100vh;
  height: auto;
  transition: transform 1s cubic-bezier(.86,0,.07,1);
}

.section {
  width: 100vw;
  min-height: 100vh;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

/* ==== Intro ==== */
#intro {
  background: linear-gradient(to right, #ffe0ea, #ffeef3);
  text-align: center;
}
#intro h1 { font-size: 2.4rem; color: #d9436f; margin-bottom: 2rem; }
#intro button {
  font-size: 1.3rem; padding: 12px 30px; background: #ff8fa3;
  border: none; border-radius: 30px; color: white; cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
#typedText { font-size: 2rem; color: #d9436f; min-height: 3em; }

/* ==== Menu (신규) ==== */
#menu{
  background: #0e0b16;
  text-align:center;
  padding: 56px 20px;
}
#menu .menu-title{
  font-size: clamp(22px,3vw,28px);
  color:#fff;
  font-weight: 800;
  margin-bottom: 22px;
}
#menu .menu-grid{
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px,1fr));
  gap: 16px;
}
.menu-link{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding: 22px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.menu-link small{ display:block; margin-top:8px; font-weight:500; opacity:.9; }
.menu-link:hover{
  transform: translateY(-4px);
  filter: brightness(1.05);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.menu-hint{ color:#d0cde1; opacity:.9; margin-top:16px; font-size:16px }

/* ==== Main (앨범) ==== */
#main {
  background: #fff6fa;
  text-align: center;
  overflow-y: clip;
  padding-bottom: 30px;
}
#main h2 { font-size: 2rem; color: #c24063; }

.memory-album {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 30px;
}
.album-card {
  border-radius: 22px;
  padding: 24px 16px 16px 16px;
  width: 320px;
  min-width: 260px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow .3s;
  position: relative;
  margin-bottom: 20px;
  background: #fff;
  box-shadow: 0 4px 22px rgba(220,60,130,0.08);
}
.album-card .album-desc { text-align: center; margin-top: 9px; }
.album-card .album-date {
  font-weight: bold; font-size: 16px; margin-bottom: 4px; opacity: 0.9;
}
.album-card .album-caption {
  font-size: 1.18rem; font-family: 'Nanum Pen Script', cursive;
  color: #c24063; margin-bottom: 4px; line-height: 1.5;
}

/* Swiper */
.memory-swiper {
  width: 100%; height: 260px; border-radius: 14px; overflow: hidden;
  margin-bottom: 12px; box-shadow: 0 2px 14px rgba(220,60,130,0.11);
  background: #fdf6fa;
}
.memory-swiper img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 14px; }

/* 앨범별 고유 디자인(기존 유지) */
.album-card.first-memory { background: linear-gradient(120deg, #fff7f0 65%, #ffe1ef 100%); border: 2.5px solid #ffd5e5; box-shadow: 0 8px 28px #ffb5d6a2;}
.album-card.first-memory .album-date { color: #d9436f;}
.album-card.first-memory .swiper-pagination-bullet { background: #fc82c7;}
.album-card.first-memory .swiper-pagination-bullet-active { background: #d9436f;}

.album-card.beach-day { background: linear-gradient(135deg, #e8f6fb 60%, #c7e8fd 100%); border: 2.5px solid #a2defc; box-shadow: 0 7px 28px #92dafcb3;}
.album-card.beach-day .album-date { color: #39a0e6;}
.album-card.beach-day .swiper-pagination-bullet { background: #58cdfa;}
.album-card.beach-day .swiper-pagination-bullet-active { background: #0072be;}

.album-card.cafe-date { background: linear-gradient(135deg, #f8ede2 70%, #f9c7b9 100%); border: 2.5px solid #f5a97f; box-shadow: 0 6px 26px #f6c1b89c; border-radius: 30px;}
.album-card.cafe-date .album-date { color: #b8833a;}
.album-card.cafe-date .swiper-pagination-bullet { background: #f7bc9d;}
.album-card.cafe-date .swiper-pagination-bullet-active { background: #e67b3c;}

.album-card.car { background: linear-gradient(130deg, #f0f7ff 70%, #ffd7e2 100%); border: 2.5px solid #a8d7fa; box-shadow: 0 8px 30px #a8d7fa88;}
.album-card.car .album-date { color: #379edb;}
.album-card.car .swiper-pagination-bullet { background: #77d1fd;}
.album-card.car .swiper-pagination-bullet-active { background: #3889ca;}
.album-card.car .album-caption { color: #1976a6; font-size: 1.16rem; letter-spacing: 0.1em;}

.album-card.movie { background: linear-gradient(120deg, #f6e6ff 65%, #ffd9ec 100%); border: 2.5px solid #d2b2f7; box-shadow: 0 7px 26px #d2b2f77a;}
.album-card.movie .album-date { color: #a25fc7;}
.album-card.movie .swiper-pagination-bullet { background: #b488ef;}
.album-card.movie .swiper-pagination-bullet-active { background: #ab2e6c;}
.album-card.movie .album-caption { color: #99378a; font-size: 1.15rem; font-family: 'Nanum Pen Script', cursive; letter-spacing: 0.03em;}

.album-card.soccer { background: linear-gradient(120deg, #e8fff3 65%, #b6ffd6 100%); border: 2.5px solid #42d787; box-shadow: 0 8px 28px #75eab7a2; border-radius: 24px;}
.album-card.soccer .album-date { color: #00995e; font-weight: bold; letter-spacing: 0.08em;}
.album-card.soccer .swiper-pagination-bullet { background: #62edac;}
.album-card.soccer .swiper-pagination-bullet-active { background: #00995e;}
.album-card.soccer .album-caption { color: #00995e; font-size: 1.17rem; font-family: 'Nanum Pen Script', cursive; letter-spacing: 0.06em; line-height: 1.5;}
.album-card.soccer .cafe-emoji { font-size: 1.3em;}

.album-card.everland { background: linear-gradient(120deg, #fffbe8 70%, #ffe3ee 100%); border: 2.5px solid #ffdbf1; box-shadow: 0 8px 30px #ffd6e888; border-radius: 32px;}
.album-card.everland .album-date { color: #f599af; font-weight: bold; letter-spacing: 0.1em;}
.album-card.everland .swiper-pagination-bullet { background: #ffcbde;}
.album-card.everland .swiper-pagination-bullet-active { background: #f08db7;}
.album-card.everland .album-caption { color: #d5658d; font-size: 1.18rem; font-family: 'Nanum Pen Script', cursive; letter-spacing: 0.07em; line-height: 1.6; text-shadow: 0 2px 10px #fff7ee99;}
.album-card.everland .cafe-emoji { font-size: 1.28em;}

.album-card.rate { background: linear-gradient(110deg, #eef9ff 80%, #ffe3f8 100%); border: 2.5px solid #f9c7e9; box-shadow: 0 7px 24px #f3cef7aa; border-radius: 20px;}
.album-card.rate .album-date { color: #b35fa7;}
.album-card.rate .swiper-pagination-bullet { background: #e6bee6;}
.album-card.rate .swiper-pagination-bullet-active { background: #b35fa7;}
.album-card.rate .album-caption { color: #ae45a7;}

/* 이모지 포인트 */
.heart-emoji { font-size: 1.2em; }
.wave-emoji { font-size: 1.15em; }
.cafe-emoji { font-size: 1.18em; }

/* ==== Letter ==== */
#letter {
  background: #fdfaf4;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem 1rem;
}
.letter-box {
  background: repeating-linear-gradient(
    to bottom,
    #fffdf9,
    #fffdf9 32px,
    #f9f6f2 32px,
    #f9f6f2 34px
  );
  border: 2px solid #f3e7d9;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  padding: 2.5rem;
  border-radius: 16px;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.letter-box::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url('https://www.transparenttextures.com/patterns/paper-fibers.png');
  opacity: 0.08;
  pointer-events: none;
  z-index: 1;
}
.letter-content { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 1.5rem; }
.letter-content p {
  font-size: 1.7rem; color: #333; line-height: 2.6rem; padding-left: 0.5rem;
  border-left: 3px solid #ffd5d5; background: rgba(255, 255, 255, 0.6);
  padding: 0.8rem 1rem; border-radius: 10px;
}
.section button, .next-btn {
  font-size: 1.2rem; margin-top: 2rem; padding: 12px 28px; background: #ff8fa3;
  border: none; border-radius: 30px; color: white; cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1); transition: background 0.3s ease;
}
.section button:hover, .next-btn:hover { background: #e7728d; }

/* ==== Hearts (배경 하트) ==== */
.hearts {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 9999; overflow: hidden;
}
.heart {
  position: absolute; background: rgba(255, 105, 135, 0.8);
  width: 20px; height: 20px; transform: rotate(45deg);
  animation: floatUp linear infinite; opacity: 0.7;
}
.heart::before, .heart::after {
  content: ""; position: absolute; width: 20px; height: 20px;
  background: rgba(255, 105, 135, 0.8); border-radius: 50%;
}
.heart::before { top: -10px; left: 0; }
.heart::after { left: -10px; top: 0; }
@keyframes floatUp {
  0% { transform: translateY(100vh) rotate(45deg) scale(0.8); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-10vh) rotate(45deg) scale(1.2); opacity: 0; }
}

/* ==== Faces (배경 얼굴) ==== */
.faces {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 9998; overflow: hidden;
}
.face-float {
  position: absolute; background-size: cover; background-position: center; border-radius: 100%;
  opacity: 0.77; animation: faceUp linear infinite;
}
@keyframes faceUp {
  0% { transform: translateY(110vh) scale(0.85); opacity: 0.15; }
  25% { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1.08); opacity: 0; }
}

/* Intro Blur Overlay */
.intro-blur-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.82); backdrop-filter: blur(15px);
  z-index: 1000; display: flex; justify-content: center; align-items: center; transition: opacity 0.6s;
}
.intro-blur-overlay.hide { opacity: 0; pointer-events: none; }
.blur-msg {
  color: #c42c5a; font-size: 1.55rem; font-family: 'Nanum Pen Script', cursive;
  background: rgba(255,255,255,0.8); border-radius: 24px; box-shadow: 0 3px 18px #ed79af22;
  padding: 32px 36px 22px 36px; line-height: 1.8; border: 2px solid #ffd2e4;
}

/* Letter list & modal */
.letter-list { display: flex; flex-direction: column; gap: 12px; }
.open-letter-btn {
  background-color: #f7c1d9; border: none; padding: 12px 20px; font-size: 16px; border-radius: 8px; cursor: pointer;
  color: #fff; font-family: 'Nanum Pen Script', cursive; font-weight: bold; transition: 0.3s;
}
.open-letter-btn:hover { background-color: #e26a8d; }

.modal {
  display: none; position: fixed; z-index: 9999; padding-top: 80px; left: 0; top: 0; width: 100%; height: 100%;
  overflow: auto; background-color: rgba(0,0,0,0.6);
}
.modal-content {
  background-color: #fff6f9; margin: auto; padding: 30px; border: 1px solid #888;
  width: 80%; max-width: 600px; border-radius: 12px; font-family: 'Nanum Pen Script', cursive;
  font-size: 20px; line-height: 1.8; color: #333; position: relative;
}
.modal-content h3 {
  margin-top: 0; font-size: 26px; color: #e26a8d; text-align: center;
}
.close {
  color: #aaa; position: absolute; right: 20px; top: 15px; font-size: 28px; font-weight: bold; cursor: pointer;
}
.close:hover, .close:focus { color: #000; }

/* ===== PC→모바일 전환 ===== */
@media (max-width: 896px) {
  #container {
    flex-direction: column !important; width: 100% !important; height: auto !important;
    min-height: unset !important; transform: none !important; transition: none !important;
  }
  .section { width: 100vw !important; min-height: 100vh !important; margin: 0 !important; padding: 0 !important; }
}

/* Scroll lock 유틸 */
body.block-scroll, html.block-scroll {
  overflow: hidden !important; height: 100vh !important; position: fixed !important; width: 100vw !important;
}
body.lock-scroll { overflow: hidden !important; height: 100vh !important; position: fixed !important; width: 100vw !important; }

/* Letter 스크롤 보장 */
.letter-box { overflow-y: auto; max-height: 85vh; }

/* 모바일 최적화 */
@media (max-width:600px) {
  .memory-album { gap: 12px; }
  .album-card { width: 98vw; min-width: unset; padding: 13px 4px 10px 4px; }
  .memory-swiper { height: 48vw; min-height: 120px; }
  .album-card .album-caption { font-size: 1.07rem; }
}

/* === Mobile menu clipping fix === */
@media (max-width: 896px) {
  /* #menu 는 공용 .section 의 padding:0 !important 를 무시하고 자체 여백 사용 */
  #menu {
    padding-top: calc(48px + env(safe-area-inset-top));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  /* 메뉴 카드가 화면 폭에 딱 맞게 보이도록 1열 + 최대폭 제한 */
  #menu .menu-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 0;  /* 혹시 있을 내부 패딩 제거 */
  }

  .menu-link {
    width: min(480px, 92vw);
    margin: 0 auto;          /* 가운데 정렬 */
    border-radius: 18px;
  }

  /* 제목/힌트도 안전 여백 안쪽에 오도록 */
  #menu .menu-title,
  #menu .menu-hint {
    padding: 0 4px;
  }
}

/* iOS Safari 추가 안전망: 전체 바디에 세이프에어리어 반영 */
@supports (padding:max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* ▶ 기존 고정 높이 제거 */
.memory-swiper {
  height: auto;           /* ← 고정 260px/48vw 대신 자동 높이 */
  max-height: 70vh;       /* 너무 길어지지 않게 안전장치 (원하면 값 조절) */
  border-radius: 16px;
  overflow: hidden;
}

/* Swiper 내부도 자동 높이에 맞춰줌 */
.memory-swiper .swiper-wrapper,
.memory-swiper .swiper-slide {
  height: auto;
}

/* ▶ 이미지 비율 유지 + 가로 100% */
.memory-swiper img {
  width: 100%;
  height: auto;           /* ← 핵심! 세로 자동 */
  display: block;
  object-fit: contain;    /* 잘림 없이 전부 보이게 */
  background: transparent;/* 여백색 필요하면 #fff/#000로 */
}

/* (모바일에서 이전에 height:48vw 같은 규칙이 있었다면 아래로 덮어쓰기) */
@media (max-width: 896px){
  .memory-swiper { height: auto; max-height: 70vh; }
}

/* ▶ Swiper 고정 높이 제거하고, 슬라이드/이미지 모두 세로 자동 */
.memory-swiper { 
  height: auto !important;          /* 기존 240px / 48vw 같은 고정값 무시 */
  max-height: none !important;
  border-radius: 16px;
  overflow: hidden;
}
.memory-swiper .swiper-wrapper,
.memory-swiper .swiper-slide {
  height: auto !important;
}

/* 이미지가 카드 너비에 맞고, 세로는 비율대로 늘어나게 */
.memory-swiper img {
  width: 100%;
  height: auto;                      /* 핵심! */
  display: block;
  object-fit: contain;               /* 잘림 없이 전부 보이기 */
  background: transparent;           /* 여백 배경 필요하면 #fff / #000 로 변경 */
}

/* 혹시 모바일에 height:48vw 같은 규칙이 있으면 강제로 무력화 */
@media (max-width: 896px){
  .memory-swiper { height: auto !important; max-height: none !important; }
}
