/* ==========================================================================
   Maylea & Richard — wedding photo sharing
   Palette: cream page, slate-blue ink, dusty blue accents. Marcellus display,
   Mulish body. An elegant printed invitation that happens to be a website.
   ========================================================================== */

:root {
  --cream: #FAF8F4;
  --cream-deep: #F2EEE7;
  --ink: #3E4C59;
  --ink-soft: #5C6A78;
  --ink-faint: #8A95A0;
  --blue: #8CA6BE;
  --blue-deep: #6E8AA6;
  --blue-wash: #C3D2DF;
  --blue-mist: #E5ECF2;
  --hairline: rgba(62, 76, 89, 0.16);
  --hairline-soft: rgba(62, 76, 89, 0.10);
  --shadow: rgba(62, 76, 89, 0.12);
  --serif: 'Marcellus', 'Times New Roman', serif;
  --sans: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* clip (not hidden) — `hidden` turns <body> into a scroll container, which
     silently breaks the view()/scroll() timelines below. clip still clips the
     horizontal overflow but establishes no scroll container. */
  overflow-x: clip;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

.label {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--blue-deep);
  font-weight: 600;
  margin-bottom: 0.6rem;
}

/* ---------------------------------------------------------------- Splash -- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashOut 1.8s ease forwards;
}
.splash.hidden { display: none; }
.splash-inner {
  text-align: center;
  opacity: 0;
  animation: splashIn 1.8s ease forwards;
}
.monogram {
  font-family: var(--serif);
  font-size: clamp(3rem, 16vw, 5rem);
  letter-spacing: 0.05em;
  color: var(--ink);
}
.monogram .amp { color: var(--blue-deep); font-size: 0.7em; }
.splash-rule {
  display: block;
  width: 64px;
  height: 1px;
  background: var(--hairline);
  margin: 1.1rem auto;
}
.splash-date {
  font-family: var(--sans);
  font-weight: 300;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--ink-soft);
}
@keyframes splashIn {
  0% { opacity: 0; transform: translateY(6px); }
  30% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes splashOut {
  0%, 78% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* ------------------------------------------------------------------ Hero -- */
.hero {
  display: grid;
  grid-template-columns: 1fr;
}
.hero-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 54vh;
  overflow: hidden;
}
.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
}
.hero-media::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42%;
  background: linear-gradient(to bottom, rgba(250,248,244,0) 0%, var(--cream) 96%);
}
.hero-text {
  text-align: center;
  padding: 1.4rem 1.5rem 2.6rem;
  margin-top: -1.5rem;
  position: relative;
  z-index: 1;
}
.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 400;
  margin: 0 0 0.7rem;
}
.names {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 12vw, 4.4rem);
  line-height: 1.02;
  margin: 0 0 0.5rem;
  color: var(--ink);
  letter-spacing: 0.01em;
}
.names .amp { color: var(--blue-deep); }
.amp { font-family: var(--serif); }
.date {
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 0.3rem;
  color: var(--ink);
}
.venue {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1.3rem;
  font-weight: 600;
}
.lede {
  /* Hidden on mobile — it restates the eyebrow and pushed the CTAs below the
     fold on tall-hero phones. Desktop's split layout restores it. */
  display: none;
  max-width: 30ch;
  margin: 0 auto 1.6rem;
  color: var(--ink-soft);
  font-weight: 300;
  font-size: 1.02rem;
}
.hero-cta {
  display: inline-block;
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 600;
  color: #fff;
  background: var(--blue-deep);
  padding: 0.85rem 1.9rem;
  border: 1px solid var(--blue-deep);
  border-radius: 999px;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.hero-cta:hover { background: #5d7994; border-color: #5d7994; }
.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}
.hero-cta-ghost {
  background: transparent;
  border-color: var(--hairline);
  color: var(--ink-soft);
}
.hero-cta-ghost:hover {
  background: var(--cream-deep);
  border-color: var(--blue);
  color: var(--ink);
}

/* --------------------------------------------------------------- Sections -- */
.section {
  max-width: 1040px;
  margin: 0 auto;
  padding: 3rem 1.4rem;
}
.section-head { margin-bottom: 1.8rem; }
.section-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  margin: 0 0 0.4rem;
  color: var(--ink);
}
.section-sub {
  color: var(--ink-soft);
  font-weight: 300;
  margin: 0;
  max-width: 44ch;
}

/* ---------------------------------------------------------------- Upload -- */
.upload-section { padding-top: 1rem; }
.panel {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1.6rem 1.4rem;
  box-shadow: 0 1px 0 var(--hairline-soft);
}
.field { display: block; margin-bottom: 1.2rem; }
.field-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.field-label .optional { color: var(--ink-faint); font-weight: 400; text-transform: none; letter-spacing: 0; }
.field-row { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.field-row .field { flex: 1 1 220px; margin-bottom: 1.2rem; }
.field-note {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.74rem;
  color: var(--ink-faint);
  font-weight: 300;
}
input[type="text"],
input[type="email"] {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  padding: 0.75rem 0.9rem;
  background: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  outline: none;
  transition: border-color 0.2s ease;
}
input[type="text"]:focus,
input[type="email"]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-mist); }
input[type="text"]::placeholder,
input[type="email"]::placeholder { color: var(--ink-faint); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.35rem;
  padding: 2.2rem 1rem;
  border: 1px dashed var(--blue);
  border-radius: 4px;
  background: var(--blue-mist);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  outline: none;
}
.dropzone:hover, .dropzone:focus-visible { background: #dce6ee; }
.dropzone.dragover { background: #d3e0ea; border-color: var(--blue-deep); }
.dz-mark {
  width: 34px; height: 34px;
  position: relative;
  margin-bottom: 0.35rem;
}
.dz-mark::before, .dz-mark::after {
  content: '';
  position: absolute;
  background: var(--blue-deep);
  border-radius: 2px;
}
.dz-mark::before { left: 50%; top: 3px; width: 2px; height: 28px; transform: translateX(-50%); }
.dz-mark::after { top: 50%; left: 3px; height: 2px; width: 28px; transform: translateY(-50%); }
.dz-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
}
.dz-hint { font-size: 0.82rem; color: var(--ink-soft); font-weight: 300; }

.previews {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.previews:empty { margin-top: 0; }
.preview {
  position: relative;
  width: 66px; height: 66px;
  border-radius: 3px;
  border: 1px solid var(--hairline);
  background: var(--cream-deep);
}
.preview img { border-radius: 2px; }
.preview-x {
  position: absolute;
  top: -8px; right: -8px;
  width: 22px; height: 22px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px var(--shadow);
}
.preview-x:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview.is-video {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-mist);
}
.preview-play {
  width: 0; height: 0;
  border-style: solid;
  border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent var(--blue-deep);
  margin-left: 3px;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.3rem;
}
.btn {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.8rem 2rem;
  border: 1px solid transparent;
  transition: background 0.2s ease, opacity 0.2s ease;
}
.btn-primary { background: var(--blue-deep); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #5d7994; }
.btn-primary:disabled {
  background: var(--cream-deep);
  color: var(--ink-soft);
  border-color: var(--hairline);
  cursor: default;
}
.selected-count { font-size: 0.85rem; color: var(--ink-soft); font-weight: 300; }
.clear-all {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.clear-all:hover { color: var(--ink); }

.progress-wrap { margin-top: 1.2rem; }
.progress-track {
  height: 3px;
  background: var(--cream-deep);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--blue-deep);
  transition: width 0.2s ease;
}
.progress-label {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.upload-status {
  margin: 1rem 0 0;
  font-size: 0.95rem;
  min-height: 1.2em;
}
.upload-status.success { color: var(--blue-deep); }
.upload-status.error { color: #a8524b; }

/* ------------------------------------------------------- Editorial break -- */
.break {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.6rem 1.4rem 1rem;
}
/* clip, not hidden: a `hidden` frame would become the inner img's scroll
   container and its view() timeline would track the frame instead of the page.
   clip still crops the zoom-settle inside the frame. */
.break-figure { margin: 0; overflow: clip; border-radius: 4px; }
.break-figure img { width: 100%; height: 100%; object-fit: cover; }
.break-lift { aspect-ratio: 3 / 4; }
.break-kiss { aspect-ratio: 3 / 4; }

/* --------------------------------------------------------------- Gallery -- */
.gallery-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}
.download-all {
  flex-shrink: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--blue-deep);
  text-decoration: none;
  border-bottom: 1px solid var(--blue-wash);
  padding-bottom: 2px;
  transition: border-color 0.2s ease;
}
.download-all:hover { border-color: var(--blue-deep); }

.gallery {
  column-count: 2;
  column-gap: 0.6rem;
}
.gallery-item {
  break-inside: avoid;
  margin-bottom: 0.6rem;
  cursor: pointer;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  transition: box-shadow 0.2s ease;
}
.gallery-item:hover { box-shadow: 0 3px 14px var(--shadow); }
.gallery-item img {
  width: 100%;
  display: block;
  background: var(--cream-deep);
}
.gallery-item .caption {
  font-size: 0.78rem;
  color: var(--ink-soft);
  padding: 0.45rem 0.6rem;
  font-weight: 300;
}
/* Placeholder card for photos with no generated thumbnail. */
.gallery-item.no-thumb .ph {
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--blue-mist);
  color: var(--blue-deep);
}
.ph-mark {
  width: 30px; height: 24px;
  border: 1.5px solid var(--blue-deep);
  border-radius: 3px;
  position: relative;
}
.ph-mark::after {
  content: '';
  position: absolute;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--blue-deep);
  top: 4px; left: 4px;
}
.ph-label {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
}
/* Play-triangle badge over video items — dusty blue on a soft cream disc. */
.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(250, 248, 244, 0.9);
  border: 1px solid var(--blue);
  pointer-events: none;
}
.play-badge::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 52%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent var(--blue-deep);
}
/* A video item's placeholder card reads slightly warmer than a photo's. */
.gallery-item.is-video.no-thumb .ph { background: #dbe6ee; }

.gallery-empty {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 300;
  font-style: italic;
  padding: 2.5rem 1rem;
  font-family: var(--serif);
  font-size: 1.15rem;
}

/* ---------------------------------------------------------------- Footer -- */
.footer {
  text-align: center;
  padding: 3rem 1.4rem 3.4rem;
  border-top: 1px solid var(--hairline-soft);
  margin-top: 2rem;
}
.footer-flourish {
  display: block;
  width: 8px; height: 8px;
  margin: 0 auto 1.1rem;
  border: 1px solid var(--blue);
  transform: rotate(45deg);
}
.footer p {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 400;
}

/* ------------------------------------------------------------- Lightbox -- */
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(30, 38, 46, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.lb-figure {
  margin: 0;
  max-width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lb-figure img,
.lb-figure video {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 3px;
}
.lb-figure video { width: auto; background: #000; }
.lb-figure video[hidden], .lb-figure img[hidden] { display: none; }
.lb-caption {
  color: #e9edf1;
  font-weight: 300;
  font-size: 0.9rem;
  margin-top: 0.9rem;
  text-align: center;
  min-height: 1em;
}
.lb-close, .lb-nav {
  position: absolute;
  background: rgba(250, 248, 244, 0.14);
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.lb-close:hover, .lb-nav:hover { background: rgba(250, 248, 244, 0.28); }
.lb-close {
  top: 1rem; right: 1rem;
  width: 42px; height: 42px;
  font-size: 1.6rem;
  line-height: 1;
}
.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px;
  font-size: 1.8rem;
  line-height: 1;
}
.lb-prev { left: 0.8rem; }
.lb-next { right: 0.8rem; }
.lb-download {
  margin-top: 1.2rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 999px;
  padding: 0.65rem 1.6rem;
  transition: background 0.2s ease;
}
.lb-download:hover { background: rgba(255,255,255,0.16); }

/* ---------------------------------------------------------------- Desktop -- */
@media (min-width: 720px) {
  .hero {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    min-height: 88vh;
    max-height: 900px;
  }
  .hero-media {
    aspect-ratio: auto;
    max-height: none;
    height: auto;
    min-height: 0;
  }
  /* Absolutely position the photo so its intrinsic height can never inflate
     the grid row — some Chrome builds let it, overflowing the hero over the
     upload form below (photo covered the fields and hero-text ate clicks). */
  .hero-media img {
    position: absolute;
    inset: 0;
  }
  .hero-media::after { display: none; }
  .hero-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    margin-top: 0;
    padding: 3rem;
  }
  .lede { display: block; margin-left: 0; }
  .hero-actions { flex-direction: row; justify-content: flex-start; }
  .gallery { column-count: 3; }
  .break { grid-template-columns: 1fr 1fr; gap: 1rem; padding: 2rem 1.4rem; }
}

@media (min-width: 1040px) {
  .gallery { column-count: 4; }
}

/* ------------------------------------------------ Scroll-driven motion -- */
/* Subtle, compositor-only (transform/opacity) movement tied to scroll. The
   native path uses CSS scroll-driven animations, double-gated so it runs only
   where the API exists AND the guest hasn't asked for reduced motion. Older
   iPhones (pre-iOS 26) get the IntersectionObserver reveal in app.js instead. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {

    /* Hero photo — a slow drift + faint settle as the hero scrolls out of
       frame (the "Apple" feel). Overscale stays high enough at every position
       that object-fit: cover never uncovers a cream edge behind the image. */
    .hero-media img {
      animation: heroDrift linear both;
      animation-timeline: scroll(root block);
      animation-range: 0 120vh;
      will-change: transform;
    }
    /* Slow Ken Burns zoom-in as the hero scrolls away. Starts barely above 1
       so the resting frame is natural; ends clearly zoomed. translateY stays
       well under the overscale margin so cover never shows a cream edge. */
    @keyframes heroDrift {
      from { transform: scale(1.03); }
      to   { transform: scale(1.18) translateY(3%); }
    }

    /* Break photos — a zoom-settle reveal that completes as each enters. */
    .break-figure img {
      animation: breakReveal linear both;
      animation-timeline: view();
      animation-range: entry 5% entry 90%;
      will-change: transform, opacity;
    }
    @keyframes breakReveal {
      from { opacity: 0; transform: scale(1.12) translateY(48px); }
      to   { opacity: 1; transform: scale(1)    translateY(0); }
    }

    /* Gallery tiles — a gentle fade-up on entry. Tiles rebuilt by the 60s poll
       or a post-upload re-render while already on screen are past the entry
       range, so fill: both paints them at their final state with no replay. */
    .gallery-item {
      animation: tileRise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
    @keyframes tileRise {
      from { opacity: 0; transform: translateY(30px) scale(0.97); }
      to   { opacity: 1; transform: none; }
    }
  }
}

/* Fallback reveal — app.js adds .js-reveal ONLY when scroll-driven animations
   are unsupported AND motion is allowed, so with JS off or on a supporting
   browser the content is never hidden by these rules. */
@media (prefers-reduced-motion: no-preference) {
  .break-figure img.js-reveal {
    opacity: 0;
    transform: scale(1.12) translateY(48px);
    transition: opacity 0.9s ease, transform 0.9s ease;
  }
  .break-figure img.js-reveal.in-view { opacity: 1; transform: none; }
  .gallery-item.js-reveal {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
    transition: opacity 0.7s ease, transform 0.7s ease;
  }
  .gallery-item.js-reveal.in-view { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .splash, .splash-inner { animation-duration: 0.01ms; }
  * { transition-duration: 0.01ms !important; }
}
