:root {
  --night: #11152a;
  --night-2: #1c2242;
  --paper: #f7f2e8;
  --paper-2: #efe7d6;
  --ink: #1b1f33;
  --ink-soft: #5a5e72;
  --gold: #b08a4e;
  --gold-light: #d4b47a;
  --rule: rgba(27, 31, 51, .14);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --turn: 900ms;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background:
    radial-gradient(120% 80% at 50% 0%, var(--night-2) 0%, var(--night) 60%) fixed,
    var(--night);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}

/* faint city-light sparkle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(212,180,122,.5), transparent),
    radial-gradient(1px 1px at 78% 12%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.5px 1.5px at 88% 64%, rgba(212,180,122,.35), transparent),
    radial-gradient(1px 1px at 22% 82%, rgba(255,255,255,.25), transparent),
    radial-gradient(1px 1px at 52% 6%, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 6% 56%, rgba(212,180,122,.3), transparent);
}

.stage {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

/* ---------- Book ---------- */

.book {
  --h: min(calc(100dvh - 120px), 760px);
  position: relative;
  height: var(--h);
  width: min(calc(100vw - 32px), calc(var(--h) * .68));
  perspective: 2200px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

/* the page stack underneath, so the book has thickness */
.book::before,
.book::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px 14px 14px 4px;
  background: var(--paper-2);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}
.book::before { transform: translate(6px, 6px); opacity: .55; }
.book::after  { transform: translate(3px, 3px); opacity: .85; }

.leaf {
  position: absolute;
  inset: 0;
  z-index: 1;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform var(--turn) cubic-bezier(.645, .045, .355, 1), opacity 250ms ease;
  cursor: pointer;
}

.leaf .face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4px 14px 14px 4px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background:
    linear-gradient(90deg, rgba(0,0,0,.09) 0, rgba(0,0,0,0) 5%),
    radial-gradient(140% 100% at 100% 0%, #fbf8f1 0%, var(--paper) 55%, var(--paper-2) 100%);
  padding: clamp(22px, 4.5vh, 40px) clamp(20px, 7%, 40px) clamp(18px, 3.5vh, 30px);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.leaf .face::-webkit-scrollbar { display: none; }

/* turning shade */
.leaf .face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(17,21,42,0) 30%, rgba(17,21,42,.28) 100%);
  opacity: 0;
  transition: opacity var(--turn) ease;
}

/* back of the leaf, seen while it swings over */
.leaf::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px 4px 4px 14px;
  transform: rotateY(180deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: linear-gradient(270deg, rgba(0,0,0,.12) 0, rgba(0,0,0,0) 8%), var(--paper-2);
}

.leaf.turned { transform: rotateY(-178deg); pointer-events: none; }
.leaf.turned .face::after { opacity: 1; }
.leaf.gone { opacity: 0; transition: opacity 200ms ease; }

@media (prefers-reduced-motion: reduce) {
  .leaf { transition: opacity 300ms ease; }
  .leaf.turned { transform: none; opacity: 0; }
}

/* ---------- Type ---------- */

.kicker {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--gold);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }

/* ---------- Cover ---------- */

.cover .face {
  align-items: center;
  text-align: center;
  justify-content: space-between;
  background:
    linear-gradient(90deg, rgba(0,0,0,.25) 0, rgba(0,0,0,0) 5%),
    radial-gradient(120% 90% at 70% 10%, #262d55 0%, var(--night) 70%);
  color: var(--paper);
  border: 1px solid rgba(212,180,122,.35);
}
.cover .face::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(212,180,122,.4);
  border-radius: 2px 9px 9px 2px;
  pointer-events: none;
}
.cover .kicker { color: var(--gold-light); }

.cover-title { display: flex; flex-direction: column; align-items: center; line-height: .9; }
.cover-title .name {
  font-style: italic;
  font-size: clamp(2.6rem, 9vh, 4.2rem);
  font-variation-settings: "opsz" 144;
}
.cover-title .turns {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin: 10px 0 2px .32em;
}
.cover-title .age {
  font-size: clamp(3.6rem, 13vh, 6.2rem);
  font-weight: 600;
  font-variation-settings: "opsz" 144;
  background: linear-gradient(180deg, #f3dcaa 0%, var(--gold-light) 45%, #9c7638 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.portrait {
  margin: 0;
  width: min(52%, 24vh);
  aspect-ratio: 3 / 4;
  border-radius: 999px 999px 10px 10px;
  overflow: hidden;
  border: 2px solid var(--gold-light);
  box-shadow: 0 0 0 6px rgba(212,180,122,.12);
  flex-shrink: 1;
  min-height: 0;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

.dates { margin: 0; font-family: var(--serif); font-style: italic; font-size: 1.02rem; color: #e9dfc8; }

.turn-hint {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(247,242,232,.55);
  animation: nudge 2.4s ease-in-out infinite;
}
.hint-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .hint-mouse { display: inline; }
  .hint-touch { display: none; }
}
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

/* ---------- Day pages ---------- */

.day-head { text-align: center; padding-bottom: clamp(10px, 2vh, 18px); border-bottom: 1px solid var(--rule); }
.day-head h2 { font-size: clamp(1.6rem, 4.6vh, 2.1rem); margin-top: 6px; }
.day-head h2 em { color: var(--gold); }
.day-sub { margin: 4px 0 0; font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: .95rem; }

.menu {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  min-height: 0;
}

.menu li {
  display: grid;
  grid-template-columns: 4.6em 1fr;
  gap: 12px;
  align-items: baseline;
  position: relative;
  padding: 4px 0;
}

.menu time {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: lining-nums;
  color: var(--ink);
}
.menu time small { font-size: .62em; margin-left: 2px; font-weight: 400; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }

.item { border-left: 1px solid var(--rule); padding-left: 14px; position: relative; }
.item::before {
  content: "";
  position: absolute;
  left: -4px;
  top: .55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--gold);
}
.item h3 { font-size: clamp(1.12rem, 3vh, 1.32rem); line-height: 1.15; }
.item p { margin: 3px 0 0; font-size: .9rem; color: var(--ink-soft); line-height: 1.35; }

.feature .item h3 { font-style: italic; }
.feature .item::before { background: var(--gold); }
.gold { color: var(--gold); font-weight: 700; }

.map {
  display: inline-block;
  margin-top: 5px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(176,138,78,.4);
  padding: 2px 0;
}
.map:hover, .map:focus-visible { color: var(--ink); border-color: var(--ink); }

.menu li.now .item::before { background: var(--gold); box-shadow: 0 0 0 4px rgba(176,138,78,.22); animation: pulse 2s ease-in-out infinite; }
.menu li.now time::after {
  content: "Now";
  display: block;
  font-family: var(--sans);
  font-size: .58rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}
.menu li.past { opacity: .5; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(176,138,78,.08); } }

.night {
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: balance;
  gap: 10px;
  margin-top: 8px;
  padding-top: clamp(10px, 2vh, 16px);
  border-top: 1px solid var(--rule);
  font-size: .86rem;
  color: var(--ink-soft);
  text-align: center;
}
.night strong { color: var(--ink); font-weight: 500; }
.moon { color: var(--gold); font-size: 1.1rem; }

.folio {
  margin: 8px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: .8rem;
  color: var(--ink-soft);
}

/* short screens (iPhone Safari with toolbars): keep a day on one page */
@media (max-height: 760px) {
  .folio { display: none; }
  .day-sub { display: none; }
  .day-head h2 { margin-top: 2px; }
  .menu li { gap: 10px; grid-template-columns: 4.2em 1fr; }
  .menu time { font-size: 1rem; }
  .item p { display: inline; font-size: .84rem; }
  .item .map { margin: 0 0 0 8px; padding: 0; }
  .item h3 { margin-bottom: 1px; }
  .night { font-size: .8rem; }
}
@media (max-height: 620px) {
  .leaf .face { padding: 18px 16px 14px; }
  .kicker { font-size: .64rem; }
  .day-head { padding-bottom: 8px; }
  .day-head h2 { font-size: 1.4rem; }
  .item h3 { font-size: 1.05rem; }
  .menu.compact li { padding: 0; }
  .night { padding-top: 8px; margin-top: 4px; }
}

/* ---------- Back cover ---------- */

.back-cover .face { align-items: center; justify-content: center; text-align: center; gap: clamp(14px, 3vh, 26px); }
.seal {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.3rem;
  color: var(--paper);
  background: radial-gradient(circle at 35% 30%, #d6b479, #9c7638 70%);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.18), 0 6px 18px -6px rgba(120,86,30,.6);
}
.wish { font-size: clamp(2rem, 6vh, 2.7rem); line-height: 1.1; }
.wish em { color: var(--gold); }
.wish-sub { margin: 0; font-family: var(--serif); font-style: italic; color: var(--ink-soft); }
.hotel { margin-top: 0; }
.restart {
  margin-top: 6px;
  font: inherit;
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--ink);
  cursor: pointer;
}
.restart:hover { border-color: var(--gold); }

/* ---------- Controls ---------- */

.controls { display: flex; align-items: center; gap: 18px; }
.arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(212,180,122,.45);
  background: rgba(255,255,255,.03);
  color: var(--gold-light);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.arrow:hover { background: rgba(212,180,122,.12); }
.arrow:disabled { opacity: .25; cursor: default; }
.dots { display: flex; gap: 10px; }
.dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: rgba(247,242,232,.25);
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.dots button[aria-current="true"] { background: var(--gold-light); transform: scale(1.3); }

:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
