/* =====================================================================
   Lily & Nima — Wedding Memory Upload
   Editorial, romantic, mobile-first. Vanilla CSS, no framework.
   ===================================================================== */

/* ---- One web font: Cormorant Garamond (display serif) ---------------
   Self-hosted (public/fonts/) so the page makes NO third-party request
   and works even if Google's font CDN is blocked. font-display: swap so
   text shows immediately in an elegant serif fallback while it loads. -- */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/cormorant-garamond.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Design tokens -------------------------------------------------- */
:root {
  /* Warm romantic palette */
  --ivory:        #FBF7F0;  /* page background */
  --cream:        #FFFDF8;  /* card surface */
  --cream-2:      #F4ECDF;  /* subtle fills */
  --blush:        #E7C9C2;  /* muted blush accent */
  --blush-soft:   #F3E2DD;
  --sage:         #7C8A6E;  /* muted sage */
  --evergreen:    #2E3D31;  /* deep accent / text */
  --gold:         #B89455;  /* antique gold */
  --gold-deep:    #9A7937;

  --ink:          #2B2A27;  /* primary text (AA on ivory) */
  --ink-soft:     #5C574E;  /* secondary text */
  --line:         #E4DAC9;  /* hairlines */
  --error:        #A03A2E;
  --error-bg:     #F7E6E2;
  --warn-bg:      #F6EFDD;
  --warn-line:    #E2CF9A;

  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius:   16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(46, 61, 49, 0.05);
  --shadow:    0 6px 24px rgba(46, 61, 49, 0.08);
  --shadow-lg: 0 14px 40px rgba(46, 61, 49, 0.12);

  --tap: 44px; /* minimum tap target */
}

/* ---- Reset / base --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* The [hidden] attribute must always win over class display rules
   (e.g. .modal-backdrop { display:flex }), so hidden things stay hidden. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;          /* >= 16px requirement */
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--ivory);
  /* Subtle warm radial wash + very faint grain — restrained, not busy */
  background-image:
    radial-gradient(120% 70% at 50% -10%, #FFFDF8 0%, var(--ivory) 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.018'/%3E%3C/svg%3E");
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;       /* never horizontal-scroll */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button, input, textarea {
  font: inherit;
  color: inherit;
}

/* Visually hidden but available to assistive tech */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Visible focus everywhere (keyboard) */
:focus-visible {
  outline: 3px solid var(--sage);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- Layout --------------------------------------------------------- */
.page {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(20px, 6vw, 44px) clamp(16px, 5vw, 28px) 48px;
  /* honor iOS safe areas */
  padding-left: max(clamp(16px, 5vw, 28px), env(safe-area-inset-left));
  padding-right: max(clamp(16px, 5vw, 28px), env(safe-area-inset-right));
}

/* ---- Hero ----------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 8px 4px 26px;
}

.flourish {
  width: 200px;
  max-width: 70%;
  height: auto;
  margin: 0 auto 14px;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.1;
  stroke-linecap: round;
  opacity: 0.85;
}
.flourish-leaf { stroke: var(--sage); }

.hero-eyebrow {
  margin: 0 0 6px;
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 600;
}

.couple-names {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.7rem, 13vw, 4rem);
  line-height: 1.02;
  margin: 0;
  color: var(--evergreen);
  letter-spacing: 0.01em;
}

.wedding-date {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  color: var(--ink-soft);
  margin: 8px 0 0;
}

.hero-invite {
  margin: 16px auto 0;
  max-width: 30em;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

/* ---- Cards ---------------------------------------------------------- */
.card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 6vw, 32px);
  margin-top: 18px;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--evergreen);
  margin: 0 0 18px;
  text-align: center;
  position: relative;
}
.card-title::after {
  content: "";
  display: block;
  width: 42px;
  height: 2px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ---- Banners (warnings / errors) ----------------------------------- */
.banner {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.95rem;
  line-height: 1.45;
}
.banner-warning {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: #6a531a;
}
.banner-error {
  background: var(--error-bg);
  border: 1px solid #E3B6AE;
  color: var(--error);
}

/* ---- Form fields ---------------------------------------------------- */
.field { margin-bottom: 22px; }

.field > label,
.field-label-text {
  display: block;
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--evergreen);
  margin-bottom: 7px;
}

.optional {
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
}

input[type="text"],
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
textarea { resize: vertical; line-height: 1.5; }

input[type="text"]::placeholder,
textarea::placeholder { color: #A79F90; }

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(124, 138, 110, 0.18);
}

input[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(160, 58, 46, 0.14);
}

.field-help {
  margin: 6px 2px 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.field-error {
  margin: 7px 2px 0;
  font-size: 0.88rem;
  color: var(--error);
  font-weight: 500;
}

/* ---- File picker ---------------------------------------------------- */
.filepicker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 120px;
  padding: 22px 16px;
  cursor: pointer;
  text-align: center;
  background: var(--cream);
  border: 1.5px dashed var(--gold);
  border-radius: var(--radius);
  color: var(--evergreen);
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.08s ease;
}
.filepicker:hover { background: var(--blush-soft); }
.filepicker:active { transform: scale(0.992); }
.filepicker.is-drag {
  background: var(--blush-soft);
  border-color: var(--sage);
  border-style: solid;
}
/* Reflect keyboard focus on the native input onto the styled label */
#file-input:focus-visible + .filepicker {
  outline: 3px solid var(--sage);
  outline-offset: 2px;
}

.filepicker-icon {
  width: 30px; height: 30px;
  fill: none;
  stroke: var(--gold-deep);
  stroke-width: 2;
  stroke-linecap: round;
  margin-bottom: 4px;
}
.filepicker-text { font-weight: 600; font-size: 1.06rem; }
.filepicker-sub { font-size: 0.85rem; color: var(--ink-soft); }

/* ---- Selected file list -------------------------------------------- */
.file-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.file-list:empty { margin: 0; }

.file-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  animation: fade-slide 0.32s ease both;
}

.file-thumb {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--cream-2);
  border: 1px solid var(--line);
}
.file-thumb.is-video {
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-thumb.is-video svg {
  width: 26px; height: 26px;
  fill: none;
  stroke: var(--sage);
  stroke-width: 1.7;
}

.file-meta { min-width: 0; }
.file-name {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size { font-size: 0.82rem; color: var(--ink-soft); }

/* Per-file status row */
.file-status { font-size: 0.82rem; margin-top: 4px; }
.file-status.is-error { color: var(--error); font-weight: 600; }
.file-status.is-done  { color: var(--sage); font-weight: 600; }

.file-progress {
  margin-top: 6px;
  height: 5px;
  border-radius: 99px;
  background: var(--cream-2);
  overflow: hidden;
}
.file-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--sage), var(--gold));
  transition: width 0.2s ease;
}

/* Per-file action button (remove or retry) */
.file-action {
  width: var(--tap); height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  flex: 0 0 auto;
}
.file-action:hover { background: var(--blush-soft); color: var(--error); }
.file-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.file-retry {
  width: auto;
  height: var(--tap);
  padding: 0 14px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-deep);
  border: 1.5px solid var(--gold);
  background: var(--cream);
}
.file-retry:hover { background: var(--warn-bg); color: var(--gold-deep); }

/* ---- Overall progress ---------------------------------------------- */
.overall { margin: 4px 0 20px; }
.overall-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.overall-label { font-weight: 600; color: var(--evergreen); }
.overall-count { font-size: 0.88rem; color: var(--ink-soft); }

.progress {
  height: 10px;
  border-radius: 99px;
  background: var(--cream-2);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blush), var(--gold), var(--sage));
  background-size: 200% 100%;
  transition: width 0.25s ease;
  animation: shimmer 2.4s linear infinite;
}

/* ---- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;            /* >= 44px tap target */
  padding: 14px 22px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.995); }

.btn-primary {
  color: #FFFDF8;
  background: linear-gradient(135deg, var(--evergreen), var(--sage));
  box-shadow: var(--shadow);
}
.btn-primary:hover { box-shadow: var(--shadow-lg); }
.btn-primary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  background: var(--ink-soft);
}

.btn-secondary {
  color: var(--evergreen);
  background: var(--cream);
  border: 1.5px solid var(--gold);
}
.btn-secondary:hover { background: var(--warn-bg); }

/* Uploading spinner inside button */
.btn-spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 253, 248, 0.45);
  border-top-color: #FFFDF8;
  animation: spin 0.8s linear infinite;
  display: none;
}
.btn.is-busy .btn-spinner { display: inline-block; }

.form-hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

/* ---- Success screen ------------------------------------------------- */
.card-success { text-align: center; }
.success-mark {
  width: 70px; height: 70px;
  margin: 0 auto 8px;
  fill: none;
  stroke: var(--sage);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.success-mark circle { opacity: 0.35; }
.success-mark path { stroke: var(--gold-deep); stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.7s ease 0.15s forwards; }

.success-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  color: var(--evergreen);
  margin: 6px 0 10px;
}
.success-detail { color: var(--ink); margin: 0 0 4px; font-size: 1.05rem; }
.success-sub {
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 22px;
}

/* ---- Footer --------------------------------------------------------- */
.page-footer {
  text-align: center;
  margin-top: 30px;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1rem;
}

/* ---- Entrance animations ------------------------------------------- */
.hero, .card { animation: fade-slide 0.6s ease both; }
.card { animation-delay: 0.08s; }

@keyframes fade-slide {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---- Reduced motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .progress-bar { animation: none; }
}

/* ---- Larger screens: a touch more air ------------------------------ */
@media (min-width: 600px) {
  .file-name { font-size: 1rem; }
}

/* ---- Dark-ish environments: keep warmth, never pure black ---------- */
@media (prefers-color-scheme: dark) {
  /* The reception hall is dim, but we keep the ivory paper feel on purpose.
     We only deepen the page surround slightly so the card glows. */
  body { background-color: #F3ECE1; }
}

/* ---- Upload progress modal ("mini pop-up") ------------------------- */
body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(46, 61, 49, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: modal-fade 0.25s ease both;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 30px 26px 26px;
  text-align: center;
  animation: modal-pop 0.3s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.modal-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid var(--cream-2);
  border-top-color: var(--gold);
  animation: modal-spin 0.9s linear infinite;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--evergreen);
  margin: 0 0 16px;
  line-height: 1.2;
}

.modal-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--cream-2);
  overflow: hidden;
  margin: 0 0 12px;
}

.modal-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sage), var(--gold));
  transition: width 0.3s ease;
}

.modal-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
}

@keyframes modal-spin { to { transform: rotate(360deg); } }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-spinner { animation-duration: 1.8s; }
  .modal-backdrop, .modal-card { animation: none; }
  .modal-bar { transition: none; }
}

/* ---- Hero photo (Lily & Nima) -------------------------------------- */
.hero-photo {
  margin: 0 auto 24px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
  aspect-ratio: 3 / 2;
  background: var(--cream-2);
  line-height: 0;
  animation: photo-reveal 0.9s ease both;
}
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 60%;
  display: block;
}
.hero-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(46, 61, 49, 0) 55%, rgba(251, 247, 240, 0.4) 100%);
  pointer-events: none;
}
@keyframes photo-reveal { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hero-photo { animation: none; } }

/* ---- File-select feedback + lazy thumbnail placeholder ------------- */
.files-status { color: var(--gold-deep); font-size: 0.9rem; margin: 9px 0 0; font-weight: 600; }
img.file-thumb { background: var(--cream-2); }
