/* ===== Design tokens (Camino / Schelpenpad) ===== */
:root {
  --bg: #f8f5ee;
  --card: #fefcf7;
  --border: #d9d4c9;
  --ink: #1f1a10;
  --ink-muted: #5a5549;
  --accent: #bc5a29;
  --accent-hover: #a24100;
  --accent2: #428252;
  --accent2-hover: #366b45;
  --header-bg: #1f1a10;
  --header-text: #f8f5ee;
  --chip-bg: #eeebe4;
  --danger: #b3311d;

  --font-display: 'Zilla Slab', serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-body: 'Work Sans', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button { font-family: inherit; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3.5% 4% 4%;
}
.container-narrow { max-width: 1000px; }

/* ===== Header ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 4%;
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--header-text);
}
.brand:hover { color: var(--header-text); opacity: 0.9; }
.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-mark svg { width: 60%; height: 60%; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.back-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--header-text);
  opacity: 0.85;
}
.back-link:hover { color: var(--header-text); opacity: 1; }

.unit-toggle {
  display: flex;
  border: 1px solid rgba(248,245,238,0.35);
  border-radius: 6px;
  overflow: hidden;
}
.unit-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.35rem 0.6rem;
  background: transparent;
  color: var(--header-text);
  opacity: 0.7;
  border: none;
  cursor: pointer;
}
.unit-btn.active { opacity: 1; background: rgba(248,245,238,0.15); }
.unit-btn:hover { opacity: 1; }

.edit-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.edit-pill:hover { background: var(--accent); color: white; }
.edit-pill-on {
  border-color: var(--accent2);
  color: var(--accent2);
}
.edit-pill-on:hover { background: var(--accent2); color: white; }
.edit-pill-preview {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(188, 90, 41, 0.12);
}
.edit-pill-preview:hover { background: var(--accent); color: white; }
.preview-banner {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--header-text);
  opacity: 0.85;
  white-space: nowrap;
}

/* ===== Login overlay ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31,26,16,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-overlay[hidden] { display: none; }
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.6rem;
  width: 90%;
  max-width: 320px;
}
.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.9rem;
}
.login-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-size: 0.92rem;
  margin-bottom: 0.6rem;
}
.login-error {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-bottom: 0.6rem;
}
.login-error[hidden] { display: none; }
.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-accent-outline {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent);
}
.btn-accent-outline:hover { background: var(--accent); color: white; }
.btn-moss-outline {
  border-color: var(--accent2);
  background: transparent;
  color: var(--accent2);
}
.btn-moss-outline:hover { background: var(--accent2); color: white; }
.btn-neutral-outline {
  border-color: #ccc4b4;
  background: transparent;
  color: var(--ink-muted);
}
.btn-neutral-outline:hover { border-color: #a89f8a; }
.btn-danger-outline {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}
.btn-danger-outline:hover { background: var(--danger); color: white; }

/* ===== Intro / titles ===== */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow-number-edit { display: flex; align-items: center; gap: 0.4rem; }
.eyebrow-number-input {
  width: 3.2rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--chip-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}
.eyebrow-number-input:hover, .eyebrow-number-input:focus { border-color: var(--accent); outline: none; }
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.4rem;
  margin: 0.3rem 0 0;
  line-height: 1.1;
}
.subtitle {
  color: var(--ink-muted);
  margin-top: 0.4rem;
  max-width: 60ch;
}
.intro { margin-bottom: 2rem; }

/* ===== Stats ===== */
.stats-grid {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-bottom: 2.2rem;
}
.stat-card {
  flex: 1;
  min-width: 150px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
.stat-number {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--accent);
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

/* ===== Stage grid ===== */
.add-stage-row { margin-bottom: 1.2rem; }

.stage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
}
.stage-card {
  width: calc(33.333% - 1rem);
  min-width: 280px;
  flex: 1 1 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: var(--ink);
  display: block;
}
.stage-card:hover {
  color: var(--ink);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px -8px rgba(46,38,26,0.25);
}
.stage-thumb {
  height: 150px;
  background: var(--chip-bg);
}
.stage-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: center;
  padding: 0 1rem;
}
.stage-body { padding: 1rem 1.1rem 1.2rem; }
.stage-title-row { display: flex; align-items: center; gap: 0.6rem; }
.stage-badge {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.stage-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}
.trip-subtitle {
  font-size: 0.88rem;
  color: var(--ink-muted);
  margin-top: 0.3rem;
}
.trip-meta-edit-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.trip-year-input {
  width: 6rem;
}
.trip-name-input {
  font-size: 1.6rem;
  max-width: 420px;
  width: 100%;
}
.stage-chips {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}
.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  padding: 0.2rem 0.5rem;
  background: var(--chip-bg);
  border-radius: 3px;
}

.empty-state {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* ===== Vorige/volgende etappe ===== */
.stage-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.stage-pager-bottom { margin-top: 1.8rem; margin-bottom: 0; }
.stage-pager-link {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-pager-link:hover { text-decoration: underline; }
.stage-pager-next { text-align: right; margin-left: auto; }

/* ===== Stage detail header ===== */
.stage-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.stage-title-edit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}
.h1-input {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  background: var(--card);
  color: var(--ink);
  max-width: 260px;
}
.h1-arrow { font-family: var(--font-display); font-weight: 700; font-size: 1.8rem; color: var(--ink-muted); }
.h1-arrow-dim { opacity: 0.35; }

.stage-meta-chips {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  align-items: center;
}
.stage-meta-chips .chip { padding: 0.3rem 0.65rem; border-radius: 4px; font-size: 0.78rem; }
.chip-input {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.28rem 0.5rem;
  background: var(--card);
  color: var(--ink);
}
.chip-input-wrap { display: inline-flex; align-items: center; gap: 0.3rem; }
.chip-select {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.28rem 0.4rem;
  background: var(--card);
  color: var(--ink);
}
.chip-number-input {
  width: 4.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  background: var(--card);
  color: var(--ink);
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem;
  margin-bottom: 1.4rem;
}
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}
.card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== Route (echte kaart via Leaflet/OpenStreetMap) ===== */
.route-map {
  width: 100%;
  height: 320px;
  background: #f2eee4;
  border-radius: 8px;
  z-index: 0; /* voorkomt dat Leaflet's eigen z-index boven de sticky header uitsteekt */
}
.route-map .leaflet-container {
  border-radius: 8px;
  font-family: var(--font-body);
}
.trip-route-num-icon { background: transparent; border: none; }
.trip-route-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.route-map .leaflet-interactive { cursor: pointer; }
.hint-text {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  margin-top: 0.6rem;
}
.gpx-result {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent2);
  margin-top: 0.6rem;
}

/* ===== Photos ===== */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.photo-tile {
  position: relative;
  width: calc(25% - 0.5rem);
  min-width: 140px;
  flex: 1 1 140px;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--chip-bg);
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-tile video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; background: #000; }
.video-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: white;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  pointer-events: none;
}
.photo-delete {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: none;
  background: rgba(31,26,16,0.65);
  color: white;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.photo-tile:hover .photo-delete { opacity: 1; }
.photo-cover-btn {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: none;
  background: rgba(31,26,16,0.65);
  color: white;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.photo-tile:hover .photo-cover-btn { opacity: 1; }
.photo-cover-btn-active { opacity: 1; color: #ffd479; }
.photo-tile-cover { outline: 2px solid var(--accent2); outline-offset: 2px; }
.photo-cover-badge {
  position: absolute;
  left: 0.3rem;
  bottom: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--accent2);
  color: white;
}
.photo-tile.uploading { opacity: 0.5; }

.trip-cover-tile {
  width: calc(16.66% - 0.5rem);
  min-width: 100px;
  flex: 1 1 100px;
}
.trip-cover-caption {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  max-width: calc(100% - 0.6rem);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: rgba(31,26,16,0.65);
  color: white;
}
.photo-empty-state { flex-basis: 100%; }

/* ===== Lightbox (foto's vergroot bekijken, met vorige/volgende) ===== */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 10, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.lightbox-overlay[hidden] { display: none; }
.lightbox-image {
  max-width: 88vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-video {
  max-width: 88vw;
  max-height: 86vh;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  background: #000;
}
.lightbox-video[hidden] { display: none; }
.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox-close {
  top: 1rem;
  right: 1.2rem;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.4rem;
  line-height: 1;
}
.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 3rem;
  height: 3rem;
  font-size: 1.8rem;
  line-height: 1;
}
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-nav[hidden] { display: none; }
.lightbox-counter {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: white;
  opacity: 0.85;
}

@media (max-width: 640px) {
  .lightbox-nav { width: 2.3rem; height: 2.3rem; font-size: 1.3rem; }
  .lightbox-prev { left: 0.4rem; }
  .lightbox-next { right: 0.4rem; }
  .lightbox-close { top: 0.5rem; right: 0.6rem; }
}

/* ===== Story ===== */
.story-textarea {
  width: 100%;
  min-height: 140px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
  resize: vertical;
  font-family: var(--font-body);
  background: var(--card);
}
.save-indicator {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent2);
  margin-top: 0.4rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.save-indicator.visible { opacity: 1; }
.story-text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
}

/* ===== Practical ===== */
.practical-grid {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
}
.practical-field { flex: 1; min-width: 160px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
}
.field-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--card);
  font-family: var(--font-body);
}
.field-value { font-size: 0.88rem; color: var(--ink); min-height: 1.2em; }

/* ===== Delen (uitnodigingslinks) ===== */
.share-create-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.share-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.share-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--chip-bg);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
}
.share-row-expired { opacity: 0.55; }
.share-url-input {
  flex: 1 1 220px;
  min-width: 160px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  background: var(--card);
  color: var(--ink);
}
.share-expiry {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  white-space: nowrap;
}
.share-expiry-expired { color: var(--danger); }
.share-empty-state { margin: 0; }

/* ===== Danger zone ===== */
.danger-zone { display: flex; justify-content: flex-end; margin-top: 1rem; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.visible { opacity: 1; }
.toast.toast-error { background: var(--danger); }

@media (max-width: 640px) {
  .page-title { font-size: 1.7rem; }
  .stage-card { width: 100%; }
}
