/* ---- Tokens ---- */
:root {
  --pine: #1F3A2E;
  --pine-dark: #142720;
  --sky: #3C5872;
  --parchment: #EFE8D8;
  --paper: #FAF7F0;
  --ember: #BD5B2C;
  --ember-dark: #9C4A22;
  --charcoal: #272420;
  --line: #C9BFA0;
  --danger: #8C2F2F;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Work Sans", -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--charcoal);
  line-height: 1.5;
}
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 3px solid var(--ember);
  outline-offset: 2px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--pine-dark);
  line-height: 1.15;
  margin: 0 0 0.5em;
}
h1 { font-size: 2.4rem; font-weight: 600; }
h2 { font-size: 1.6rem; font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 500; }

p { max-width: 68ch; }

/* ---- Header / nav ---- */
.site-header {
  background: var(--pine);
  color: var(--parchment);
}
.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--parchment);
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 14px; height: 14px;
  background: var(--ember);
  border-radius: 50%;
  display: inline-block;
}
.brand__text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.95rem;
}
.main-nav a {
  color: var(--parchment);
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
.main-nav a:hover, .main-nav a.is-active {
  text-decoration: none;
  border-bottom-color: var(--ember);
}
.nav-user { color: var(--line); }
.nav-login, .nav-logout {
  background: var(--ember);
  color: #fff !important;
  padding: 6px 14px;
  border-radius: 3px;
  border-bottom: none !important;
}
.nav-login:hover, .nav-logout:hover {
  background: var(--ember-dark);
}
.contour-strip {
  height: 20px;
  background-image: url('/assets/contour.svg');
  background-repeat: repeat-x;
  background-size: 240px 20px;
  background-color: var(--pine-dark);
}

/* ---- Layout ---- */
.site-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  min-height: 60vh;
}
.page-head {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.page-head p { color: #5b564d; }

.site-footer {
  text-align: center;
  padding: 24px;
  color: #8a8474;
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

/* ---- Flash messages ---- */
.flash {
  padding: 12px 16px;
  border-radius: 3px;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.flash--error { background: #f6e4e0; color: var(--danger); border: 1px solid #e2b5ab; }
.flash--ok { background: #e6ede4; color: var(--pine-dark); border: 1px solid #b9d0b3; }

/* ---- Forms ---- */
.form-card {
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 28px;
}
label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.92rem;
}
input[type=text], input[type=password], input[type=file], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 1rem;
  margin-bottom: 16px;
  background: var(--paper);
}
textarea { resize: vertical; min-height: 70px; }
button, .btn {
  display: inline-block;
  background: var(--pine);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--pine-dark); text-decoration: none; }
.btn--ember { background: var(--ember); }
.btn--ember:hover { background: var(--ember-dark); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #6f2222; }
.btn--ghost {
  background: transparent;
  color: var(--pine);
  border: 1px solid var(--line);
}
.btn--ghost:hover { background: var(--parchment); }

/* ---- Photo grid ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.photo-grid .photo-tile {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
  border-radius: 2px;
}
.photo-grid .photo-tile .tile-link { display: block; }
.photo-grid .photo-tile img {
  width: 100%;
  border-radius: 1px;
  cursor: zoom-in;
}
input.tile-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--ember);
}
.photo-tile__meta {
  font-size: 0.72rem;
  color: #857f70;
  padding: 4px 2px 0;
}
@media (max-width: 1000px) { .photo-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px)  { .photo-grid { grid-template-columns: repeat(1, 1fr); } }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 40px 24px;
  text-align: center;
  color: #5b564d;
}

/* ---- Uploader / timeline listings ---- */
.uploader-list, .date-list {
  list-style: none;
  padding: 0;
  margin: 0 0 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.uploader-list a, .date-list a {
  display: block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  color: var(--charcoal);
  font-size: 0.9rem;
}
.uploader-list a:hover, .date-list a:hover, .uploader-list a.is-active, .date-list a.is-active {
  border-color: var(--ember);
  text-decoration: none;
}
.uploader-list a.is-active, .date-list a.is-active {
  background: var(--ember);
  color: #fff;
}

.event-section { margin-bottom: 44px; }
.event-section__head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.event-section__head h2 { margin: 0; }
.event-section__date { color: #857f70; font-size: 0.95rem; }
.event-label-form { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.event-label-form input[type=text] { margin-bottom: 0; padding: 6px 10px; font-size: 0.85rem; width: 220px; }
.event-label-form button { padding: 6px 12px; font-size: 0.85rem; }

/* ---- Single photo view ---- */
.photo-view {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(220px, 1fr);
  gap: 28px;
}
.photo-view img {
  border: 1px solid var(--line);
  border-radius: 2px;
  width: 100%;
}
.photo-view__meta dt { font-weight: 600; font-size: 0.85rem; color: #5b564d; margin-top: 14px; }
.photo-view__meta dd { margin: 2px 0 0; }
@media (max-width: 760px) {
  .photo-view { grid-template-columns: 1fr; }
}

/* ---- Upload page ---- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 6px;
  padding: 36px 20px;
  text-align: center;
  background: #fff;
  cursor: pointer;
  margin-bottom: 20px;
}
.dropzone.is-dragover { border-color: var(--ember); background: var(--parchment); }
.file-count { font-weight: 500; margin-bottom: 16px; }
.progress-track {
  height: 10px;
  background: var(--parchment);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar {
  height: 100%;
  background: var(--ember);
  width: 0%;
  transition: width 0.2s ease;
}
.upload-log {
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 14px;
  background: #fff;
}
.upload-log .row { padding: 3px 0; border-bottom: 1px solid #f0ece0; }
.upload-log .row.err { color: var(--danger); }
.upload-log .row.ok { color: var(--pine-dark); }

.failed-list {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  padding: 4px 14px;
}
.failed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #f0ece0;
}
.failed-row:last-child { border-bottom: none; }
.failed-row__info { flex: 1; min-width: 0; }
.failed-row__name { font-weight: 500; word-break: break-word; }
.failed-row__reason { font-size: 0.82rem; color: var(--danger); margin-top: 2px; }
.retry-btn { flex-shrink: 0; }

/* ---- Admin ---- */
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  margin-bottom: 32px;
}
table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
table.admin-table th { color: #5b564d; font-weight: 600; }

.pagination { display: flex; gap: 10px; margin-top: 28px; }

/* ---- Lightbox / slideshow ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 39, 32, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px 20px;
  z-index: 1000;
}
.lightbox-overlay.is-open { display: flex; }
.lightbox-image {
  max-width: 90vw;
  max-height: 76vh;
  cursor: zoom-in;
  border: 2px solid var(--parchment);
  background: #111;
}
.lightbox-caption {
  color: var(--parchment);
  margin-top: 14px;
  font-size: 0.95rem;
  text-align: center;
  max-width: 80vw;
}
.lightbox-edit-link { color: var(--ember); }
.lightbox-hint { color: #a9a08a; font-size: 0.78rem; margin-top: 6px; }
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 24px;
  background: none;
  border: none;
  color: var(--parchment);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 2.4rem;
  width: 52px;
  height: 64px;
  cursor: pointer;
  border-radius: 4px;
}
.lightbox-prev:hover, .lightbox-next:hover, .lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
@media (max-width: 700px) {
  .lightbox-prev, .lightbox-next { width: 40px; height: 52px; font-size: 1.8rem; }
}

/* ---- Bulk delete bar ---- */
.bulk-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--pine);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px;
  transform: translateY(100%);
  transition: transform 0.2s ease;
  z-index: 900;
}
.bulk-bar.is-visible { transform: translateY(0); }
