@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,600;1,500&family=EB+Garamond:ital,wght@0,400;0,500;1,400&family=Great+Vibes&display=swap');

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --ink: #2a2420;
  --ink-soft: #6b6259;
  --accent: #b06500;
  --accent-dark: #8a4f00;
  --line: #e6e1d9;
  --danger: #a13a2f;
  --paid: #3f6b3a;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(42, 36, 32, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'EB Garamond', serif;
  font-size: 18px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  margin: 0 0 0.4em;
  letter-spacing: 0.01em;
}

a { color: var(--accent-dark); }

button {
  font-family: 'EB Garamond', serif;
  cursor: pointer;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- Header ---------- */

.site-header {
  padding: 48px 0 32px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.site-header img.logo {
  width: min(380px, 80%);
  height: auto;
  object-fit: contain;
}

.gallery-meta {
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 17px;
}

.gallery-title {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: 24px;
  color: var(--ink);
}

.days-left {
  margin-top: 6px;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 500;
}

.gallery-details {
  margin-top: 6px;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ---------- Empty / landing states ---------- */

.empty-state {
  text-align: center;
  padding: 120px 20px;
  color: var(--ink-soft);
}

.empty-state h1 { color: var(--ink); font-size: 28px; }

/* ---------- Photo grid ---------- */

/* Each photo keeps its own proportions (horizontal or vertical): columns of
   different heights, filled top to bottom, with no cropping. */
.photo-grid {
  column-width: 260px;
  column-gap: 22px;
  padding: 40px 0 140px;
}

.photo-card {
  position: relative;
  display: block;
  margin: 0 0 22px;
  break-inside: avoid;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.photo-card img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.photo-card.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.select-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.85);
  background: rgba(42, 36, 32, 0.35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.photo-card.selected .select-toggle {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Sticky selection bar ---------- */

.selection-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--ink);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 40;
}

.selection-bar.visible { transform: translateY(0); }

.selection-bar .count { font-family: 'Playfair Display', serif; font-size: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-size: 16px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.secondary:hover { border-color: var(--ink-soft); }

.btn.on-dark {
  border-color: #fff;
}

/* ---------- Modal / Lightbox ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 14, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 24px;
}

.overlay.visible { display: flex; }

.lightbox img {
  max-width: 88vw;
  max-height: 74vh;
  display: block;
  margin: 0 auto;
  border-radius: 2px;
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #fff;
  font-size: 34px;
  padding: 12px;
}

.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }

.overlay-close {
  position: fixed;
  top: 20px;
  right: 26px;
  color: #fff;
  font-size: 30px;
  background: none;
  border: none;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 420px;
}

.modal-card h2 { font-size: 22px; }
.modal-card p { color: var(--ink-soft); margin-top: 0; }

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field input, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: 'EB Garamond', serif;
  font-size: 17px;
  background: var(--bg);
}

.field input:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Admin ---------- */

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 22px;
  background: var(--surface);
}

.admin-sidebar .logo { width: 100%; max-width: 210px; height: auto; margin-bottom: 24px; }

.gallery-list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 16px;
  margin-bottom: 4px;
}

.gallery-list-item.active {
  background: var(--bg);
  color: var(--accent-dark);
  font-weight: 500;
}

.admin-main {
  padding: 36px 40px 80px;
}

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px;
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 32px;
  transition: border-color 0.15s ease;
}

.dropzone.drag { border-color: var(--accent); color: var(--accent-dark); }

.admin-photo-grid {
  column-width: 180px;
  column-gap: 16px;
}

.admin-photo-card {
  position: relative;
  display: block;
  margin: 0 0 16px;
  break-inside: avoid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.admin-photo-card img {
  width: 100%;
  height: auto;
  display: block;
}

.admin-photo-card .remove {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(42,36,32,0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 14px;
}

.selection-entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  background: var(--surface);
}

.selection-entry .thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.selection-entry .thumbs img {
  width: 64px; height: 80px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  display: block;
}

.selection-entry .thumb {
  margin: 0;
  width: 84px;
}

.selection-entry .thumb figcaption {
  font-size: 12px;
  line-height: 1.25;
  color: var(--ink-soft);
  margin-top: 4px;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.photos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search-input {
  width: 100%;
  max-width: 320px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: 'EB Garamond', serif;
  font-size: 17px;
  background: var(--surface);
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.photo-filename {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Payments (admin) ---------- */

.btn:disabled { opacity: 0.55; cursor: default; }

.selection-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.selection-actions .btn { padding: 8px 16px; font-size: 15px; }

.thumb-paid-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 3px 0;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.thumb-paid-btn:hover:not(:disabled) { border-color: var(--accent); }
.thumb-paid-btn:disabled { opacity: 0.55; cursor: default; }

.selection-entry .thumb.paid img { outline: 2px solid var(--paid); outline-offset: -2px; }

.selection-entry .thumb.paid .thumb-paid-btn {
  background: var(--paid);
  border-color: var(--paid);
  color: #fff;
}

.admin-paid-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--paid);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

/* ---------- Payments (client gallery) ---------- */

.photo-card.paid { outline: 2px solid var(--paid); outline-offset: -2px; }

.paid-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--paid);
  color: #fff;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Overlaid on the bottom of the photo so paid and unpaid cards stay the same size */
.download-btn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  text-align: center;
  padding: 11px;
  background: rgba(63, 107, 58, 0.92);
  color: #fff;
  text-decoration: none;
  font-size: 16px;
}

.download-btn:hover { background: #2f5230; }

/* Bar above the grid with "Download all" for purchased photos */
.paid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 32px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--paid);
  border-radius: var(--radius);
}

.paid-toolbar + .photo-grid { padding-top: 24px; }

.paid-toolbar-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.paid-toolbar-info strong { font-family: 'Playfair Display', serif; font-weight: 600; font-size: 18px; color: var(--ink); }
.paid-toolbar-status { font-size: 15px; color: var(--ink-soft); }
.paid-toolbar-status:empty { display: none; }
.paid-toolbar-status.error { color: var(--danger); }

.download-all-btn { background: var(--paid); border-color: var(--paid); }
.download-all-btn:hover { background: #2f5230; border-color: #2f5230; }
.download-all-btn:disabled { opacity: 0.6; cursor: default; }
.download-all-btn:disabled:hover { background: var(--paid); border-color: var(--paid); }

.lightbox { text-align: center; }

.lightbox-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 14px;
}

.lightbox-download { text-decoration: none; }

/* Select button inside the enlarged photo: outlined = not selected, filled = selected */
.lightbox-select {
  background: transparent;
  color: #fff;
  border-color: #fff;
}

.lightbox-select:hover { background: rgba(255, 255, 255, 0.14); border-color: #fff; }

.lightbox-select.selected,
.lightbox-select.selected:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.lightbox-count {
  color: #fff;
  font-family: 'Playfair Display', serif;
  font-size: 17px;
}

/* The bottom bar is shown from the start; Finish stays off until something is selected */
.btn:disabled { cursor: default; }
.selection-bar .btn:disabled { opacity: 0.45; }
.selection-bar .btn:disabled:hover { background: var(--accent); border-color: #fff; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 44px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card img { width: 220px; max-width: 80%; height: auto; margin-bottom: 20px; }

.hint { font-size: 14px; color: var(--ink-soft); margin-top: 6px; }

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.link-row .hint {
  margin: 0;
  word-break: break-all;
}

.btn-small { padding: 6px 14px; font-size: 14px; }

.btn.copied,
.btn.secondary.copied {
  background: var(--paid);
  border-color: var(--paid);
  color: #fff;
}

.error-text { color: var(--danger); font-size: 15px; margin: 10px 0 0; }

@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { border-right: none; border-bottom: 1px solid var(--line); }
}

/* ---------- Gallery cover ---------- */

.cover {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4.5 / 1;
  margin-top: 32px;
  background: #d9d3c8;
  container-type: inline-size;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-img {
  position: absolute;
  max-width: none;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity .4s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.cover-img.ready { opacity: 1; }

/* very light veil so white lettering stays readable on bright photos */
.cover-shade {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.10);
  pointer-events: none;
}

.cover-title {
  position: relative;
  margin: 0;
  padding: 0 6%;
  text-align: center;
  font-family: 'Great Vibes', 'Snell Roundhand', cursive;
  font-weight: 400;
  font-size: 11cqw;
  font-size: clamp(30px, 11cqw, 128px);
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  overflow-wrap: anywhere;
}

.cover-meta {
  margin: 14px 0 0;
  padding-bottom: 6px;
  text-align: center;
  font-family: system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  letter-spacing: .01em;
  color: #7a7a7a;
}

@container (max-width: 640px) {
  .cover-title { font-size: clamp(30px, 15cqw, 128px); }
}

@media (max-width: 760px) {
  .cover { aspect-ratio: 4 / 3; margin-top: 20px; }
  .cover-meta { font-size: 14px; }
}

/* ---------- Cover editor (admin) ---------- */

.cover-editor { margin: 8px 0 28px; }
.cover-editor-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cover-toggle { display: flex; gap: 6px; }
.cover-toggle .btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.cover-edit { margin-top: 0; cursor: grab; touch-action: none; outline-offset: 3px; }
.cover-edit.dragging { cursor: grabbing; }
.cover-edit.phone { width: min(100%, 390px); aspect-ratio: 4 / 3; margin-left: auto; margin-right: auto; }
.cover-edit .cover-title { }

.cover-drag-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  pointer-events: none;
  transition: opacity .3s;
  white-space: nowrap;
}
.cover-edit.dragging .cover-drag-hint { opacity: 0; }

.cover-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 6px; }
.zoom-field { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink-soft); }
.zoom-field input { width: 160px; accent-color: var(--accent); }

.cover-pick {
  position: absolute;
  bottom: 38px;
  left: 8px;
  padding: 4px 10px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.cover-pick:hover { background: #fff; }
.cover-pick.active { background: var(--accent); color: #fff; }
.cover-pick:disabled { opacity: .6; cursor: default; }
