/* =========================================================================
   Wedding photo app — elegant, Apple-inspired, mobile-first
   Palette: white / cream / soft gold
   ========================================================================= */

:root {
  --cream: #fbf7f0;
  --cream-deep: #f3ece0;
  --white: #ffffff;
  --ink: #2c2620;
  --ink-soft: #6b6157;
  --gold: #c9a24b;
  --gold-soft: #e3cf9c;
  --gold-deep: #b08a35;
  --line: rgba(176, 138, 53, 0.18);
  --shadow-sm: 0 2px 10px rgba(80, 60, 20, 0.06);
  --shadow-md: 0 10px 30px rgba(80, 60, 20, 0.10);
  --shadow-lg: 0 20px 50px rgba(80, 60, 20, 0.16);
  --radius: 22px;
  --radius-lg: 32px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-serif: "Cormorant Garamond", "Georgia", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: linear-gradient(160deg, var(--cream) 0%, var(--cream-deep) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

h1,
h2 {
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

.muted {
  color: var(--ink-soft);
}
.center {
  text-align: center;
}

/* ---------------------------- Splash / loader --------------------------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(160deg, var(--cream), var(--cream-deep));
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
.splash.hide {
  opacity: 0;
  visibility: hidden;
}
.splash-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--gold-soft);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
.splash-text {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--gold-deep);
  letter-spacing: 0.06em;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------- Topbar -------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 44px 1fr 56px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(251, 247, 240, 0.82);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-title {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--ink);
}
.topbar-back {
  font-size: 1.8rem;
  line-height: 1;
  text-decoration: none;
  color: var(--gold-deep);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-link {
  text-decoration: none;
  color: var(--gold-deep);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: right;
}

/* ------------------------------ Containers ------------------------------ */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}
.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 12px 80px;
}

/* -------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-pill);
  padding: 14px 26px;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background 0.2s var(--ease), opacity 0.2s;
  user-select: none;
}
.btn:active {
  transform: scale(0.97);
}
.btn-lg {
  padding: 17px 30px;
  font-size: 1.08rem;
}
.btn-block {
  width: 100%;
}
.btn-primary {
  color: #4a3a12;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  box-shadow: var(--shadow-md);
}
.btn-primary:hover {
  box-shadow: var(--shadow-lg);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-secondary {
  color: var(--gold-deep);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: #fffdf8;
}
.btn-icon {
  font-size: 1.15em;
  line-height: 1;
}
.link-center {
  display: block;
  text-align: center;
  margin-top: 22px;
  color: var(--gold-deep);
  font-weight: 600;
  text-decoration: none;
}

/* --------------------------------- Home --------------------------------- */
.home {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px calc(40px + env(safe-area-inset-bottom));
}
.home-card {
  width: 100%;
  max-width: 480px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 34px 26px 30px;
  text-align: center;
}
.couple-photo {
  width: 190px;
  height: 190px;
  margin: 0 auto 22px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--white);
  box-shadow: 0 0 0 2px var(--gold-soft), var(--shadow-md);
}
.couple-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 0.7rem;
  color: var(--gold-deep);
  margin: 0 0 8px;
}
.names {
  font-family: var(--font-serif);
  font-size: 2.9rem;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 8px;
}
.wedding-date {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--gold-deep);
  position: relative;
  display: inline-block;
  padding: 0 18px;
  margin-bottom: 18px;
}
.wedding-date::before,
.wedding-date::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 24px;
  height: 1px;
  background: var(--gold-soft);
}
.wedding-date::before {
  right: 100%;
}
.wedding-date::after {
  left: 100%;
}
.welcome {
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 1.02rem;
  margin: 0 auto 26px;
  max-width: 380px;
}
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.home-hint {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ------------------------------- Upload --------------------------------- */
.upload-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 26px 22px;
}
.upload-hero {
  text-align: center;
  margin-bottom: 22px;
}
.upload-emoji {
  font-size: 2.6rem;
}
.upload-hero h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin: 6px 0 8px;
}
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 38px 20px;
  border: 2px dashed var(--gold-soft);
  border-radius: var(--radius);
  background: linear-gradient(160deg, #fffdf8, var(--cream));
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease),
    transform 0.15s var(--ease);
}
.dropzone:active {
  transform: scale(0.99);
}
.dropzone.dragover {
  border-color: var(--gold);
  background: #fff8e9;
}
.dropzone-icon {
  font-size: 2.4rem;
  color: var(--gold);
  line-height: 1;
}
.dropzone-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-top: 6px;
}
.dropzone-sub {
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.limits {
  text-align: center;
  margin: 14px 0 6px;
  font-size: 0.9rem;
}
.selected-info {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.selected-info strong {
  color: var(--gold-deep);
}

/* Progress */
.progress-wrap {
  margin: 18px 0 8px;
}
.progress-track {
  height: 12px;
  background: var(--cream-deep);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  border-radius: var(--radius-pill);
  transition: width 0.25s var(--ease);
}
.progress-text {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

/* Result box */
.result-box {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius);
  font-size: 0.97rem;
  line-height: 1.5;
  text-align: center;
}
.result-box.success {
  background: #f1f8ee;
  border: 1px solid #cfe6c4;
  color: #3c6b2c;
}
.result-box.error {
  background: #fcefee;
  border: 1px solid #f0cfcc;
  color: #a4402f;
}
.result-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 6px;
}

#uploadBtn {
  margin-top: 18px;
}

/* ------------------------------- Gallery -------------------------------- */
.gallery-head {
  text-align: center;
  padding: 12px 8px 18px;
}
.gallery-head h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
}
.count {
  margin-top: 4px;
  font-size: 0.95rem;
}

/* Masonry via CSS columns — light & fast on mobile */
.masonry {
  column-count: 2;
  column-gap: 10px;
}
@media (min-width: 640px) {
  .masonry {
    column-count: 3;
  }
}
@media (min-width: 980px) {
  .masonry {
    column-count: 4;
  }
}
.tile {
  break-inside: avoid;
  margin: 0 0 10px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--cream-deep);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  position: relative;
  display: block;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.tile:active {
  transform: scale(0.98);
}
.tile img {
  width: 100%;
  display: block;
  height: auto;
  background: var(--cream-deep);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.tile img.loaded {
  opacity: 1;
}

.sentinel {
  height: 1px;
}
.grid-loader {
  display: flex;
  justify-content: center;
  padding: 26px 0;
}
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--gold-soft);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-emoji {
  font-size: 3rem;
  margin-bottom: 10px;
}

/* ------------------------------ Lightbox -------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(28, 24, 18, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lbfade 0.25s var(--ease);
}
@keyframes lbfade {
  from {
    opacity: 0;
  }
}
.lb-stage {
  max-width: 96vw;
  max-height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
}
.lb-stage img {
  max-width: 96vw;
  max-height: 86vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
}
.lb-close {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-prev {
  left: 12px;
}
.lb-next {
  right: 12px;
}
.lb-counter {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}
@media (max-width: 640px) {
  .lb-nav {
    display: none; /* use swipe on mobile */
  }
}

/* -------------------------------- Admin --------------------------------- */
.admin-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px 22px;
  margin-bottom: 20px;
}
.admin-card h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.qr-box {
  display: flex;
  justify-content: center;
  margin: 18px 0 10px;
}
.qr-box canvas {
  background: #fff;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  width: 220px;
  height: 220px;
}
.qr-url {
  text-align: center;
  word-break: break-all;
  margin: 8px 0 16px;
}
.field {
  margin: 14px 0;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 1rem;
  background: var(--cream);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--gold);
  background: #fffdf8;
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.admin-thumb {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--cream-deep);
}
.admin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.admin-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(164, 64, 47, 0.92);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------- 404 ------------------------------------ */
.error-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}

/* ----------------------------- Animations ------------------------------- */
.fade-in {
  animation: fadeUp 0.6s var(--ease) both;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Load elegant serif if available (optional, graceful fallback) */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: local("Cormorant Garamond");
}
