/* Wedding album — an ivory invitation, then a photo-first editorial gallery.
   Local fonts only. All upload, gallery and viewer states live in this file. */
:root {
  color-scheme: light;
  --bg: #fbf8f2;
  --surface: #fffdf9;
  --text: #342d30;
  --muted: #716665;
  --accent: #713d50;
  --accent-hover: #593040;
  --olive: #60664e;
  --line: #ded4c8;
  --champagne: #c9b79b;
  --danger: #a0393f;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --album-width: 1040px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100vh; min-height: 100dvh; font-size: 15px; line-height: 1.5; }
button, input { font: inherit; }
button { min-height: 44px; cursor: pointer; touch-action: manipulation; }
button, [role="button"] { -webkit-user-select: none; user-select: none; }
button:disabled { cursor: not-allowed; }
button, input, [role="button"] { outline-offset: 4px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
::selection { background: #e7d4db; color: var(--text); }
.hidden { display: none !important; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid #d9cbd0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}
.spinner.light { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* The invitation: one quiet arch and a fine inner stationery rule. */
#welcomeScreen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}
.welcome-card {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 448px;
  padding: 46px 28px 30px;
  border: 1px solid var(--champagne);
  border-radius: 240px 240px 8px 8px;
  background: var(--surface);
  text-align: center;
}
.welcome-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 9px;
  border: 1px solid #e9dfd0;
  border-radius: 230px 230px 3px 3px;
  pointer-events: none;
}
.wedding-mark {
  width: max-content;
  min-width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  white-space: nowrap;
}
.eyebrow, .welcome-kicker, .hero-eyebrow {
  margin: 0 0 12px;
  color: var(--olive);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: .19em;
  text-transform: uppercase;
}
.welcome-title {
  margin: 0 auto 14px;
  max-width: 350px;
  color: var(--accent);
  font-family: var(--serif);
  font-size: clamp(34px, 9vw, 48px);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.welcome-date {
  margin: 0 0 20px;
  color: var(--olive);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.welcome-copy {
  max-width: 310px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-wrap: pretty;
}
.name-label {
  display: block;
  margin: 0 0 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.name-input {
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  border: 1px solid #cbbfb5;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  text-align: left;
}
.name-input::placeholder { color: #7b706e; opacity: 1; }
.name-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #efe3e7; }
.enter-button, .upload-main-button {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  padding: 13px 18px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fffdf9;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .02em;
}
.enter-button:disabled, .upload-main-button:disabled { background: #e9e2df; border-color: #d5c9c5; color: #77686e; }
.welcome-note { margin: 16px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.error-message { min-height: 20px; margin-top: 12px; color: var(--danger); font-size: 13px; }

/* Direct Drive navigation remains available when the API/quota is unavailable. */
.drive-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
}
.drive-button:hover { background: var(--surface); border-color: var(--accent); }
.drive-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.welcome-drive-button { width: 100%; margin-top: 12px; white-space: normal; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
@media (max-width: 360px) {
  body .topbar { padding-inline: 12px; gap: 8px; }
  .topbar .brand-title { font-size: 20px; }
  .topbar .drive-button { padding-inline: 8px; font-size: 11px; }
}

/* A compact album opening keeps the first photographs in view. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand { min-width: 0; }
.brand-label { margin-bottom: 2px; color: var(--olive); font-size: 9px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.brand-title {
  margin: 0;
  overflow: hidden;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.add-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  color: #fffdf9;
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
}
.header-upload-label { display: none; font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.hero, .gallery-wrap { width: 100%; max-width: var(--album-width); margin-inline: auto; }
.hero { padding: 24px 20px 19px; text-align: left; }
.hello { margin: 0 0 8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.hero-eyebrow { margin-bottom: 6px; }
.hero-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 7.6vw, 42px);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.12;
  text-wrap: balance;
}
.hero-title br { display: initial; }
.hero-title em { color: var(--accent); font-weight: 400; }
.hero-copy { max-width: 520px; margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; text-wrap: pretty; }
.gallery-meta-row { display: flex; align-items: center; gap: 8px; min-height: 20px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.gallery-loading-icon { width: 15px; height: 15px; flex-basis: 15px; }
.gallery-wrap { padding: 0 12px calc(108px + env(safe-area-inset-bottom)); }
.album-toolbar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin: 0 8px 12px; padding-top: 15px; border-top: 1px solid var(--line); }
.album-title { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 400; }
.album-caption { margin: 0; color: var(--muted); font-size: 11px; }
#gallery { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.gallery-item {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: #ede7de;
  cursor: pointer;
  touch-action: manipulation;
}
.gallery-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; z-index: 1; }
.gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .18s ease; }
.gallery-item img.loaded, .gallery-item.loaded img { opacity: 1; }
.thumb-loading { position: absolute; inset: 0; display: grid; place-items: center; background: #ede7de; pointer-events: none; }
.thumb-loading .spinner { width: 16px; height: 16px; }
.thumb-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 15px; color: var(--muted); text-align: center; font-size: 12px; }
.video-badge { position: absolute; top: 9px; right: 9px; z-index: 2; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; background: rgba(30,23,27,.8); color: white; font-size: 11px; pointer-events: none; }
.empty-gallery { padding: 48px 20px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); text-align: center; line-height: 1.8; }
.gallery-status { margin: 14px 4px 0; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.gallery-status:empty { display: none; }
.load-more {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  min-width: 188px;
  max-width: 100%;
  margin: 24px auto 0;
  padding: 12px 22px;
  border: 1px solid #b59ba3;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.load-more-arrow { font-size: 17px; line-height: 1; }
.load-more:disabled { cursor: not-allowed; border-color: var(--line); color: var(--muted); }
.load-more.is-loading { cursor: wait; background: #f2ece7; color: var(--accent); }
.load-more.is-loading .load-more-arrow { display: none; }
.load-more.is-error { border-color: var(--danger); color: var(--danger); background: #fff5f3; }
.album-footer { margin-top: 32px; padding: 20px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--serif); font-size: 14px; font-style: italic; text-align: center; }
.mobile-upload {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 40;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  max-width: calc(100% - 40px);
  padding: 12px 24px;
  transform: translateX(-50%);
  border: 1px solid #8c5d6d;
  border-radius: 999px;
  background: var(--accent);
  color: #fffdf9;
  box-shadow: 0 4px 18px rgba(63,36,46,.17);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Upload: a practical, scrollable sheet with all progress/retry states. */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(39,28,33,.48); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .18s ease, visibility .18s ease; }
.overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }
.upload-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 22px max(26px, env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  transform: translateY(105%);
  transition: transform .2s ease;
}
.overlay.open .upload-sheet { transform: translateY(0); }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 25px; border-radius: 99px; background: #d3c7be; }
.sheet-close { position: absolute; top: 21px; right: 12px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--accent); font-size: 27px; line-height: 1; }
.sheet-title { margin: 0; padding-right: 35px; color: var(--accent); font-family: var(--serif); font-size: 29px; font-weight: 400; letter-spacing: -.025em; line-height: 1.2; }
.sheet-copy { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.picker-box { position: relative; padding: 25px 16px; border: 1px dashed #b79fa4; border-radius: 7px; background: var(--bg); text-align: center; }
.picker-box input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.picker-box:focus-within { outline: 3px solid var(--accent); outline-offset: 4px; }
.picker-icon { margin-bottom: 5px; color: var(--accent); font-family: var(--serif); font-size: 30px; }
.picker-main { color: var(--accent); font-size: 14px; font-weight: 600; }
.picker-sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.selected-count, .overall-progress { margin-top: 14px; color: var(--muted); font-size: 13px; }
.upload-main-button { margin-top: 18px; }
.progress-list { margin-top: 20px; }
.upload-row { margin-bottom: 18px; }
.upload-row-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.upload-filename { min-width: 0; flex: 1 1 auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.upload-status-wrap { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.upload-status { color: var(--muted); }
.retry-button { display: none; align-items: center; justify-content: center; min-width: 52px; min-height: 44px; padding: 8px 10px; border: 1px solid #d6aeb1; border-radius: 5px; background: #fff4f2; color: var(--danger); font-size: 12px; font-weight: 600; }
.retry-button.show { display: inline-flex; }
.retry-button:disabled { opacity: .6; }
.progress-track { height: 6px; overflow: hidden; border-radius: 99px; background: #ece4dc; }
.progress-bar { width: 0; height: 100%; background: var(--accent); transition: width .12s linear; }

/* Viewer: dark, distraction-free, with persistent 44px navigation targets. */
#viewer { position: fixed; inset: 0; z-index: 200; display: none; flex-direction: column; background: #191517; touch-action: pan-y; }
#viewer.open { display: flex; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; min-height: 66px; padding: max(10px, env(safe-area-inset-top)) 16px 8px; color: #fffdf9; }
.viewer-count { color: #e0d6da; font-size: 13px; letter-spacing: .03em; }
.viewer-close { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid #62545a; border-radius: 50%; background: transparent; color: #fffdf9; font-size: 28px; line-height: 1; }
.viewer-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.viewer-track { display: flex; height: 100%; transform: translateX(0); }
.viewer-slide { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; flex: 0 0 100%; padding: 8px 8px max(12px, env(safe-area-inset-bottom)); }
.viewer-slide img, .viewer-slide video { display: block; max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer-loader { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.viewer-message { padding: 24px; color: #e0d6da; font-size: 14px; line-height: 1.6; text-align: center; }
.viewer-prev, .viewer-next { position: absolute; top: 50%; z-index: 5; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; transform: translateY(-50%); border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: rgba(25,21,23,.8); color: #fff; font-size: 28px; line-height: 1; }
.viewer-prev { left: 10px; }
.viewer-next { right: 10px; }
.viewer-prev:disabled, .viewer-next:disabled { opacity: .35; }
#viewer :focus-visible { outline-color: #e7bfce; }
.viewer-hint { flex: 0 0 auto; margin: 0; padding: 10px 18px max(16px, env(safe-area-inset-bottom)); color: #c9bbc1; font-size: 11px; text-align: center; }

#toast { position: fixed; left: 18px; right: 18px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 300; width: auto; max-width: 520px; margin: 0 auto; padding: 14px 18px; border-radius: 7px; background: #34272d; color: #fffdf9; font-size: 13px; line-height: 1.6; text-align: left; white-space: normal; overflow-wrap: anywhere; max-height: 35vh; overflow-y: auto; box-shadow: 0 4px 20px rgba(0,0,0,.15); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
#toast.show { opacity: 1; transform: translateY(0); }

@media (hover: hover) {
  .enter-button:not(:disabled):hover, .upload-main-button:not(:disabled):hover, .add-button:hover, .mobile-upload:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .load-more:not(:disabled):hover { background: #efe5e7; border-color: var(--accent); }
  .gallery-item:hover { outline: 2px solid var(--champagne); outline-offset: 2px; }
  .sheet-close:hover { background: #f0e7e8; }
  .viewer-close:hover, .viewer-prev:not(:disabled):hover, .viewer-next:not(:disabled):hover { background: #49333e; }
}
@media (min-width: 700px) {
  .topbar { padding-inline: max(28px, calc((100vw - 984px) / 2)); padding-bottom: 16px; padding-top: max(16px, env(safe-area-inset-top)); }
  .brand-title { font-size: 27px; }
  .add-button { width: auto; min-width: 148px; padding: 0 18px; border-radius: 5px; }
  .header-upload-label { display: inline; }
  .hero { padding: 30px 28px 24px; }
  .hero-title { font-size: 42px; }
  .hero-copy { font-size: 14px; }
  .gallery-wrap { padding: 0 28px 42px; }
  .album-toolbar { margin-inline: 0; margin-bottom: 16px; }
  .album-caption { font-size: 12px; }
  #gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .gallery-item { border-radius: 6px; }
  .mobile-upload { display: none; }
  .upload-sheet { left: 50%; right: auto; width: 500px; max-width: calc(100vw - 48px); padding-inline: 30px; border-radius: 20px 20px 0 0; transform: translate(-50%,105%); }
  .overlay.open .upload-sheet { transform: translate(-50%,0); }
  .sheet-close { right: 20px; }
  .viewer-slide { padding-inline: 70px; }
  .viewer-prev { left: 20px; }
  .viewer-next { right: 20px; }
  #toast { bottom: max(24px, env(safe-area-inset-bottom)); }
}
@media (max-width: 359px) {
  #welcomeScreen { padding-inline: 14px; }
  .welcome-card { padding-inline: 23px; }
  .welcome-title { font-size: 32px; }
  .topbar { padding-inline: 14px; gap: 10px; }
  .brand-title { font-size: 21px; }
  .hero { padding-inline: 14px; }
  .upload-sheet { padding-inline: 16px; }
  .upload-row-top { flex-wrap: wrap; }
  .upload-filename { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none !important; border-style: dotted; border-top-style: solid; }
  .viewer-track { transition: none !important; }
}
