/* ============================================================
   For Claire / 写给秋然 — romantic keepsake album
   ============================================================ */

:root {
  --blush: #f4d6d0;
  --blush-deep: #e8b4b0;
  --rose: #c97b7b;
  --rose-soft: #d4a5a5;
  --cream: #faf6f1;
  --cream-deep: #f0e8df;
  --paper: #fffdf9;
  --ink: #4a3f3a;
  --ink-soft: #6b5c55;
  --ink-muted: #9a8a82;
  --gold: #c4a574;
  --gold-soft: #e0c9a0;
  --shadow: rgba(74, 63, 58, 0.12);
  --shadow-deep: rgba(74, 63, 58, 0.22);
  --radius: 12px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --font-en: "Cormorant Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  --font-zh: "Ma Shan Zheng", "KaiTi", "STKaiti", "楷体", cursive, serif;
  --font-ui: "Cormorant Garamond", "Noto Serif SC", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(244, 214, 208, 0.55) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(224, 201, 160, 0.25) 0%, transparent 45%),
    linear-gradient(165deg, var(--cream) 0%, var(--blush) 45%, var(--cream-deep) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
}

.en {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
}

.zh {
  font-family: var(--font-zh);
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.04em;
}

/* Hide inactive language */
[data-lang="en"] .zh-only,
[data-lang="zh"] .en-only {
  display: none !important;
}

[data-lang="en"] .lang-pair .zh,
[data-lang="zh"] .lang-pair .en {
  display: none;
}

/* ---------- App shell ---------- */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.25rem;
  background: linear-gradient(180deg, rgba(250, 246, 241, 0.95) 60%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.brand-title {
  font-size: 1.15rem;
  color: var(--rose);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--ink-muted);
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--blush-deep);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 1px 4px var(--shadow);
}

.lang-toggle button {
  border: none;
  background: transparent;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: var(--font-en);
}

.lang-toggle button.active {
  background: var(--rose);
  color: var(--paper);
}

.nav-pills {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-pills button,
.nav-pills a {
  border: 1px solid transparent;
  background: rgba(255, 253, 249, 0.7);
  color: var(--ink-soft);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.nav-pills a {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.nav-pills a.active,
.nav-pills button.active {
  border-color: var(--blush-deep);
  background: var(--paper);
  color: var(--rose);
  box-shadow: 0 1px 4px var(--shadow);
}

@media (max-width: 559px) {
  .nav-pills button,
  .nav-pills a {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }
  .brand-sub {
    display: none;
  }
}

/* ---------- Views ---------- */
.view {
  display: none;
  flex: 1;
  animation: fadeIn 0.45s ease;
}

.view.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cover ---------- */
.cover {
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem 3rem;
  min-height: calc(100dvh - 5rem);
}

.cover-ornament {
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 1rem auto;
}

.cover-frame {
  width: min(100%, 380px);
  padding: 2.5rem 2rem 2rem;
  background:
    linear-gradient(145deg, var(--paper) 0%, var(--cream) 100%);
  border: 1px solid var(--blush-deep);
  border-radius: 4px;
  box-shadow:
    0 1px 0 var(--gold-soft),
    0 12px 40px var(--shadow),
    inset 0 0 0 8px rgba(244, 214, 208, 0.35);
  position: relative;
}

.cover-frame::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(196, 165, 116, 0.35);
  border-radius: 2px;
  pointer-events: none;
}

.cover-dedication {
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.cover-dedication .zh {
  text-transform: none;
  letter-spacing: 0.2em;
  font-size: 1rem;
}

.cover-title {
  font-size: clamp(2rem, 8vw, 2.75rem);
  color: var(--rose);
  line-height: 1.25;
  margin-bottom: 0.35rem;
}

.cover-subtitle {
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
}

.cover-names {
  font-size: 1rem;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}

.cover-date {
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-bottom: 1.75rem;
}

.cover-open {
  appearance: none;
  border: 1px solid var(--rose-soft);
  background: linear-gradient(180deg, var(--paper), var(--blush));
  color: var(--rose);
  padding: 0.7rem 1.75rem;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 16px var(--shadow);
  font-family: inherit;
}

.cover-open:hover,
.cover-open:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow-deep);
  outline: none;
}

.cover-hint {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  opacity: 0.8;
}

/* ---------- Story ---------- */
.story {
  padding: 0.6rem 0 0.8rem;
  min-height: 0;
  flex: 1 1 auto;
  overflow: visible;
}

html[data-screen="story"] body {
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
}

html[data-screen="story"] #app,
html[data-screen="story"] #view-story {
  height: auto;
  max-height: none;
  overflow: visible;
}

html[data-screen="story"] #app {
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
}

html[data-screen="story"] #site-footer {
  display: none;
}

.story-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 1 auto;
  max-height: none;
  overflow: visible;
}

.story-card {
  background: var(--paper);
  border: 1px solid var(--blush-deep);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: 0 8px 32px var(--shadow);
  position: relative;
  overflow: visible;
  flex: 0 1 auto;
  min-height: auto;
}

.story-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1.5rem;
  right: 1.5rem;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  border-radius: 2px;
}

.story-title {
  text-align: center;
  font-size: 1.75rem;
  color: var(--rose);
  margin-bottom: 0.5rem;
}

.story-ornament {
  width: 40px;
  height: 1px;
  background: var(--gold);
  margin: 0 auto 1.75rem;
}

.story-para {
  margin-bottom: 1.35rem;
  font-size: 1.05rem;
  color: var(--ink-soft);
  line-height: 1.85;
}

.story-para:last-of-type {
  margin-bottom: 0;
}

.story-dedication {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--blush-deep);
  text-align: center;
  font-size: 1.05rem;
  color: var(--rose);
  line-height: 1.8;
}

.story-para,
.story-title,
.story-dedication {
  opacity: 1 !important;
}

#btn-see-us {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2147483000;
  pointer-events: auto !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 12rem;
  min-height: 48px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  align-items: center;
  justify-content: center;
}

html[data-screen="story"] #btn-see-us {
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

html[data-screen="story"] #btn-see-us:hover,
html[data-screen="story"] #btn-see-us:focus-visible {
  transform: translateX(-50%) translateY(-2px);
}

html[data-screen="story"] #view-cover,
html[data-screen="story"] #view-album,
html[data-screen="story"] #view-album * {
  pointer-events: none !important;
}

html[data-screen="story"] #view-cover,
html[data-screen="story"] #view-album {
  display: none !important;
  visibility: hidden !important;
}

html[data-screen="story"] #album-controls,
html[data-screen="story"] #album-controls *,
html[data-screen="story"] #book-stage,
html[data-screen="story"] #book-stage *,
html[data-screen="story"] #ambient-petals,
html[data-screen="story"] #ambient-petals *,
html[data-screen="story"] #claire-burst,
html[data-screen="story"] #claire-burst *,
html[data-screen="story"] #xuan-paper,
html[data-screen="story"] #xuan-paper *,
#view-story.active ~ #view-album #album-controls,
#view-story.active ~ #view-album #album-controls *,
#view-story.active ~ #view-album #book-stage,
#view-story.active ~ #view-album #book-stage * {
  pointer-events: none !important;
}

html[data-screen="story"] #album-controls,
#view-story.active ~ #view-album #album-controls {
  display: none !important;
  visibility: hidden !important;
}

#btn-see-us.is-opening {
  opacity: 0.72;
}

#btn-see-us.is-error {
  outline: 2px solid var(--rose);
}

html[data-screen="story"] .story-shell {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

.view.story,
.view.story.active {
  animation: storyIn 0.35s ease;
}

@keyframes storyIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.view.album,
.view.album.active {
  animation: none;
}

@media (max-width: 640px) {
  .story {
    padding: 0.3rem 0 0.2rem;
  }
  .story-card {
    padding: 1.1rem 1rem 1.15rem;
  }
  .story-para {
    margin-bottom: 0.8rem;
    font-size: 0.98rem;
    line-height: 1.7;
  }
  #btn-see-us {
    min-width: min(100%, 16rem);
    padding: 0.85rem 1.6rem;
    font-size: 1.05rem;
  }
}

/* ---------- Album book ---------- */
.album {
  padding: 0.5rem 0 5rem;
  flex: 1;
  flex-direction: column;
}

.chapter-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.chapter-title {
  font-size: 1.5rem;
  color: var(--rose);
  margin-bottom: 0.35rem;
}

.chapter-intro {
  font-size: 0.95rem;
  color: var(--ink-muted);
  max-width: 28em;
  margin: 0 auto;
  line-height: 1.7;
}

.book-stage {
  flex: 1;
  perspective: 1400px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  touch-action: pan-y;
  user-select: none;
}

.book-page {
  width: 100%;
  max-width: 440px;
  background: var(--paper);
  border: 1px solid var(--blush-deep);
  border-radius: 4px 12px 12px 4px;
  box-shadow:
    4px 0 0 rgba(244, 214, 208, 0.5),
    8px 12px 36px var(--shadow);
  padding: 1.5rem 1.25rem 1.75rem;
  position: relative;
  transform-origin: left center;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  cursor: pointer;
}

.book-page.flip-next {
  animation: flipNext 0.55s ease;
}

.book-page.flip-prev {
  animation: flipPrev 0.55s ease;
}

@keyframes flipNext {
  0% { transform: rotateY(0); opacity: 1; }
  45% { transform: rotateY(-88deg); opacity: 0.4; }
  46% { transform: rotateY(88deg); opacity: 0.4; }
  100% { transform: rotateY(0); opacity: 1; }
}

@keyframes flipPrev {
  0% { transform: rotateY(0); opacity: 1; }
  45% { transform: rotateY(88deg); opacity: 0.4; }
  46% { transform: rotateY(-88deg); opacity: 0.4; }
  100% { transform: rotateY(0); opacity: 1; }
}

.book-page::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 100%;
  background: linear-gradient(90deg, rgba(74, 63, 58, 0.06), transparent);
  border-radius: 4px 0 0 4px;
  pointer-events: none;
}

.photo-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.photo-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.photo-frame {
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--blush-deep);
  background:
    linear-gradient(145deg, var(--cream) 0%, var(--blush) 50%, var(--cream-deep) 100%);
  box-shadow: inset 0 0 0 6px rgba(255, 253, 249, 0.55);
  position: relative;
  cursor: zoom-in;
  transition: transform var(--transition), box-shadow var(--transition);
}

.photo-frame:hover,
.photo-frame:focus-visible {
  transform: scale(1.015);
  box-shadow:
    inset 0 0 0 6px rgba(255, 253, 249, 0.55),
    0 8px 24px var(--shadow);
  outline: none;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 253, 249, 0.7) 0%, transparent 65%),
    linear-gradient(160deg, #f7ebe6 0%, #f0d5d0 40%, #e8cfc4 100%);
}

.photo-placeholder-icon {
  width: 42px;
  height: 42px;
  border: 1.5px solid var(--gold-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 1.25rem;
  opacity: 0.85;
}

.photo-placeholder-text {
  font-size: 0.9rem;
  color: var(--ink-muted);
  max-width: 12em;
  line-height: 1.5;
}

.photo-caption {
  text-align: center;
  font-size: 1.1rem;
  color: var(--ink);
  line-height: 1.4;
}

.photo-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-muted);
  line-height: 1.7;
  padding: 0 0.5rem;
}

/* ---------- Album controls ---------- */
.album-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 280;
  display: flex;
  justify-content: center;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(250, 246, 241, 0.96) 70%, transparent);
  pointer-events: none;
}

.album-controls-inner {
  pointer-events: auto;
  position: relative;
  z-index: 281;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--paper);
  border: 1px solid var(--blush-deep);
  border-radius: 999px;
  padding: 0.4rem 0.5rem;
  box-shadow: 0 6px 24px var(--shadow);
  max-width: 100%;
}

.ctrl-btn {
  appearance: none;
  border: none;
  background: var(--blush);
  color: var(--rose);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
  pointer-events: auto;
  position: relative;
  z-index: 282;
}

.ctrl-btn:hover:not(:disabled),
.ctrl-btn:focus-visible:not(:disabled) {
  background: var(--blush-deep);
  transform: scale(1.05);
  outline: none;
}

.ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-indicator {
  font-size: 0.8rem;
  color: var(--ink-muted);
  text-align: center;
  min-width: 7rem;
  line-height: 1.3;
  padding: 0 0.25rem;
}

.swipe-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 0.75rem;
  opacity: 0.7;
}

/* Chapter dots */
.chapter-dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.chapter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--blush-deep);
  cursor: pointer;
  padding: 0;
  transition: transform var(--transition), background var(--transition);
}

.chapter-dot.active {
  background: var(--rose);
  transform: scale(1.25);
}

.chapter-dot:hover {
  background: var(--rose-soft);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(42, 32, 28, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(6px);
  pointer-events: none;
  visibility: hidden;
}

.lightbox:not(.open) {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden;
}

.lightbox.open {
  display: flex;
  pointer-events: auto;
  visibility: visible;
  animation: fadeIn 0.25s ease;
}

.lightbox-inner {
  max-width: min(920px, 100%);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.lightbox-frame {
  max-width: 100%;
  max-height: calc(90dvh - 5rem);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(244, 214, 208, 0.4);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  background: var(--cream);
}

.lightbox-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(90dvh - 5rem);
  object-fit: contain;
}

.lightbox-placeholder {
  width: min(80vw, 480px);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #f7ebe6, #e8cfc4);
  color: var(--ink-muted);
  font-size: 1rem;
  padding: 2rem;
  text-align: center;
}

.lightbox-caption {
  color: var(--cream);
  text-align: center;
  font-size: 1.1rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  appearance: none;
  border: 1px solid rgba(244, 214, 208, 0.4);
  background: rgba(255, 253, 249, 0.12);
  color: var(--cream);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  transition: background var(--transition);
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(255, 253, 249, 0.25);
  outline: none;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.site-footer .heart {
  color: var(--rose);
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* Cover WeChat avatars */
.cover-avatars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.25rem 0 1rem;
}
.cover-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--blush-deep);
  box-shadow: 0 4px 14px var(--shadow);
  background: var(--cream);
}
.cover-avatar-heart {
  color: var(--rose);
  font-size: 0.95rem;
  opacity: 0.85;
}

#btn-see-us {
  position: fixed !important;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 2147483647 !important;
  pointer-events: auto !important;
  display: none;
}
html[data-screen="story"] #btn-see-us {
  display: flex !important;
}

#btn-see-us {
  position: fixed !important;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 2147483647 !important;
  pointer-events: auto !important;
}
html:not([data-screen="story"]) #btn-see-us {
  display: none !important;
}
html[data-screen="story"] #btn-see-us {
  display: flex !important;
}
