:root {
  --primary-color: #95797f;
  --secondary-color: #c5afb1;
  --bg-color: #f9f7f2;
  --text-color: #2c2c2c;
  --white: #ffffff;
}

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

body {
  font-family: 'Lato', sans-serif;
  font-weight: 300;
  line-height: 1.7;
  background: var(--bg-color);
  color: var(--text-color);
}

h1, h2 { font-family: 'Playfair Display', serif; color: var(--primary-color); font-weight: 400; }
h1 { font-size: clamp(2.6rem, 8vw, 4.5rem); line-height: 1.1; }
/* Couple's names: always on one line. */
.names {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-size: clamp(2.2rem, 10vw, 5rem);
}
.names .heart { width: 0.55em; height: 0.5em; margin: 0 0.12em; vertical-align: 0.05em; }
h2 { font-size: 2.2rem; }
h2::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  margin: 10px auto 0;
  background: var(--secondary-color);
}

a { color: inherit; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 0.8rem;
  color: var(--secondary-color);
  font-weight: 700;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  border: none;
  border-radius: 999px;
  background: var(--primary-color);
  color: var(--white);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.btn:hover { background: #7f646a; }
.btn-light { background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.5); }
.btn-light:hover { background: rgba(255, 255, 255, 0.3); }

/* --- Gallery page --- */
.hero { text-align: center; padding: 4rem 20px 2rem; }
.hero p:last-child { margin-top: 1rem; font-size: 1.1rem; }

.section-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.8rem 20px;
  background: rgba(249, 247, 242, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #ece6e0;
}
.section-nav a {
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--secondary-color);
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.9rem;
}
.section-nav a:hover { background: var(--secondary-color); color: var(--white); }

.container { max-width: 1400px; margin: 0 auto; padding: 1rem 12px 3rem; }
.status { text-align: center; padding: 3rem 0; }

.gallery-section { padding-top: 3rem; scroll-margin-top: 4rem; }
.section-header { text-align: center; margin-bottom: 1.5rem; }
.section-meta { margin: 0.8rem 0 0; color: #777; }

/* Justified rows: each tile grows in proportion to its aspect ratio (--r). */
.grid { display: flex; flex-wrap: wrap; gap: 6px; }
.grid::after { content: ''; flex-grow: 999; }
.tile {
  flex: calc(var(--r) * 100) 1 calc(var(--r) * 220px);
  aspect-ratio: var(--r);
  padding: 0;
  border: none;
  background: #ece6e0;
  cursor: zoom-in;
  overflow: hidden;
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.tile:hover img { transform: scale(1.03); }

@media (max-width: 600px) {
  .tile { flex-basis: calc(var(--r) * 130px); }
  .grid { gap: 3px; }
}

.footer { text-align: center; padding: 2rem; font-size: 0.9rem; color: #888; }

/* --- Photo viewer (PhotoSwipe) --- */
.pswp { --pswp-bg: #120e0c; }
.pswp-save {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.9rem 1.6rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #b8862d, #e8c65a 50%, #b8862d);
  color: #2a1e10;
  font: 700 1rem 'Lato', sans-serif;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  pointer-events: auto;
}
.pswp-save svg { width: 1.25rem; height: 1.25rem; }
.pswp-save:disabled { opacity: 0.75; cursor: progress; }
.pswp-save[data-state="ready"] { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.05); } }
/* Arrows are useless with a touch screen: swiping is the way. */
@media (pointer: coarse) { .pswp__button--arrow { display: none !important; } }

.zip-link { color: var(--primary-color); font-weight: 700; }

/* --- Welcome page (login) --- */
.welcome-page {
  --gold: #e8c65a;
  min-height: 100vh;
  background: #17120f;
  color: #f4ede4;
  overflow-x: hidden;
}
.welcome-backdrop {
  position: fixed;
  inset: -10%;
  background: url('/assets/cover-blur.webp') center / cover;
  filter: blur(40px) brightness(0.4) saturate(1.2);
}
.welcome {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2rem, 6vw, 6rem);
  padding: 4vh 4vw;
}
.card {
  position: relative;
  flex: none;
  height: min(92vh, 138vw);
  aspect-ratio: 2 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: #2a211b;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.card-photo, .gold-rain { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-photo { object-fit: cover; opacity: 0; transform: scale(1.06); }
.merci {
  position: absolute;
  left: 50%;
  bottom: 13%;
  width: 72%;
  transform: translateX(-50%);
  overflow: visible;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}
.merci-text {
  font-family: 'Great Vibes', cursive;
  font-size: 200px;
  fill: url(#gold);
}
.reveal-band { transform: translateX(0); }
.merci-line { stroke: url(#gold); stroke-width: 2.5; stroke-dasharray: 90; stroke-dashoffset: 90; }
.welcome-panel { width: min(380px, 100%); opacity: 0; transform: translateY(20px); }
.welcome-panel h1 { color: var(--gold); margin: 0.6rem 0 1rem; font-size: clamp(2.4rem, 4vw, 3.6rem); }
.welcome-panel .eyebrow { color: #d8c3a5; }
.welcome-panel form { margin-top: 2rem; display: flex; flex-direction: column; gap: 0.7rem; }
.welcome-panel label { font-weight: 700; color: #d8c3a5; }
.welcome-panel input {
  font: inherit;
  color: #fff;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(232, 198, 90, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}
.welcome-panel input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.welcome-panel .btn { margin-top: 0.4rem; background: linear-gradient(135deg, #b8862d, #e8c65a 50%, #b8862d); color: #2a1e10; }
.welcome-panel .btn:hover { filter: brightness(1.08); }
.error { color: #ffb4a8; }

/* Intro sequence: photo, gold rain (canvas, settled by ~3.5s), "Merci" is written, then the form. */
.intro .card-photo { animation: photo-in 1.6s ease-out forwards; }
.intro .reveal-band { animation: write 2.4s cubic-bezier(0.45, 0.05, 0.4, 1) 3.6s forwards; }
.intro .merci-line { animation: draw 0.6s ease-out 5.8s forwards; }
.intro .welcome-panel { animation: panel-in 0.9s ease-out 3.6s forwards; }

@keyframes photo-in { to { opacity: 1; transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes write { to { transform: translateX(720px); } }
@keyframes panel-in { to { opacity: 1; transform: none; } }

.no-intro .card-photo, .no-intro .welcome-panel { animation: none; opacity: 1; transform: none; }
.no-intro .reveal-band { animation: none; transform: translateX(720px); }
.no-intro .merci-line { animation: none; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: reduce) {
  .card-photo, .welcome-panel { animation: none !important; opacity: 1 !important; transform: none !important; }
  .reveal-band { animation: none !important; transform: translateX(720px) !important; }
  .merci-line { animation: none !important; stroke-dashoffset: 0 !important; }
}

/* Phones and portrait screens: full-bleed photo, form over its lower part. */
@media (max-aspect-ratio: 5 / 6) {
  .welcome { display: block; padding: 0; }
  .card { width: 100vw; height: 100svh; border-radius: 0; box-shadow: none; }
  .merci { bottom: 40%; width: 80%; }
  .welcome-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    padding: 5rem 1.5rem 1.8rem;
    text-align: center;
    background: linear-gradient(to bottom, transparent, rgba(15, 11, 8, 0.85) 35%);
  }
  .welcome-panel h1 { font-size: clamp(2rem, 11vw, 3rem); margin: 0.3rem 0 0.4rem; }
  .welcome-panel > p:not(.eyebrow) { display: none; }
  .welcome-panel form { margin-top: 1rem; text-align: left; }
}
