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

:root {
  --cream: #faf6f0;
  --blush: #f3e6de;
  --sage: #8a9a82;
  --sage-dark: #6c7a65;
  --ink: #332f2b;
  --ink-soft: #6b6560;
  --gold: #c8a866;
  --white: #ffffff;
  --danger: #b5544a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(51, 47, 43, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.5;
}

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

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

.hero {
  position: relative;
  min-height: 46vh;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(135deg, var(--blush), var(--sage) 140%);
  background-size: cover;
  background-position: center;
  color: var(--white);
}
.hero.has-image { background-image: var(--cover-url); }
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(30, 25, 20, 0.55), rgba(30, 25, 20, 0.05) 60%);
}
.hero-inner {
  position: relative;
  z-index: 1;
  padding: 48px 24px;
  width: 100%;
  text-align: center;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); text-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.hero p { font-size: 1.05rem; opacity: 0.95; margin: 0; }

/* Text pulled from the "Site Text" admin tab starts hidden and is only
   revealed once JavaScript has confirmed the correct wording (either
   from a cached copy or a fresh fetch) - see main.js. This deliberately
   trades a brief blank moment on a visitor's very first visit for never
   showing the wrong (default/placeholder) text, even for a moment. */
[data-content-key] { visibility: hidden; }
[data-content-key].content-ready { visibility: visible; }

main { max-width: 980px; margin: 0 auto; padding: 40px 20px 80px; }

section { margin-bottom: 56px; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.subtle { color: var(--ink-soft); font-size: 0.95rem; }

label { font-weight: 500; }

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2dcd4;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  margin-top: 6px;
}
input[type="text"]:focus { outline: 2px solid var(--sage); border-color: transparent; }

textarea {
  padding: 12px 14px;
  border: 1px solid #e2dcd4;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  margin-top: 6px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--sage); border-color: transparent; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--sage-dark); }
.checkbox-row .hint { color: var(--ink-soft); font-size: 0.88rem; margin-left: 6px; }

.dropzone {
  border: 2px dashed #d9cfc2;
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  margin-top: 18px;
  transition: border-color 0.15s, background 0.15s;
  color: var(--ink-soft);
}
.dropzone.drag { border-color: var(--sage-dark); background: #f8f5ef; }
.dropzone input { display: none; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 13px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--sage-dark);
  color: var(--white);
  transition: transform 0.1s, opacity 0.15s;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--ink); border: 1px solid #ddd4c8; }
.btn-danger { background: var(--danger); }
.btn-small { padding: 8px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 20px; }

.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.upload-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.88rem; color: var(--ink-soft);
}
.upload-row .bar {
  flex: 1; height: 6px; background: #eee; border-radius: 4px; overflow: hidden;
}
.upload-row .bar-fill { height: 100%; background: var(--sage); width: 0%; transition: width 0.2s; }
.upload-row .status { width: 90px; text-align: right; flex-shrink: 0; }
.upload-row.done .status { color: var(--sage-dark); }
.upload-row.error .status { color: var(--danger); }

.gallery-header { margin-bottom: 18px; }
.note {
  background: var(--blush);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--ink);
  display: inline-block;
}

.gallery-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.sort-label {
  font-size: 0.88rem;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.sort-label select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #ddd4c8;
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--white);
  color: var(--ink);
}

.gallery-grid { -webkit-touch-callout: none; }
.gallery-grid.selecting .dl { display: none; }
.gallery-grid.selecting .photo-card img { cursor: pointer; }

.photo-card .select-check {
  position: absolute;
  top: 6px; right: 6px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  background: rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  z-index: 2;
}
.gallery-grid.selecting .select-check,
.admin-photo-card .select-check.always { display: flex; }
.gallery-grid.selecting .photo-card .select-check { display: flex; }
.photo-card.selected { outline: 3px solid var(--sage-dark); outline-offset: -3px; }
.photo-card.selected .select-check {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
}
.photo-card.selected .select-check::after { content: "✓"; }

.selection-bar {
  position: fixed;
  left: 50%; bottom: 20px;
  transform: translateX(-50%) translateY(140%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  z-index: 90;
  max-width: 92vw;
}
.selection-bar.open { transform: translateX(-50%) translateY(0); }
.selection-bar .btn { padding: 8px 16px; font-size: 0.85rem; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.photo-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: #eee;
  box-shadow: var(--shadow);
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.photo-card .caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65), transparent);
  color: #fff; font-size: 0.78rem; padding: 18px 8px 6px;
}
.photo-card .dl {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  color: var(--ink);
  font-size: 1rem;
}
.empty-state { color: var(--ink-soft); font-style: italic; padding: 20px 0; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(20,17,14,0.92);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; z-index: 100; padding: 20px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 78vh; border-radius: 8px; }
.lightbox .lb-bar { margin-top: 16px; display: flex; gap: 12px; align-items: center; color: #fff; flex-wrap: wrap; justify-content: center; text-align: center; }
.lightbox .lb-close {
  position: absolute; top: 18px; right: 24px; color: #fff;
  font-size: 2rem; cursor: pointer; background: none; border: none;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 1.8rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.lb-nav:hover { background: rgba(255,255,255,0.25); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-log { max-width: 90vw; overflow: auto; background: #fff; border-radius: 10px; padding: 14px; margin-top: 14px; }

footer { text-align: center; padding: 30px; color: var(--ink-soft); font-size: 0.85rem; }

/* Admin / login specific */
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
  padding: 18px 24px; background: var(--white); box-shadow: var(--shadow);
}
.admin-header h1 { font-size: 1.4rem; margin: 0; }
.admin-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 9px 18px; border-radius: 999px; border: 1px solid #ddd4c8;
  background: var(--white); cursor: pointer; font-family: inherit; font-weight: 500;
}
.tab-btn.active { background: var(--sage-dark); color: #fff; border-color: var(--sage-dark); }

.admin-toolbar-row {
  margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.toolbar-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.cover-preview-wrap { margin: 16px 0; }
.cover-preview-wrap img { max-width: 100%; border-radius: 10px; }

.form-field { margin-top: 14px; }
.form-field:first-of-type { margin-top: 0; }
.form-field label { display: block; margin-bottom: 6px; }
.form-field input, .form-field textarea { width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table th, table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #eee; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blush), var(--sage) 140%);
}
.login-card { background: var(--white); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; max-width: 380px; }

.admin-photo-card { position: relative; }
.admin-photo-card .badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.65); color: #fff; font-size: 0.68rem;
  padding: 2px 8px; border-radius: 999px;
}
.admin-photo-card .meta { font-size: 0.72rem; padding: 4px 8px 8px; color: var(--ink-soft); }
.admin-photo-card .actions { display: flex; gap: 6px; padding: 0 8px 8px; }

@media (max-width: 600px) {
  main { padding: 28px 14px 60px; }
  .card { padding: 20px; }
  .admin-header { padding: 14px 16px; }
  .admin-header h1 { font-size: 1.15rem; }
  .admin-toolbar-row { flex-direction: column; align-items: stretch; }
  .toolbar-controls { justify-content: space-between; }
  .lb-nav { width: 40px; height: 40px; font-size: 1.5rem; }
  .selection-bar { flex-wrap: wrap; justify-content: center; text-align: center; bottom: 12px; padding: 10px 14px; }
}
