/* ── Design tokens ─────────────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;

  /* Neutrals */
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-alt: #f2ede3;
  --border: rgba(20, 18, 12, 0.10);
  --text: #1f1d17;
  --text-muted: #6a655a;
  --text-inverse: #f7f3ea;

  /* Ocean theme (Galápagos default): warm sand + pacific + ochre */
  --accent: #1a6b7f;
  --accent-hover: #145566;
  --warm: #c8891f;
  --shadow: 0 12px 40px -12px rgba(20, 18, 12, 0.25);

  /* Typography */
  --font-serif: "Fraunces", "Playfair Display", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;  --sp-8: 64px; --sp-9: 96px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #201e17;
    --surface-alt: #2a2820;
    --border: rgba(240, 236, 222, 0.10);
    --text: #f0ecde;
    --text-muted: #a9a397;
    --text-inverse: #16150f;
    --accent: #4fb3c8;
    --accent-hover: #6cc0d2;
    --warm: #e3a749;
    --shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.5);
  }
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}
p { margin: 0; }
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

.loading, .empty { color: var(--text-muted); padding: var(--sp-6); text-align: center; }

/* ── Landing ───────────────────────────────────────────────────────────────── */

.landing { max-width: 960px; margin: 0 auto; padding: var(--sp-8) var(--sp-5); }

.landing-header { margin-bottom: var(--sp-8); text-align: center; }
.wordmark {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  font-family: var(--font-serif); font-size: 32px; font-weight: 600;
  letter-spacing: -0.02em;
}
.wordmark-mark { color: var(--warm); font-size: 24px; }
.landing-tagline {
  margin-top: var(--sp-3); color: var(--text-muted);
  font-style: italic; font-family: var(--font-serif); font-size: 18px;
}

.trip-cards { display: grid; gap: var(--sp-5); }

.trip-card {
  position: relative;
  display: block;
  min-height: 240px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
  border-radius: var(--r-lg);
  overflow: hidden;
  color: var(--text-inverse);
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
}
.trip-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 50px -12px rgba(20, 18, 12, 0.35);
}
.trip-card-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}
.trip-card-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--sp-6);
}
.trip-card-title {
  color: #fff;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.trip-card-subtitle {
  color: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  margin-top: var(--sp-2);
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

/* ── Login card ────────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  position: relative;
  padding: var(--sp-5);
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: blur(24px) brightness(0.6);
  transform: scale(1.1);
  z-index: 0;
}
.login-bg-fallback {
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
}
.login-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-7);
  width: min(420px, 100%);
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease-out;
}
.login-card h1 { font-size: 28px; margin-bottom: var(--sp-2); }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: var(--sp-5); }
.login-input {
  width: 100%; padding: var(--sp-4);
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 16px; font-family: inherit;
  transition: border-color 0.15s;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn {
  width: 100%; padding: var(--sp-4);
  margin-top: var(--sp-3);
  background: var(--accent); color: var(--text-inverse);
  border: none; border-radius: var(--r-md);
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.login-btn:hover:not(:disabled) { background: var(--accent-hover); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-error {
  color: #e11d48; font-size: 14px; margin-top: var(--sp-3);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Trip page — hero ──────────────────────────────────────────────────────── */

.trip-hero {
  position: relative;
  min-height: 60vh;
  padding: var(--sp-9) var(--sp-5) var(--sp-8);
  color: #fff;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.trip-hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--warm) 100%);
  background-size: cover; background-position: center;
  z-index: 0;
}
.trip-hero-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.7) 100%);
  z-index: 1;
}
.trip-hero-inner {
  position: relative; z-index: 2;
  max-width: 1000px; margin: 0 auto; width: 100%;
}
.trip-hero-eyebrow {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 12px; font-weight: 600;
  opacity: 0.85;
  margin-bottom: var(--sp-3);
}
.trip-hero-eyebrow a { color: rgba(255,255,255,0.9); }
.trip-hero-title {
  font-size: clamp(36px, 6vw, 68px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0,0,0,0.4);
  max-width: 900px;
}
.trip-hero-subtitle {
  font-family: var(--font-serif); font-style: italic;
  font-size: clamp(16px, 2vw, 22px);
  color: rgba(255,255,255,0.9);
  margin-top: var(--sp-4);
}

/* ── Trip page — body ──────────────────────────────────────────────────────── */

.trip-body {
  max-width: 1200px; margin: 0 auto;
  padding: var(--sp-8) var(--sp-5);
}
.trip-section { margin-bottom: var(--sp-8); }
.section-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}
.section-title {
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: var(--sp-4);
}
.trip-overview {
  font-family: var(--font-serif);
  font-size: 20px; line-height: 1.55;
  color: var(--text);
  max-width: 720px;
}
.trip-overview::first-letter {
  font-size: 60px; font-weight: 800;
  float: left; line-height: 0.9;
  padding-right: 12px; padding-top: 4px;
  color: var(--warm);
}

.trip-map {
  height: 500px;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #1a2a34;
  position: relative;
  z-index: 0;
}
@media (max-width: 640px) {
  .trip-map { height: 380px; }
}
.trip-marker { background: transparent; border: none; }
.trip-marker-inner {
  width: 30px; height: 30px;
  background: #c8891f; color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  border: 2px solid #fff;
}
.leaflet-popup-content {
  font-family: var(--font-sans); font-size: 13px; line-height: 1.4;
}
.leaflet-popup-content strong {
  font-family: var(--font-serif); font-size: 14px;
}

.itinerary {
  border-top: 1px solid var(--border);
}
.itinerary details {
  border-bottom: 1px solid var(--border);
}
.itinerary summary {
  padding: var(--sp-4) 0;
  cursor: pointer;
  font-family: var(--font-serif); font-size: 18px; font-weight: 600;
  display: flex; align-items: baseline; gap: var(--sp-4);
  list-style: none;
}
.itinerary summary::-webkit-details-marker { display: none; }
.itinerary summary::before {
  content: "+";
  color: var(--warm); font-size: 24px;
  transition: transform 0.2s;
}
.itinerary details[open] summary::before {
  content: "−";
}
.itinerary .day-num {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  min-width: 50px;
}

/* ── Photo grid (CSS columns for masonry) ──────────────────────────────────── */

.gallery {
  columns: 4 240px;
  column-gap: 8px;
}
@media (max-width: 640px) {
  .gallery { columns: 2 140px; column-gap: 6px; }
}
.gallery img {
  width: 100%;
  height: auto;
  margin-bottom: 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  break-inside: avoid;
  background: var(--surface-alt);
  transition: transform 0.2s;
}
.gallery img:hover { transform: scale(1.02); }

.gallery-empty {
  column-span: all;
  padding: var(--sp-8) 0;
  text-align: center; color: var(--text-muted);
  font-family: var(--font-serif); font-style: italic; font-size: 18px;
}

/* ── Upload FAB ────────────────────────────────────────────────────────────── */

.fab {
  position: fixed; bottom: var(--sp-6); right: var(--sp-6);
  z-index: 50;
  width: 64px; height: 64px;
  background: var(--accent); color: var(--text-inverse);
  border: none; border-radius: 50%;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.15s, background 0.15s;
}
.fab:hover { transform: scale(1.05); background: var(--accent-hover); }
.fab input { display: none; }

.dropzone-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--font-serif); font-size: 28px; font-style: italic;
  text-align: center;
  pointer-events: none;
}
.dropzone-overlay.active { display: flex; }

.upload-toast {
  position: fixed; bottom: 100px; right: var(--sp-6);
  z-index: 60;
  background: var(--surface); color: var(--text);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: 14px;
  min-width: 200px;
  animation: fadeUp 0.2s ease-out;
}
.upload-toast .bar {
  height: 4px; background: var(--border); border-radius: 2px;
  margin-top: var(--sp-3); overflow: hidden;
}
.upload-toast .bar-fill {
  height: 100%; background: var(--accent);
  transition: width 0.2s;
}

/* ── Lightbox ──────────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.95);
  display: grid; place-items: center;
  animation: fadeIn 0.15s ease-out;
}
.lightbox img {
  max-width: 95vw; max-height: 92vh;
  object-fit: contain;
}
.lightbox-close, .lightbox-nav {
  position: absolute; background: rgba(255,255,255,0.1);
  color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s;
  backdrop-filter: blur(8px);
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,0.2); }
.lightbox-close {
  top: var(--sp-4); right: var(--sp-4);
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 22px;
}
.lightbox-nav {
  top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  font-size: 24px;
}
.lightbox-nav.prev { left: var(--sp-4); }
.lightbox-nav.next { right: var(--sp-4); }
.lightbox-meta {
  position: absolute; bottom: var(--sp-5); left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.85); font-size: 13px;
  display: flex; gap: var(--sp-4); align-items: center;
  background: rgba(0,0,0,0.5); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); backdrop-filter: blur(8px);
}
.lightbox-download {
  color: #fff; text-decoration: none;
  padding: 4px 12px; border-radius: 4px;
  background: rgba(255,255,255,0.15);
}
.lightbox-download:hover { background: rgba(255,255,255,0.25); color: #fff; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Root loading ──────────────────────────────────────────────────────────── */

.root-loading { min-height: 100vh; display: grid; place-items: center; }
