/* Feature pages, admin, invite, albums */

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(80, 40, 120, 0.35), transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 80%, rgba(120, 40, 80, 0.18), transparent 70%),
    var(--sky-top, #070414);
}
.page-bg .grain-lite {
  position: absolute; inset: 0; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Login / setup */
.auth-card {
  width: min(460px, 100%);
  margin: 0 auto;
  text-align: left;
}
.auth-card .name-mini {
  font-family: "Allura", cursive;
  font-size: 3.4rem;
  line-height: 1;
  text-align: center;
  background: linear-gradient(105deg, #fffaf0, #e8c56a 55%, #f3b7c6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.role-switch {
  display: flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem;
  margin: 0 0 1.2rem;
}
.role-switch label {
  flex: 1;
  text-align: center;
  padding: 0.45rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--muted);
}
.role-switch input { position: absolute; opacity: 0; pointer-events: none; }
.role-switch input:checked + span,
.role-switch label:has(input:checked) {
  background: linear-gradient(160deg, #fff4c8, #e8c56a);
  color: #2a1840;
  font-weight: 600;
}

/* Storybook */
.book-stage {
  perspective: 2000px;
  width: min(920px, 100%);
  margin: 0 auto;
  min-height: 70vh;
}
.book {
  position: relative;
  width: 100%;
  aspect-ratio: 1.45 / 1;
  min-height: 480px;
  transform-style: preserve-3d;
  border-radius: 6px 18px 18px 6px;
  background:
    linear-gradient(90deg, #3a2610 0 10px, transparent 10px),
    linear-gradient(180deg, #f7ecd0, #efe0b8 55%, #e6d3a0);
  box-shadow:
    0 0 0 3px #c9a24a,
    0 0 0 7px #7a5a18,
    0 0 0 8px #e8c56a,
    0 28px 80px rgba(0,0,0,0.45),
    inset 8px 0 18px rgba(80, 50, 10, 0.18);
  overflow: hidden;
  color: #3a2a18;
}
.book-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 22px;
  background: linear-gradient(90deg, #5a3a12, #c9a24a 40%, #7a5218);
  z-index: 5;
}
.book-page {
  position: absolute;
  inset: 10px 14px 14px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  transform-origin: left center;
}
.book-leaf {
  padding: 1.4rem 1.3rem;
  position: relative;
  overflow: hidden;
}
.book-leaf.left { border-right: 1px solid rgba(80,50,10,0.12); }
.book-photo {
  width: 100%;
  height: 68%;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(60,40,10,0.18);
  background: #d9cba8;
}
.book-caption {
  font-family: "Playfair Display", serif;
  font-style: italic;
  margin-top: 0.8rem;
  font-size: 1.05rem;
  color: #4a3720;
}
.book-date { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: #7a6240; margin-top: 0.3rem; }
.book-empty { display: flex; align-items: center; justify-content: center; color: #7a6240; font-style: italic; }
.book-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(920px, 100%);
  margin: 1.2rem auto 0;
}
.chapter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0 auto 1.4rem;
  width: min(920px, 100%);
}
.chapter-tab {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: var(--gold-soft);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.chapter-tab.is-active {
  background: linear-gradient(160deg, #fff4c8, #e8c56a);
  color: #2a1840;
  border-color: transparent;
}
.book.is-turning .book-page { animation: page-turn 0.7s var(--ease); }
@keyframes page-turn {
  0% { transform: rotateY(0); }
  45% { transform: rotateY(-88deg); }
  100% { transform: rotateY(0); }
}
@media (max-width: 700px) {
  .book { aspect-ratio: 3 / 4; min-height: 520px; }
  .book-page { grid-template-columns: 1fr; }
  .book-leaf.left { border-right: 0; border-bottom: 1px solid rgba(80,50,10,0.12); }
  .book-photo { height: 58%; }
}

/* Growth tower */
.tower-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 2rem;
  align-items: end;
  width: min(900px, 100%);
  margin: 0 auto;
}
.tower {
  position: relative;
  height: 620px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 20%),
    repeating-linear-gradient(180deg, #cbb79a 0 18px, #b79e7e 18px 20px),
    #c4ae90;
  border-radius: 18px 18px 8px 8px;
  border: 3px solid rgba(232,197,106,0.55);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), inset 0 0 40px rgba(80,40,10,0.15);
  overflow: hidden;
}
.tower::before {
  content: "";
  position: absolute; left: 50%; top: -42px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 90px solid transparent;
  border-right: 90px solid transparent;
  border-bottom: 52px solid #3d4a6e;
  filter: drop-shadow(0 -2px 0 #e8c56a);
}
.tower-scale {
  position: absolute; inset: 24px 16px 16px;
}
.tower-mark {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  border-top: 2px solid rgba(232,197,106,0.85);
  transform: translateY(50%);
}
.tower-mark .jewel {
  position: absolute; left: 50%; top: -7px; margin-left: -7px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #e8c56a 55%, #c9a227);
  box-shadow: 0 0 16px rgba(255,230,160,0.9);
  animation: mark-sparkle 2.4s ease-in-out infinite;
}
.tower-mark .lbl {
  position: absolute; left: 24px; top: -1.15rem;
  font-size: 0.78rem;
  color: #2a1840;
  background: rgba(255,244,200,0.85);
  padding: 0.1rem 0.45rem;
  border-radius: 8px;
  white-space: nowrap;
}
@keyframes mark-sparkle {
  0%,100% { box-shadow: 0 0 10px rgba(255,230,160,0.6); transform: scale(1); }
  50% { box-shadow: 0 0 22px rgba(255,230,160,1); transform: scale(1.15); }
}
.growth-list { list-style: none; }
.growth-list li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 700px) {
  .tower-wrap { grid-template-columns: 1fr; }
  .tower { height: 480px; width: min(260px, 100%); margin: 0 auto; }
}

/* Letters */
.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.4rem;
}
.envelope {
  position: relative;
  aspect-ratio: 1.5 / 1;
  background: linear-gradient(180deg, #f4e4c4, #e8d2a4);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
  cursor: pointer;
  color: #3a2a18;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.4s var(--ease);
}
.envelope:hover { transform: translateY(-8px) rotate(-1deg); }
.envelope .flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%;
  background: linear-gradient(180deg, #edd6a8, #dcc08a);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.7s var(--ease);
  z-index: 2;
}
.envelope.is-open .flap { transform: rotateX(180deg); }
.envelope .seal {
  position: absolute; left: 50%; top: 42%;
  width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e07080, #8a2038);
  box-shadow: 0 4px 10px rgba(80,0,20,0.3);
  z-index: 3;
  display: grid; place-items: center;
  color: #fff4c8;
  font-family: "Allura", cursive;
  font-size: 1.3rem;
}
.envelope.is-locked .seal { background: radial-gradient(circle at 30% 30%, #8a8aa0, #3a3a50); }
.envelope .from {
  position: absolute; left: 1rem; right: 1rem; bottom: 0.9rem;
  font-family: "Playfair Display", serif;
  font-style: italic;
  z-index: 1;
}
.letter-modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(6,3,16,0.72);
  display: none;
  place-items: center;
  padding: 1.5rem;
}
.letter-modal.is-open { display: grid; }
.letter-sheet {
  width: min(640px, 100%);
  min-height: 360px;
  background: #fbf4e8;
  color: #3a2a18;
  padding: 2.2rem 2rem;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
  animation: letter-rise 0.6s var(--ease);
  position: relative;
}
@keyframes letter-rise {
  from { transform: translateY(40px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.letter-sheet h2 { font-family: "Playfair Display", serif; margin-bottom: 0.4rem; }
.letter-sheet .from-line { color: #7a6240; margin-bottom: 1.1rem; font-style: italic; }
.letter-sheet .body { white-space: pre-wrap; line-height: 1.7; }
.letter-close {
  position: absolute; top: 0.7rem; right: 0.7rem;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,0.06);
  color: #3a2a18;
}

/* Firsts */
.firsts-path {
  position: relative;
  width: min(760px, 100%);
  margin: 1rem auto 0;
  min-height: 200px;
  padding: 1rem 0 2rem;
}
.firsts-path svg.path-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lantern {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1.6rem;
  padding: 0.4rem;
}
.lantern:nth-child(even) { margin-left: 8%; }
.lantern:nth-child(odd) { margin-right: 8%; }
.lantern-orb {
  width: 64px; height: 80px;
  border-radius: 12px 12px 18px 18px;
  background: radial-gradient(circle at 50% 35%, #fff4c8, #e8c56a 45%, #8a5a18 100%);
  box-shadow: 0 0 24px rgba(232,197,106,0.55), 0 8px 18px rgba(0,0,0,0.25);
  position: relative;
  animation: lantern-glow 3.2s ease-in-out infinite;
}
.lantern-orb::before {
  content: "";
  position: absolute; left: 50%; top: -10px; margin-left: -8px;
  width: 16px; height: 12px;
  background: #c9a227;
  border-radius: 3px 3px 0 0;
}
@keyframes lantern-glow {
  0%,100% { filter: brightness(0.95); }
  50% { filter: brightness(1.15); }
}
.lantern h3 { font-family: "Playfair Display", serif; font-weight: 500; }
.lantern time { color: var(--gold-soft); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.lantern p { color: var(--muted); margin-top: 0.25rem; }
.lantern img {
  width: 100%; max-width: 280px; border-radius: 12px; margin-top: 0.6rem;
  border: 1px solid var(--line);
}

/* Wishes page */
.wish-page-sky {
  position: relative;
  min-height: 70vh;
  border-radius: 28px;
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(90, 36, 88, 0.35), transparent 55%),
    radial-gradient(ellipse at 50% 0%, rgba(40, 30, 90, 0.4), transparent 50%),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.15));
}
.wish-form-card { width: min(520px, 100%); margin: 0 auto 1.6rem; }
.wish-page-sky .sky-wish { position: absolute; background: none; border: 0; color: var(--gold-soft); cursor: pointer; filter: drop-shadow(0 0 6px rgba(255,230,160,0.8)); }
.wish-tooltip {
  position: absolute;
  transform: translate(-50%, -120%);
  background: rgba(18,12,36,0.92);
  border: 1px solid var(--line);
  color: var(--ivory);
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  max-width: 220px;
  pointer-events: none;
  z-index: 3;
}

/* Guest book */
.gb-list { display: grid; gap: 1rem; width: min(720px, 100%); margin: 2rem auto 0; }
.gb-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem 1.3rem;
  animation: gb-in 0.7s var(--ease) both;
}
@keyframes gb-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.gb-card .who { font-family: "Playfair Display", serif; color: var(--gold-soft); }
.gb-card time { display: block; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin: 0.2rem 0 0.6rem; }
.gb-pending { opacity: 0.7; font-style: italic; color: var(--muted); text-align: center; margin-top: 1rem; }

/* Albums */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.4rem;
}
.album-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  box-shadow: 0 12px 36px rgba(0,0,0,0.28);
  transform: translateY(0) rotate(0);
  transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease), border-color 0.3s;
  animation: album-in 0.7s var(--ease) both;
}
.album-card:nth-child(3n) { animation-delay: 0.08s; }
.album-card:nth-child(3n+1) { animation-delay: 0.16s; }
.album-card:hover, .album-card:focus-visible {
  transform: translateY(-10px) rotate(-0.6deg);
  border-color: rgba(232,197,106,0.6);
  box-shadow: 0 22px 50px rgba(0,0,0,0.4), 0 0 30px rgba(232,197,106,0.16);
}
.album-cover {
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(circle at 50% 40%, rgba(232,197,106,0.28), transparent 55%),
    linear-gradient(160deg, #2a1848, #120816);
  position: relative;
  overflow: hidden;
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cover .placeholder-crest {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--gold-soft);
  font-size: 2.4rem;
}
.album-meta { padding: 0.95rem 1rem 1.1rem; }
.album-meta h3 { font-family: "Playfair Display", serif; font-weight: 500; font-size: 1.2rem; }
.album-meta time, .album-meta .open-hint {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.3rem;
}
.album-meta .open-hint { color: var(--gold-soft); margin-top: 0.45rem; }
@keyframes album-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.admin-tile {
  text-decoration: none;
  color: inherit;
  padding: 1.2rem 1.15rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  transition: transform 0.35s var(--ease), border-color 0.3s, box-shadow 0.35s;
}
.admin-tile:hover { transform: translateY(-6px); border-color: rgba(232,197,106,0.55); box-shadow: 0 12px 32px rgba(0,0,0,0.28); }
.admin-tile .num {
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  color: var(--gold-soft);
  display: block;
}
.admin-tile h3 { margin-top: 0.2rem; font-size: 1.05rem; }
.admin-tile p { color: var(--muted); font-size: 0.88rem; margin-top: 0.3rem; }
.admin-subnav {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin: 0 0 1.5rem;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-soft); }
.inline-form { display: inline; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.muted { color: var(--muted); }
.admin-form { width: min(640px, 100%); }

/* Invite */
body.page-invite { background: #070414; }
.invite-stage { min-height: 100svh; position: relative; display: grid; place-items: center; padding: 2rem 1rem 3rem; }
.invite-envelope {
  width: min(420px, 92vw);
  aspect-ratio: 1.45 / 1;
  position: relative;
  cursor: pointer;
  z-index: 3;
}
.invite-envelope .back {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #f0dcb4, #e2c896);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.invite-envelope .flap {
  position: absolute; left: 0; right: 0; top: 0; height: 62%;
  background: linear-gradient(180deg, #f7e6c4, #d9bd8c);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 1s var(--ease);
  z-index: 2;
}
.invite-envelope.is-open .flap { transform: rotateX(180deg); }
.invite-envelope .wax {
  position: absolute; left: 50%; top: 48%; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #e07080, #8a2038);
  z-index: 3;
  display: grid; place-items: center;
  color: #fff4c8;
  font-family: "Allura", cursive; font-size: 1.8rem;
  transition: opacity 0.5s 0.2s;
}
.invite-envelope.is-open .wax { opacity: 0; }
.invite-card {
  display: none;
  width: min(640px, 100%);
  text-align: center;
  z-index: 4;
  animation: letter-rise 0.8s var(--ease);
}
.invite-stage.is-revealed .invite-envelope { display: none; }
.invite-stage.is-revealed .invite-card { display: block; }
.invite-card .name { font-size: clamp(4rem, 16vw, 8rem); }
.invite-card h2 { font-family: "Playfair Display", serif; font-weight: 500; margin: 0.4rem 0 0.6rem; }
.invite-when { color: var(--gold-soft); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.86rem; }
.invite-loc { margin: 0.5rem 0 1rem; font-style: italic; font-family: "Playfair Display", serif; }
.invite-msg { color: var(--muted); max-width: 36em; margin: 0 auto 1.4rem; }
.invite-form { text-align: left; margin: 1.5rem auto 0; width: min(480px, 100%); }
.rsvp-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.rsvp-choices label {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.4rem;
  text-align: center;
  cursor: pointer;
  color: var(--ivory-dim);
}
.rsvp-choices input { position: absolute; opacity: 0; }
.rsvp-choices label:has(input:checked) {
  border-color: var(--gold);
  background: rgba(232,197,106,0.15);
  color: var(--gold-soft);
}
.thanks-card { text-align: center; padding: 2rem 1rem; }

@media (prefers-reduced-motion: reduce) {
  .book.is-turning .book-page,
  .album-card, .gb-card, .lantern-orb, .tower-mark .jewel,
  .invite-card, .letter-sheet, .envelope { animation: none !important; transition: none !important; }
}
