/* ============================================================
   Wayfarer — warm editorial travel-journal styling
   ============================================================ */

:root {
  --paper:      #f5efe2;  /* warm paper background        */
  --paper-2:    #efe6d4;  /* slightly deeper panel paper  */
  --paper-3:    #e7dcc5;  /* card / inset                 */
  --ink:        #2c2722;  /* warm near-black text         */
  --ink-soft:   #6b6051;  /* muted captions               */
  --ink-faint:  #9a8e7a;  /* faintest labels              */
  --line:       #d8ccb2;  /* hairlines                    */
  --accent:     #bf4326;  /* terracotta — the one accent  */
  --accent-deep:#9b341c;
  --accent-tint:#f1d9cf;
  --good:       #7a8c4f;  /* olive (placed)               */
  --warn:       #c98a2b;  /* amber (no location)          */
  --bad:        #b14a3a;  /* rust-red (error)             */

  --serif-display: "Fraunces", Georgia, "Times New Roman", serif;
  --serif-body:    "Lora", Georgia, serif;

  --shadow-soft: 0 2px 10px rgba(44, 39, 34, 0.10);
  --shadow-lift: 0 8px 30px rgba(44, 39, 34, 0.20);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--serif-body);
  color: var(--ink);
  background-color: var(--paper);
  /* a faint paper grain made from layered radial dots */
  background-image:
    radial-gradient(rgba(120, 100, 70, 0.05) 1px, transparent 1px),
    radial-gradient(rgba(120, 100, 70, 0.04) 1px, transparent 1px);
  background-size: 18px 18px, 32px 32px;
  background-position: 0 0, 9px 9px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.brand { display: flex; align-items: center; gap: 14px; }

/* ---------- Panel toggle (show/hide the roll) ---------- */
.panel-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.panel-toggle:hover { background: var(--paper-3); border-color: var(--ink-faint); }
.panel-toggle:active { transform: translateY(1px); }
.panel-toggle svg { fill: currentColor; display: block; }
/* a quiet "on" state while the panel is open */
.panel-toggle[aria-expanded="true"] {
  background: var(--accent-tint);
  border-color: var(--accent-tint);
  color: var(--accent-deep);
}

.brand-mark {
  font-size: 26px;
  color: var(--accent);
  line-height: 1;
  transform: translateY(-1px);
}

.brand-text h1 {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1;
}

.tagline {
  font-style: italic;
  color: var(--ink-soft);
  margin: 3px 0 0;
  font-size: 14px;
}

.topbar-actions { display: flex; gap: 10px; }

.topbar-meta {
  font-family: var(--serif-display);
  font-size: 15px;
  font-style: italic;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

/* ---------- Set switcher ---------- */
.set-switcher {
  position: relative;
  display: flex;
  align-items: center;
}
/* The dropdown toggle is desktop-hidden; the chips show inline (see media query). */
.set-menu-btn { display: none; }
.set-menu-list { display: flex; align-items: center; gap: 6px; }
.set-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.set-link:hover { background: var(--paper-3); border-color: var(--ink-faint); color: var(--ink); }
.set-link.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--serif-body);
  font-size: 15px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--paper-3); border-color: var(--ink-faint); }

.btn-accent {
  background: var(--accent);
  color: #fff7ef;
  box-shadow: var(--shadow-soft);
}
.btn-accent:hover { background: var(--accent-deep); }
.btn-accent:disabled {
  background: var(--paper-3);
  color: var(--ink-faint);
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Layout ---------- */
.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- Side panel ---------- */
.panel {
  flex: 0 0 372px;
  display: flex;
  flex-direction: column;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  min-height: 0;
  overflow: hidden;
  transition: flex-basis 0.3s ease, opacity 0.25s ease;
}
/* Collapsed: slide away to zero width (zero height on the mobile stacked
   layout) and fade out, letting the map take the full space. */
.panel.collapsed {
  flex-basis: 0;
  min-width: 0;
  min-height: 0;
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
}

.panel-head {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0;
}
.panel-sub {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-style: italic;
}

.progress { margin-top: 14px; }
.progress-bar {
  height: 6px;
  background: var(--paper-3);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  transition: width 0.25s ease;
}
.progress-label {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 16px 16px;
}
.panel-scroll::-webkit-scrollbar { width: 9px; }
.panel-scroll::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 9px;
  border: 2px solid var(--paper-2);
}

.group { margin-top: 16px; }
.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  margin: 0 0 4px;
  padding: 0 6px;
}
.count {
  margin-left: auto;
  font-family: var(--serif-body);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0;
  text-transform: none;
}
.group-note {
  margin: 0 6px 8px;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-faint);
}

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-placed   { background: var(--good); }
.dot-unplaced { background: var(--warn); }
.dot-error    { background: var(--bad); }

.cards { list-style: none; margin: 0; padding: 0; }

/* ---------- Photo cards ---------- */
.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.card:hover { background: var(--paper); box-shadow: var(--shadow-soft); }
.card + .card { margin-top: 2px; }

.card-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper-3);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(44, 39, 34, 0.25);
}
.card-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 18px;
}

.card-body { min-width: 0; flex: 1 1 auto; }
.card-name {
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 2px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.card-coords-dms { font-style: italic; color: var(--ink-faint); }

.status-chip {
  font-size: 11px;
  letter-spacing: 0.03em;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--paper);
  white-space: nowrap;
}
.status-chip.working { color: var(--accent-deep); border-color: var(--accent-tint); background: var(--accent-tint); }
.status-chip.error   { color: var(--bad); border-color: #e3c4bc; background: #f3e0db; }

.card-index {
  position: absolute;
  top: 6px;
  right: 8px;
  font-family: var(--serif-display);
  font-size: 12px;
  color: var(--ink-faint);
}

@keyframes pulse-bg {
  0%   { background: var(--accent-tint); }
  100% { background: transparent; }
}
.card.flash { animation: pulse-bg 1.1s ease; }

/* ---------- Panel footer ---------- */
.panel-foot {
  flex: 0 0 auto;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

/* ---------- Map ---------- */
.map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
/* z-index:0 makes #map its own stacking context so Leaflet's internal panes
   and controls (which go up to z-index 1000) can't paint over our overlays. */
#map { position: absolute; inset: 0; z-index: 0; background: var(--paper-3); }

/* tone the Leaflet UI to match the paper theme */
.leaflet-bar a,
.leaflet-touch .leaflet-bar a {
  background: var(--paper);
  color: var(--ink);
  border-bottom-color: var(--line);
  font-family: var(--serif-body);
}
.leaflet-bar a:hover { background: var(--paper-2); }
.leaflet-control-attribution {
  background: rgba(245, 239, 226, 0.82) !important;
  font-family: var(--serif-body);
  color: var(--ink-soft) !important;
}
.leaflet-popup-content-wrapper {
  background: var(--paper);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
}
.leaflet-popup-content { font-family: var(--serif-body); color: var(--ink); margin: 12px 14px; }
.leaflet-popup-tip { background: var(--paper); }
.popup-name { font-family: var(--serif-display); font-weight: 600; font-size: 15px; }
.popup-coords { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.popup-hint { font-size: 11.5px; color: var(--accent-deep); margin-top: 6px; font-style: italic; }

/* ---------- Map pins (circular photo thumbnails) ---------- */
.photo-pin { background: none; border: none; }
.pin {
  position: relative;
  width: 56px;
  height: 56px;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.pin:hover { transform: scale(1.08); z-index: 1000; }
.pin-frame {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fffaf2;
  box-shadow: 0 4px 10px rgba(44, 39, 34, 0.35);
  background: var(--paper-3);
}
.pin-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* little stem so it reads as a pin pointing at the spot */
.pin-stem {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 14px;
  height: 14px;
  background: #fffaf2;
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 3px 3px 6px rgba(44, 39, 34, 0.22);
  border-radius: 0 0 3px 0;
}

/* ---------- Empty / drop state ---------- */
.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
  background: radial-gradient(circle at center, rgba(245,239,226,0.6), rgba(245,239,226,0.92));
  pointer-events: none;
}
.empty.hidden { display: none; }
.empty-card {
  pointer-events: auto;
  max-width: 420px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 38px 34px;
  box-shadow: var(--shadow-lift);
}
.empty-mark { font-size: 30px; color: var(--accent); display: block; margin-bottom: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-mark.spin { display: inline-block; animation: spin 1.5s linear infinite; }
.empty-card h2 { font-family: var(--serif-display); font-weight: 600; font-size: 26px; margin: 0 0 10px; }
.empty-card p { color: var(--ink-soft); line-height: 1.55; margin: 0 0 22px; }

/* ---------- Drag veil ---------- */
.dragveil {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(191, 67, 38, 0.14);
  backdrop-filter: blur(2px);
}
.dragveil.show { display: flex; }
.dragveil-inner {
  font-family: var(--serif-display);
  font-size: 30px;
  color: var(--accent-deep);
  background: var(--paper);
  border: 3px dashed var(--accent);
  border-radius: 20px;
  padding: 40px 60px;
  box-shadow: var(--shadow-lift);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(28, 24, 20, 0.86);
  backdrop-filter: blur(3px);
}
.lightbox[hidden] { display: none; }
.lightbox-figure {
  margin: 0;
  max-width: min(94vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox-imgwrap { position: relative; display: inline-block; line-height: 0; }
.lightbox-figure img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  background: #000;
}
.lightbox-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-family: var(--serif-body);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff7ef;
  background: rgba(191, 67, 38, 0.92);
  padding: 4px 11px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.lightbox-badge[hidden] { display: none; }
.lightbox-figure figcaption {
  margin-top: 16px;
  text-align: center;
  color: #f5efe2;
}
.lightbox-name { font-family: var(--serif-display); font-size: 20px; display: block; }
.lightbox-coords { font-size: 14px; color: #cdbfa7; font-style: italic; display: block; }
.lightbox-help {
  margin-top: 14px;
  font-family: var(--serif-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: #f5efe2;
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}
.lightbox-help:hover { background: #fffaf2; }
.lightbox-help:active { transform: translateY(1px); }
.lightbox-help[hidden] { display: none; }
.lightbox-close {
  position: absolute;
  top: 22px;
  right: 28px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(245, 239, 226, 0.4);
  background: rgba(245, 239, 226, 0.1);
  color: #f5efe2;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lightbox-close:hover { background: rgba(245, 239, 226, 0.25); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  body { overflow: auto; }
  .layout { flex-direction: column; }
  .panel { flex: 0 0 auto; max-height: 42vh; border-right: none; border-bottom: 1px solid var(--line); }
  .map-wrap { min-height: 58vh; }
  .brand-text h1 { font-size: 24px; }
  .tagline { display: none; }

  /* Free up header space: the panel summary already shows these counts. */
  .topbar { padding: 12px 16px; }
  .topbar-meta { display: none; }

  /* Collapse the set chips behind a dropdown so the header never overflows. */
  .set-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .set-menu-caret { transition: transform 0.18s ease; }
  .set-switcher.open .set-menu-btn { background: var(--paper-3); border-color: var(--ink-faint); }
  .set-switcher.open .set-menu-caret { transform: rotate(180deg); }

  .set-menu-list {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px;
    min-width: 132px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    z-index: 40;
  }
  .set-switcher.open .set-menu-list { display: flex; }
  .set-menu-list .set-link { justify-content: flex-start; padding: 8px 12px; }
}
