/* TrekMap — clean outdoor UI, mobile first */

:root {
  --accent: #374151;
  --accent-dark: #111827;
  --accent-light: #f3f4f6;
  --earth: #6c584c;
  --ink: #1a2029;
  --muted: #64748b;
  --bg: #f6f8f7;
  --card: #ffffff;
  --border: #dde5e0;
  --danger: #b91c1c;
  --warn-bg: #fef3c7;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- header / footer ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--accent-dark);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: .45rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand-icon { color: #9ca3af; }
.site-nav { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.site-nav a, .site-nav .link-button { color: #e5e7eb; text-decoration: none; font-size: .95rem; }
.site-nav a:hover { color: #fff; text-decoration: underline; }
.nav-cta { background: #e5e7eb; color: var(--accent-dark) !important; padding: .3rem .7rem; border-radius: 6px; font-weight: 600; }
.lang-switch {
  width: auto; padding: .2rem .4rem; font-size: .85rem;
  background: var(--accent); color: #e5e7eb; border: 1px solid var(--accent); border-radius: 6px;
}
.lang-switch[hidden] { display: none; }
.lang-switch option { background: #fff; color: var(--ink); }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: inherit; }
.link-button.danger { color: var(--danger); font-size: .85rem; }

.site-main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem; }
.site-footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: 0.9rem 1rem; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--border);
}

.flash {
  max-width: 1100px; margin: .8rem auto 0; padding: .7rem 1rem;
  background: var(--accent-light); border: 1px solid #9ca3af; border-radius: var(--radius);
}

/* ---------- cards / hero ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem; margin: 1rem 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.hero { text-align: center; padding: 2.4rem 1rem 1.2rem; }
.hero h1 { font-size: clamp(1.6rem, 4.5vw, 2.5rem); margin: 0 0 .6rem; color: var(--accent-dark); }
.hero-sub { color: var(--muted); font-size: 1.05rem; margin: 0; }

.howto h2 { text-align: center; font-size: 1.15rem; }
.steps { display: flex; gap: 1rem; justify-content: center; list-style: none; padding: 0; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: .55rem; font-weight: 600; }
.step-num {
  display: inline-flex; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--accent); color: #fff; align-items: center; justify-content: center; font-size: .95rem;
}

/* ---------- forms ---------- */
.field { display: block; margin: 0.9rem 0; }
.field > span { display: block; font-weight: 600; margin-bottom: .3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--border);
  border-radius: 7px; font: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #6b7280; outline-offset: -1px; border-color: #6b7280; }
.visibility label { display: block; font-weight: 400; margin: .3rem 0; }
.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox input { width: auto; }
.checkbox span { font-weight: 400; }
.muted { color: var(--muted); font-weight: 400; }
.form-error { color: var(--danger); font-weight: 600; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.button-row { display: flex; gap: .6rem; align-items: center; }

.btn {
  display: inline-block; padding: .5rem 1rem; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; font: inherit; font-size: .95rem;
}
.btn:hover { background: #f0f4f1; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-lg { font-size: 1.05rem; padding: .7rem 1.4rem; width: 100%; }
.btn-small { padding: .2rem .55rem; font-size: .82rem; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.badge { background: #e2e8f0; border-radius: 4px; padding: .1rem .45rem; font-size: .8rem; }
.badge-warn { background: var(--warn-bg); color: #92400e; border-radius: 4px; padding: .1rem .45rem; font-size: .8rem; font-weight: 400; }

.notice { border-radius: 7px; padding: .7rem .9rem; margin: .8rem 0; font-size: .95rem; }
.notice-warn { background: var(--warn-bg); border: 1px solid #f59e0b33; }
.notice-danger { background: #fee2e2; border: 1px solid #b91c1c33; }

/* ---------- upload ---------- */
.dropzone {
  border: 2px dashed #9ca3af; border-radius: var(--radius);
  padding: 2rem 1rem; text-align: center; cursor: pointer; transition: background .15s;
}
.dropzone:hover, .dropzone.dragover { background: var(--accent-light); }
.dropzone svg { color: var(--accent); }
.dropzone-file { font-weight: 600; color: var(--accent-dark); }
.progress { height: 8px; background: #e2e8f0; border-radius: 4px; margin: .8rem 0; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------- tour page ---------- */
.tour-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-top: .6rem; }
.tour-header h1 { margin: 0; font-size: clamp(1.3rem, 3.5vw, 2rem); }
.tour-meta { color: var(--muted); margin: .35rem 0 0; font-size: .92rem; }
.tour-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: .6rem; margin: 1rem 0;
}
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .5rem; text-align: center; }
.stat-value { display: block; font-weight: 700; font-size: 1.15rem; color: var(--accent-dark); }
.stat-label { display: block; font-size: .78rem; color: var(--muted); margin-top: .15rem; }

.map-wrap { margin: 1rem 0; }
.tour-map {
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 1 / 1;
  max-height: 1000px;
  margin-inline: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 0;
}
.elevation-profile {
  position: relative; margin-top: .6rem; height: 160px; max-width: 1000px; margin-inline: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.elevation-profile svg { width: 100%; height: 100%; display: block; }
.elevation-marker {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); pointer-events: none;
}

/* Desktop: Kopf + Statistik + Karte + Höhenprofil füllen genau einen Viewport.
   Die Karte nimmt den Restplatz — unabhängig davon, ob der Titel umbricht. */
@media (min-width: 700px) {
  .tour-fold {
    display: flex;
    flex-direction: column;
    /* 100dvh minus .site-header (49px), .site-main padding-top (1rem)
       und 12px Luft unter dem Höhenprofil. */
    height: calc(100dvh - 49px - 1rem - 12px);
    min-height: 460px;
  }
  .tour-fold .map-wrap {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }
  .tour-fold .tour-map {
    flex: 1 1 auto;
    min-height: 240px;
    aspect-ratio: auto;
    max-width: none;
    max-height: none;
  }
  .tour-fold .elevation-profile { flex: 0 0 auto; max-width: none; }
  /* Flash-Meldung über <main> schiebt den Fold nach unten.
     Gemessen: .flash 46.375px hoch + margin-top .8rem (12.8px) = 59.175px, aufgerundet 60px. */
  body:has(.flash) .tour-fold { height: calc(100dvh - 49px - 1rem - 12px - 60px); }
}

.tour-description p { line-height: 1.65; }

/* ---------- waypoints / photos / comments ---------- */
.editor-tools .inline-upload, .editor-tools .waypoint-form {
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem;
}
.editor-tools input[type="text"], .editor-tools select { width: auto; flex: 1 1 140px; }
.waypoint-list { list-style: none; padding: 0; }
.waypoint-list li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.waypoint-list form { margin-left: auto; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; }
.photo-item { margin: 0; }
.photo-item img { width: 100%; height: 140px; object-fit: cover; border-radius: 7px; border: 1px solid var(--border); }
.photo-item figcaption { font-size: .85rem; color: var(--muted); margin-top: .25rem; }

.comment-list { list-style: none; padding: 0; }
.comment { border-top: 1px solid var(--border); padding: .7rem 0; }
.comment-head { display: flex; gap: .7rem; align-items: baseline; flex-wrap: wrap; }
.comment p { margin: .35rem 0 0; line-height: 1.55; }
.comment-form { margin-top: 1rem; display: grid; gap: .6rem; }

/* ---------- misc ---------- */
.lang-filter { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0 1rem; }
.lang-filter a {
  padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--border);
  text-decoration: none; color: var(--ink); font-size: .85rem; background: #fff;
}
.lang-filter a:hover { border-color: #9ca3af; background: var(--accent-light); }
.lang-filter a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--border); }
.profile { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1.2rem; }
.profile dt { font-weight: 600; }
.profile dd { margin: 0; }
.admin-nav { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0 1.2rem; }
.auth-card { max-width: 440px; margin: 2rem auto; }
.created-card { max-width: 620px; margin: 2rem auto; }
.link-block { margin: 1.3rem 0; }
.link-block label { font-weight: 600; display: block; margin-bottom: .35rem; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; font-size: .85rem; color: var(--muted); }
.error-card { max-width: 520px; margin: 3rem auto; text-align: center; }
.leaflet-popup-content img { max-width: 220px; border-radius: 6px; }
/* OpenTopoMap wirkt sehr grün — Sättigung leicht dämpfen */
.tour-map { background: #fff; }
.leaflet-layer.tiles-topo { opacity: 0.55; }
.leaflet-layer.tiles-topo .leaflet-tile { filter: saturate(0.3) brightness(1.12) contrast(0.9); }

@media (min-width: 720px) {
  .btn-lg { width: auto; }
  .upload-card { max-width: 640px; margin-left: auto; margin-right: auto; }
}
