:root {
  --sky: #F3F6FB;
  --mist: #E2EAF9;
  --ink: #1D2A4D;
  --night: #141D3A;
  --nemo: #6C8FE0;
  --nemo-deep: #3F5FB8;
  --nemo-pale: #A9C2F5;
  --leaf: #3E6B4A;
  --ruby: #C8324B;
  --sun: #FFD44D;
  --blush: #FF9FB2;
  --title: "Huninn", "Chiron GoRound TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --text: "Chiron GoRound TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --print-shadow: 0 1px 2px rgba(29, 42, 77, .16), 0 10px 20px -12px rgba(29, 42, 77, .5);
}

* { box-sizing: border-box; margin: 0; }

body {
  /* 淡淡的點點底，像筆記本 */
  background: var(--sky) radial-gradient(#CBD9F3 1.1px, transparent 1.6px) 0 0 / 22px 22px;
  color: var(--ink);
  font-family: var(--text);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-x: clip;
}

/* 花還沒開之前，下面的內容先不存在（不鎖捲動，避免卡住） */
.gate main, .gate .end { display: none; }

/* Huninn 只有一種粗細，標題一律不加粗 */
h1, h2, h3, .headline {
  font-family: var(--title);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: .02em;
}

h2 { font-size: clamp(1.6rem, 6.4vw, 2.25rem); }

:focus-visible { outline: 3px solid var(--nemo); outline-offset: 3px; }

.btn {
  font: 700 1.125rem/1 var(--text);
  padding: .95em 2.2em;
  border-radius: 999px;
  border: 0;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform .15s ease;
}
.btn:active { transform: scale(.96); }

/* ---------- 開場：花田 ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
}

.sky { position: absolute; inset: 0; z-index: -1; }
.sky-dusk { background: linear-gradient(var(--night) 0%, #2B3A6B 48%, #7C8BBB 100%); }
.sky-day {
  background: linear-gradient(#9DBDF0 0%, #D3E2F9 50%, #EEF3FC 100%);
  transition: opacity 2.4s ease;
}
.gate .sky-day { opacity: 0; }

.bunting {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 84px;
  transition: transform 1s cubic-bezier(.3, 1.4, .5, 1) 1.2s;
}
.bunting svg { display: block; }
.gate .bunting { transform: translateY(-110%); transition: none; }

.hero-text {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 11svh 24px 3svh;
}
.hero-text > div {
  grid-area: 1 / 1;
  transition: opacity .9s ease, visibility .9s;
}
.before { color: #fff; opacity: 0; visibility: hidden; }
.gate .before { opacity: 1; visibility: visible; }
.gate .after { opacity: 0; visibility: hidden; }
.bloomed .after { transition-delay: 1.5s; }

.to { font-size: 1.05rem; letter-spacing: .12em; }
.hero .headline { font-size: clamp(3rem, 14vw, 6.5rem); margin: .2em 0 .35em; }
.before .headline { font-size: clamp(2.1rem, 9.5vw, 4.25rem); }
.after .headline { outline: 0; }
.lede { font-size: 1.0625rem; line-height: 2; }
.lede b { font-family: var(--title); font-weight: 400; font-size: 1.6em; color: var(--nemo-deep); padding: 0 .1em; }
#bloom { margin-top: .5rem; }

.field {
  position: relative;
  height: 44svh;
  transition: filter 2.4s ease;
}
.gate .field { filter: brightness(.36) saturate(.55); }

.hill {
  position: absolute;
  bottom: 0;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.hill-far { left: -45%; right: 12%; height: 80%; background: #6A9A6E; }
.hill-near {
  left: -10%; right: -10%;
  height: 60%;
  background: linear-gradient(#4F8257, var(--leaf));
  z-index: 1;
}

.flower {
  position: absolute;
  aspect-ratio: 1;
  translate: -50% 0;
  transform-origin: 50% 100%;
  transition: transform 1s cubic-bezier(.3, 1.5, .5, 1) var(--d, 0s);
}
.gate .hero .flower { transform: scale(0); transition: none; }

/* ---------- 蛋糕 + 票 ---------- */

.wish-line {
  min-height: 1.8em;
  margin-top: 12px;
  font-family: var(--title);
  font-size: 1.2rem;
  color: var(--nemo-deep);
}

.cake { width: 240px; margin: 12px auto 0; position: relative; }
.candles { display: flex; justify-content: center; gap: 22px; }
.candle {
  position: relative;
  width: 44px; height: 92px;
  padding: 0; border: 0; background: none;
  cursor: pointer;
  color: var(--nemo);
}
.candle:nth-child(2) { color: var(--ruby); }
.candle:nth-child(3) { color: #E0A800; }
.candle::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 0;
  width: 12px; height: 58px;
  translate: -50% 0;
  border-radius: 4px 4px 0 0;
  background: repeating-linear-gradient(-35deg, #fff 0 6px, currentColor 6px 12px);
}
.flame {
  position: absolute;
  left: 50%; bottom: 60px;
  width: 18px; height: 28px;
  margin-left: -9px;
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  background: radial-gradient(circle at 50% 72%, #fff 0 16%, var(--sun) 42%, #FF9A3C 78%);
  box-shadow: 0 0 18px 5px rgba(255, 212, 77, .55);
  transform-origin: 50% 100%;
  animation: flicker 1.1s ease-in-out infinite alternate;
  transition: opacity .25s, scale .25s;
}
.candle.out { cursor: default; }
.candle.out .flame { animation: none; opacity: 0; scale: .2; }
@keyframes flicker {
  from { transform: rotate(-4deg) scaleY(1); }
  to { transform: rotate(4deg) scaleY(1.12); }
}
.cake-body {
  position: relative;
  height: 118px;
  border-radius: 20px 20px 10px 10px;
  display: flex; align-items: flex-end; justify-content: space-evenly;
  padding-bottom: 16px;
  background:
    radial-gradient(circle at 15px 0, var(--blush) 15px, transparent 16px) 0 32px / 30px 20px repeat-x,
    linear-gradient(var(--blush) 32px, transparent 32px),
    #FFF4DC;
  box-shadow: inset 0 -10px 0 #F6E3BC;
}
.cake-body svg { width: 34px; height: 34px; color: var(--nemo); }
.plate {
  height: 16px;
  margin: -6px -26px 0;
  border-radius: 50%;
  background: var(--mist);
}

.ticket {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  rotate: -2deg;
  box-shadow: 0 12px 20px -14px rgba(29, 42, 77, .6);
}
.ticket-main {
  flex: 1;
  min-width: 0;
  background: #fff;
  border-left: 10px solid var(--nemo);
  border-radius: 10px 0 0 10px;
  padding: 14px 12px 12px 16px;
}
.ticket-names { font-family: var(--title); font-size: 1.3rem; line-height: 1.3; }
.ticket-time { margin: 6px 0 4px; line-height: 1.5; }
.ticket-time b {
  font-family: var(--title);
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--nemo-deep);
  font-variant-numeric: tabular-nums;
}
.ticket-small { font-size: .8rem; opacity: .75; }
.ticket-stub {
  position: relative;
  flex: none;
  width: 78px;
  background: var(--sun);
  border-left: 2px dashed rgba(29, 42, 77, .35);
  border-radius: 0 10px 10px 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.15;
  font-size: .85rem;
}
.ticket-stub b { display: block; font-family: var(--title); font-weight: 400; font-size: 2rem; }
/* 撕線上下的小缺口 */
.ticket-stub::before, .ticket-stub::after {
  content: "";
  position: absolute;
  left: -9px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sky);
}
.ticket-stub::before { top: -8px; }
.ticket-stub::after { bottom: -8px; }

/* ---------- 跑馬燈照片牆 ---------- */

.marquee {
  display: grid;
  gap: 10px;
  padding: 12px 0 20px;
  overflow: hidden;
}
.track {
  display: flex;
  gap: 10px;
  width: max-content;
  animation: slide 80s linear infinite;
}
.track.rev { animation-direction: reverse; }
.marquee:hover .track { animation-play-state: paused; }
@keyframes slide {
  to { transform: translateX(calc(-50% - 5px)); }
}

/* ---------- 照片 ---------- */

.print {
  position: relative;
  display: block;
  padding: 5px;
  border: 0;
  background: #fff;
  box-shadow: var(--print-shadow);
  cursor: zoom-in;
  min-width: 0;
}
.print img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--mist);
}
.thumb { flex: none; width: 96px; padding: 4px; }
@media (min-width: 900px) { .thumb { width: 132px; } }

/* ---------- 回憶 ---------- */

.journey { max-width: 1040px; margin: 0 auto; padding: 20px 16px 44px; }
.journey > h2 { margin-bottom: 20px; }

#chapters {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px 14px;
}
.chapter { grid-column: span 2; min-width: 0; }
/* 只有一張照片的回憶：照片在左、標題在右 */
.chapter.n1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: center;
}
.chapter.n1 .prints { order: -1; margin-top: 0; }
.chapter.n1 h3 { font-size: 1.6rem; }
.chapter.n1 .pin { width: 30px; height: 30px; }
.chapter.n1 header { flex-wrap: wrap; }

.chapter header { display: flex; align-items: center; gap: 6px; }
.pin { flex: none; width: 22px; height: 22px; color: var(--nemo); }
.chapter:nth-child(3n+2) .pin { color: var(--blush); }
.chapter:nth-child(3n) .pin { color: #F2B90F; }
.chapter h3 { font-size: 1.3rem; }
.when { font-size: .85rem; color: var(--nemo-deep); line-height: 1.5; }
.when span + span { margin-left: .8em; }
.note { font-size: .95rem; }

.prints { display: grid; gap: 10px; margin-top: 10px; }
.n2 .prints { grid-template-columns: 1fr 1fr; }
.n3 .prints { grid-template-columns: 2fr 1fr; }
.n3 .print:first-child { grid-row: span 2; }
.n4 .prints { grid-template-columns: 3fr 1fr; }
.n4 .print:first-child { grid-row: span 3; }
.n3 .print:first-child img, .n4 .print:first-child img { aspect-ratio: auto; }
.nmany .prints { grid-template-columns: repeat(3, 1fr); }

/* 每段第一張貼一條紙膠帶 */
.prints .print:first-child { rotate: -.8deg; }
.prints .print:first-child::before {
  content: "";
  position: absolute;
  top: -9px; left: 50%;
  width: 64px; height: 18px;
  translate: -50% 0;
  rotate: -3deg;
  background: var(--sun);
  opacity: .85;
  z-index: 1;
}
.chapter:nth-child(3n+2) .print:first-child::before { background: var(--blush); rotate: 2deg; }
.chapter:nth-child(3n) .print:first-child::before { background: var(--nemo-pale); }
.prints .print:nth-child(2) { rotate: .7deg; }

@media (min-width: 900px) {
  .journey { padding-top: 36px; }
  #chapters { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 44px 28px; }
  .prints { gap: 14px; }
  .print { padding: 7px; }
}

/* ---------- 坐在我對面的妳 ---------- */

.across { background: var(--mist); padding: 36px 16px 44px; }
.across-in { max-width: 1040px; margin: 0 auto; }
.across p:empty, .across h2:empty { display: none; }
.across h2:empty ~ .grid { margin-top: 0; }
.across .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.across .print:nth-child(odd) { rotate: -1deg; }
.across .print:nth-child(even) { rotate: 1deg; }
@media (min-width: 900px) {
  .across { padding: 56px 16px 64px; }
  .across .grid { grid-template-columns: repeat(4, 1fr); gap: 24px; }
}

/* ---------- 結尾 ---------- */

.end {
  position: relative;
  background: linear-gradient(var(--night) 0%, #2B3A6B 60%, #6474A8 100%);
  color: #fff;
  padding-top: 48px;
  text-align: center;
  overflow: hidden;
  overflow: clip;
}
.end-line { font-family: var(--title); font-size: clamp(1.8rem, 8vw, 3rem); }
.end-sub { color: var(--nemo-pale); margin-top: 4px; }
.field-dusk { height: 190px; margin-top: 28px; filter: brightness(.66) saturate(.85); }
.field-dusk .hill-near { height: 78%; }
.colophon {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  font-size: .85rem;
  letter-spacing: .08em;
  z-index: 200;
}

/* ---------- 放大照片 ---------- */

#lb {
  border: 0;
  padding: 0;
  margin: auto;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  overflow: visible;
}
#lb::backdrop { background: rgba(20, 29, 58, .9); }
#lb img {
  display: block;
  max-width: 92vw;
  max-height: 80svh;
  border: 8px solid #fff;
  cursor: zoom-out;
}
.lb-close {
  display: block;
  margin: 16px auto 0;
  font: 700 1rem var(--text);
  color: #fff;
  background: none;
  border: 1.5px solid #fff;
  border-radius: 999px;
  padding: .4em 1.4em;
  cursor: pointer;
}

/* ---------- 彩紙 ---------- */

.confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -24px; animation: fall linear forwards; }
@keyframes fall {
  to { transform: translate(var(--x), 112vh) rotate(var(--r)); }
}

/* ---------- 第一個畫面：蛋糕和票直接放在花田上 ---------- */

.hero { display: block; }
.hero .field { position: absolute; left: 0; right: 0; bottom: 0; }
.hero-text {
  position: relative;
  z-index: 200;
  min-height: 100svh;
  padding: 11svh 16px 0;
  place-items: start center;
}
.hero-text > .before { margin-top: 7svh; }
.hero-text > .after {
  align-self: stretch;
  justify-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.after .headline { font-size: clamp(2.6rem, 11.5vw, 5.5rem); margin: .12em 0 .2em; }
.wish-line { margin-top: 0; font-size: 1.15rem; }

.stage {
  margin-top: auto;
  width: 100%;
  padding: 16px 0 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.stage .cake { margin: 0; }
.stage .ticket { width: min(100%, 340px); margin: 0; }
.ticket-stub::before, .ticket-stub::after { display: none; }
@media (min-width: 900px) {
  .stage { flex-direction: row; justify-content: center; align-items: flex-end; gap: 72px; padding-bottom: 90px; }
}

.marquee { padding-top: 22px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .marquee { overflow-x: auto; }
}
