/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Tokens ─────────────────────────────────────────────────────────────────── */
:root {
  --bg:        #f7f4ef;       /* warm off-white page */
  --card-back: #ffffff;
  --ink:       #1a1816;
  --ink-mid:   #8a8078;
  --rule:      #e0d8ce;
  --gold:      #a07840;
  --shadow:    0 2px 8px rgba(0,0,0,0.06), 0 16px 48px rgba(0,0,0,0.1);
}

/* ─── Page ───────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

/* ─── Scroll container — no native scroll, transform-driven ─────────────────── */
.scroll-container {
  height: 100vh;
  overflow: hidden;
}

.slides-wrapper {
  width: 100%;
  will-change: transform;
  transition: transform 0.65s cubic-bezier(0.77, 0, 0.175, 1);
}

/* ─── Each slide ─────────────────────────────────────────────────────────────── */
.slide {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 48px 32px 32px;
  perspective: 2400px;
}

/* ─── Postcard — ~80% of screen ─────────────────────────────────────────────── */
/* width is the smaller of 87vw or the width that keeps height ≤ 82vh at 3:2 */
.postcard {
  position: relative;
  width: min(87vw, calc(82vh * 1.5));
  aspect-ratio: 3 / 2;
  border-radius: 2px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.45, 0, 0.15, 1);
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid rgba(0,0,0,0.06);
}
.postcard.flipped { transform: rotateY(180deg); }

/* ─── Front & back shared ────────────────────────────────────────────────────── */
.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.card-back { transform: rotateY(180deg); }

/* ─── Front: photo + label ───────────────────────────────────────────────────── */
.card-front {
  display: flex;
  flex-direction: column;
}

.card-front-photo {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: #111; /* fallback before image loads */
}

.card-front-photo.no-image { background: #2a2a2a; }

/* Blurred ambient background — same image, fills the space with its own colors */
.photo-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(24px) brightness(0.55) saturate(1.3);
  transform: scale(1.12); /* avoid blur edge halos */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.photo-bg.loaded { opacity: 1; }

/* Main photo — full, uncropped */
.photo-main {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.photo-main.loaded { opacity: 1; }

.card-front-label {
  flex-shrink: 0;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-back);
  border-top: 1px solid var(--rule);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mid);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, background 0.2s;
}
.postcard:hover .card-front-label {
  color: var(--ink);
  background: #f0ece4;
}

/* ─── Back: sleek postcard ───────────────────────────────────────────────────── */
.card-back {
  background: var(--card-back);
  display: flex;
}

/* Caption column — left 60% */
.back-message {
  flex: 0 0 60%;
  display: flex;
  align-items: center;
  padding: 28px 32px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.back-message::-webkit-scrollbar { display: none; }

.caption-text {
  font-family: 'Cormorant Garamond', serif;
  font-style: normal;
  font-weight: 400;
  font-size: clamp(1rem, 1.9vw, 1.3rem);
  line-height: 1.75;
  color: var(--ink);
  letter-spacing: 0.01em;
}

/* Thin vertical divider */
.back-divider {
  width: 1px;
  background: var(--rule);
  align-self: stretch;
  margin: 20px 0;
  flex-shrink: 0;
}

/* Right column — stamp + location */
.back-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 20px 24px 16px;
}

.location-text {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(0.9rem, 1.7vw, 1.15rem);
  color: var(--ink-mid);
  letter-spacing: 0.06em;
  text-align: right;
  line-height: 1.5;
}

.stamp {
  width: 52px;
  height: 62px;
  border: 1.5px solid var(--gold);
  border-radius: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 3px var(--card-back), inset 0 0 0 5px var(--gold);
}

.stamp-initial {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: 1.5rem;
  color: var(--gold);
  line-height: 1;
}

/* ─── Title card ─────────────────────────────────────────────────────────────── */
.title-card {
  position: relative;
  width: min(87vw, calc(82vh * 1.5));
  aspect-ratio: 3 / 2;
  border-radius: 2px;
  background: var(--card-back);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.06);
  display: flex;
  flex-direction: row;
  overflow: hidden;
  cursor: default;
}

/* Left column: text */
.title-left {
  flex: 0 0 50%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 40px 32px 48px;
}

.title-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.title-eyebrow {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: clamp(0.65rem, 1.2vw, 0.82rem);
  color: var(--ink-mid);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.title-name {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(1.8rem, 5vw, 3.6rem);
  color: var(--ink);
  line-height: 0.95;
  letter-spacing: -0.01em;
}

.title-divider {
  width: 32px;
  height: 1px;
  background: var(--rule);
  margin: 20px 0 0;
}

/* Stamp — top-right of the left column */
.title-stamp {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 58px;
  border: 1.5px solid var(--gold);
  border-radius: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 3px var(--card-back), inset 0 0 0 5px var(--gold);
}

.scroll-hint {
  position: absolute;
  bottom: 18px;
  left: 48px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mid);
  animation: drift 3.5s ease-in-out infinite;
}

/* Right column: portrait photo */
.title-photo-wrap {
  flex: 1;
  overflow: hidden;
  border-left: 1px solid var(--rule);
}

.title-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

@keyframes drift {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.8; }
}

/* ─── Progress indicators ────────────────────────────────────────────────────── */
.progress-dots {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.dot {
  width: 1.5px;
  height: 14px;
  border-radius: 1px;
  background: rgba(0,0,0,0.15);
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
  transition: background 0.3s, height 0.3s;
}
.dot.active {
  background: rgba(0,0,0,0.55);
  height: 26px;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .slide { padding: 4vh 14px 4vh 14px; }

  /* Full-height card on mobile — portrait photos fill the screen */
  .postcard {
    width: 96vw;
    aspect-ratio: unset;
    height: 88vh;
    border-radius: 2px;
  }

  .title-card {
    width: 92vw;
    aspect-ratio: 4 / 3;
  }

  .back-message { padding: 24px 20px; }
  .caption-text { font-size: 0.95rem; }

  .stamp,
  .title-stamp { width: 42px; height: 50px; }
  .stamp-initial { font-size: 1.2rem; }

  .title-left { padding: 24px 28px 24px 24px; flex: 0 0 55%; }
  .title-name { font-size: clamp(1.4rem, 7vw, 2.2rem); }
  .title-stamp { top: 14px; right: 14px; width: 40px; height: 48px; }
  .scroll-hint { left: 24px; }

  .progress-dots { right: 10px; }
}

@media (max-height: 500px) {
  .progress-dots { display: none; }
}

/* ─── View toggle ────────────────────────────────────────────────────────────── */
.view-toggle {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 300;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--ink);
  opacity: 0.38;
  transition: opacity 0.2s;
  line-height: 0;
}
.view-toggle:hover { opacity: 0.75; }
.view-toggle svg { width: 18px; height: 18px; display: block; }
.view-toggle .icon-card { display: none; }
.view-toggle.in-gallery .icon-grid { display: none; }
.view-toggle.in-gallery .icon-card { display: block; }

/* ─── Gallery overlay ────────────────────────────────────────────────────────── */
.gallery-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 250;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.gallery-view.active { opacity: 1; transform: scale(1); }

/* ─── Filter bar ─────────────────────────────────────────────────────────────── */
.gallery-filters {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}
.gallery-filters::-webkit-scrollbar { display: none; }

.filter-btn {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mid);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 5px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.filter-btn:hover { color: var(--ink); border-color: var(--ink-mid); }
.filter-btn.active {
  color: var(--ink);
  border-color: var(--ink);
  background: rgba(0,0,0,0.05);
}

/* ─── Gallery grid ───────────────────────────────────────────────────────────── */
.gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  align-content: start;
}

/* ─── Thumbnail ──────────────────────────────────────────────────────────────── */
.gallery-thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 2px;
  cursor: pointer;
  background: #111;
  border: 1px solid rgba(0,0,0,0.06);
  animation: thumbIn 0.4s ease both;
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes thumbIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.gallery-thumb .photo-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(16px) brightness(0.55) saturate(1.3);
  transform: scale(1.12);
  pointer-events: none;
  transition: transform 0.4s ease;
}
.gallery-thumb .photo-main {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.4s ease;
}
.gallery-thumb:hover .photo-bg  { transform: scale(1.18); }
.gallery-thumb:hover .photo-main { transform: scale(1.04); }

.thumb-location {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 24px 8px 7px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.85);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.gallery-thumb:hover .thumb-location { opacity: 1; }

.gallery-thumb.filtered-out {
  opacity: 0;
  transform: scale(0.93);
  pointer-events: none;
}

/* Gallery zoom-out transition */
.scroll-container {
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.scroll-container.hidden {
  opacity: 0;
  transform: scale(0.94);
  pointer-events: none;
}
