/* ============================================================
   KLP Wendland · Styles
   Mobile-first, BFSG / WCAG 2.1 AA Kontraste
   Aesthetik: warm, papierartig, "Land-Partie"
   ============================================================ */

/* === FARB-VARIABLEN === */
/* Default = Hell. Dark Mode greift entweder per System-Pref (kein data-theme)
   oder per data-theme="dark" (Force). Hell per data-theme="light" oder default. */
:root {
  /* Farben Hell (Pergament) */
  --bg:           #f4ecda;
  --bg-elev:      #fbf6e8;
  --ink:          #1b1611;
  --ink-soft:     #4d3e2c;
  --muted:        #6b5b46;
  --line:         #d4c8a8;
  --line-soft:    #e6ddc4;
  --accent:       #b0532a;
  --accent-dark:  #8b3f1d;
  --forest:       #3a4f2e;
  --forest-dark:  #283921;
  --warn:         #a8500f;
  --focus:        #1b1611;
  --chip-bg:      #ebe0c2;
  --chip-on-bg:   var(--forest);
  --chip-on-fg:   #fbf6e8;
  --shadow-sm:    0 1px 2px rgba(40, 25, 0, .08);
  --shadow-md:    0 6px 24px -8px rgba(40, 25, 0, .18);

  /* Type */
  --display: "Fraunces", Georgia, serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Rhythmus */
  --radius:        12px;
  --radius-lg:     18px;
  --pad:           clamp(12px, 4vw, 24px);
  --maxw:          760px;
  --bottomnav-h:   64px;
}

/* Dark wenn System auf dark UND kein User-Override gesetzt ist */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #18130c;
    --bg-elev:   #221c12;
    --ink:       #f3ead4;
    --ink-soft:  #d8c8a3;
    --muted:     #a89977;
    --line:      #3a3023;
    --line-soft: #2a221b;
    --chip-bg:   #2c2418;
    --chip-on-bg: #d6b889;
    --chip-on-fg: #18130c;
    --accent:    #e08f5a;
    --accent-dark:#c5713c;
    --forest:    #8fb27a;
    --focus:     #f3ead4;
  }
}

/* User-Override: explizit Dark */
:root[data-theme="dark"] {
  --bg:        #18130c;
  --bg-elev:   #221c12;
  --ink:       #f3ead4;
  --ink-soft:  #d8c8a3;
  --muted:     #a89977;
  --line:      #3a3023;
  --line-soft: #2a221b;
  --chip-bg:   #2c2418;
  --chip-on-bg: #d6b889;
  --chip-on-fg: #18130c;
  --accent:    #e08f5a;
  --accent-dark:#c5713c;
  --forest:    #8fb27a;
  --focus:     #f3ead4;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { color-scheme: light dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"]  { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(176,83,42,.06), transparent 40%),
    radial-gradient(circle at 90% 30%, rgba(58,79,46,.06), transparent 45%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent-dark);
  text-underline-offset: 3px;
}
a:hover, a:focus-visible { color: var(--ink); }

/* === SKIP-LINK & FOCUS === */
.skip-link {
  position: absolute;
  top: -40px; left: 8px;
  background: var(--ink);
  color: var(--bg-elev);
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 100;
  transition: top .15s;
}
.skip-link:focus { top: 8px; outline: 2px solid var(--accent); }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* === TOPBAR === */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--pad);
  max-width: var(--maxw);
  margin: 0 auto;
}

.brand {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 144;
  letter-spacing: -.02em;
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand__mark {
  color: var(--accent);
  font-size: 1.4em;
  line-height: 0;
  transform: translateY(2px);
}

.iconbtn {
  font: inherit;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}
.iconbtn--icon {
  padding: 0;
  width: 40px;
  justify-content: center;
  font-size: 1.2rem;
}
.iconbtn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: white;
}

/* === DATEBAR (sichtbar nur in events-view, ausgeblendet sonst per .view) === */
.datebar {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-top: 1px solid var(--line-soft);
  scroll-snap-type: x proximity;
  mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}
.datebar.is-hidden { display: none; }

.datebar__list {
  display: flex;
  gap: 6px;
  margin: 0; padding: 8px var(--pad);
  list-style: none;
  max-width: var(--maxw);
  margin-inline: auto;
}
.datebar__btn {
  font: inherit;
  font-family: var(--body);
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  font-size: .85rem;
  scroll-snap-align: start;
}
.datebar__btn b {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.05rem;
}
.datebar__btn[aria-pressed="true"] {
  background: var(--forest);
  color: var(--bg-elev);
  border-color: var(--forest-dark);
}

/* === VIEW Container === */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad);
}
.view[hidden] { display: none; }
.view__title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  margin: 20px 0 6px;
  letter-spacing: -.01em;
}
.view__lede {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: .95rem;
}

/* === FILTERS === */
.filters {
  margin: 16px 0 0;
}

.filters__search input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--ink);
  min-height: 48px;
}

.filters__details {
  margin-top: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.filters__details > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  min-height: 48px;
  user-select: none;
}
.filters__details > summary::-webkit-details-marker { display: none; }
.filters__details > summary::after {
  content: "▾";
  color: var(--muted);
  transition: transform .2s;
}
.filters__details[open] > summary::after { transform: rotate(180deg); }

.filters__count {
  font-weight: 400;
  font-size: .85rem;
  color: var(--bg-elev);
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: auto;
  margin-right: 8px;
}
.filters__count:empty { display: none; }

.filters__body {
  padding: 6px 16px 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filtergroup {
  border: 0;
  margin: 0;
  padding: 0;
}
.filtergroup legend {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--ink);
}

.chiplist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chiplist--tight { gap: 4px; }

.chip {
  font: inherit;
  font-size: .9rem;
  background: var(--chip-bg);
  color: var(--ink);
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}
.chip:hover { border-color: var(--line); }
.chip[aria-pressed="true"] {
  background: var(--chip-on-bg);
  color: var(--chip-on-fg);
  font-weight: 700;
}
.chip__count {
  opacity: .7;
  font-variant-numeric: tabular-nums;
  font-size: .8em;
}

.timerange {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: .95rem;
}
.timerange input {
  font: inherit; font-size: 1rem;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--ink);
  min-height: 44px;
}

.filteractions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  font: inherit;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  min-height: 44px;
}
.btn--ghost { background: transparent; }

/* === Active-Filter-Banner (zeigt aktive Tour-/Ort-Filter aus Bottom-Nav-Drilldown) === */
.banner {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--forest);
  color: var(--bg-elev);
  border-radius: var(--radius);
  font-size: .9rem;
}
.banner__clear {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
}

/* === RESULTS / EVENT-LIST === */
.results {
  margin: 18px 0 30px;
}
.meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}
.eventlist {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.event__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
  padding-right: 44px;
}
.event__time {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  color: var(--forest);
  white-space: nowrap;
}
.event__tour {
  font-size: .8rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.event__tour:hover, .event__tour:focus-visible {
  background: var(--forest);
  color: var(--bg-elev);
  border-color: var(--forest-dark);
}
.event__tour svg { width: 14px; height: 14px; flex-shrink: 0; }

.event__title {
  margin: 4px 0 6px;
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.25;
  font-weight: 500;
  font-variation-settings: "opsz" 36;
  letter-spacing: -.01em;
}
.event__title button {
  font: inherit;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  padding: 0;
  width: 100%;
}
.event__title button:hover { color: var(--accent-dark); }

.event__desc {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: .95rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event__meta {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: .85rem;
  color: var(--muted);
  margin-top: 6px;
}
.event__meta span { display: inline-flex; align-items: center; gap: 4px; }
.event__loc { font-weight: 700; color: var(--ink-soft); }

.event__date {
  font-size: .85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.event__tags {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 8px;
}
.tag {
  font-size: .75rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 4px;
}
.tag--fee-frei      { color: var(--forest); border-color: var(--forest); }
.tag--fee-hutkasse  { color: var(--accent-dark); border-color: var(--accent); }
.tag--fee-paid      { color: var(--warn); border-color: var(--warn); }

.event__fav {
  position: absolute;
  top: 8px; right: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--muted);
  padding: 6px;
  line-height: 1;
  min-width: 40px; min-height: 40px;
}
.event__fav[aria-pressed="true"] { color: var(--accent); }
.event__fav:hover { color: var(--accent); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}

/* === TILEGRID (Touren) – 1 Spalte, listenartig === */
.tilegrid {
  list-style: none;
  margin: 0 0 30px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tile {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  width: 100%;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tile:hover, .tile:focus-visible {
  border-color: var(--forest);
  box-shadow: var(--shadow-sm);
}
.tile__icon {
  width: 36px; height: 36px;
  color: var(--forest);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--forest) 8%, transparent);
  border-radius: 999px;
  padding: 6px;
}
.tile__icon svg { width: 100%; height: 100%; }
.tile__title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--forest);
  margin: 0;
  line-height: 1;
  flex: 1;
  min-width: 0;
}
.tile__count {
  font-family: var(--body);
  font-weight: 700;
  font-size: .9rem;
  color: var(--accent);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.tile__count small {
  font-family: var(--body);
  font-weight: 400;
  font-size: .85em;
  color: var(--muted);
  margin-left: 4px;
}

/* === LOCATIONLIST === */
.locations__search { margin: 10px 0; }
.locations__search input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--ink);
  min-height: 44px;
}

.locationlist {
  list-style: none;
  margin: 0 0 30px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.locationlist__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  min-height: 48px;
  width: 100%;
  gap: 12px;
}
.locationlist__item:hover, .locationlist__item:focus-visible {
  border-color: var(--forest);
}
.locationlist__name {
  font-weight: 700;
  font-size: .95rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.locationlist__count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: .85rem;
  background: var(--chip-bg);
  padding: 2px 10px;
  border-radius: 999px;
}

/* === BOTTOMNAV === */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgba(40,25,0,.08);
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: var(--maxw);
  margin: 0 auto;
}
.bottomnav__btn {
  font: inherit;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: var(--bottomnav-h);
  font-size: .72rem;
  line-height: 1.1;
  position: relative;
}
.bottomnav__btn svg {
  width: 26px; height: 26px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .15s, fill .15s, transform .15s;
}
.bottomnav__btn[aria-pressed="true"] {
  color: var(--forest);
}
.bottomnav__btn[aria-pressed="true"] svg {
  stroke: var(--forest);
  fill: color-mix(in srgb, var(--forest) 12%, transparent);
  transform: translateY(-1px);
}
.bottomnav__btn:focus-visible {
  outline-offset: -3px;
}
/* Tap-Feedback */
.bottomnav__btn:active svg { transform: scale(.92); }

/* === DIALOG === */
.dialog {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--bg-elev);
  color: var(--ink);
  width: min(560px, 96vw);
  max-height: 92dvh;
  overflow: auto;
  box-shadow: var(--shadow-md);
}
.dialog::backdrop {
  background: rgba(20,14,5,.5);
  backdrop-filter: blur(4px);
}
.dialog article {
  padding: 24px;
  padding-top: 32px;
}
.dialog__close {
  position: sticky;
  top: 8px; left: calc(100% - 48px);
  width: 40px; height: 40px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 2;
}
.dialog h2 {
  font-family: var(--display);
  font-size: 1.45rem;
  margin: 0 0 8px;
  line-height: 1.2;
}

/* === FOOTER === */
.footer {
  border-top: 1px solid var(--line-soft);
  padding: 14px var(--pad);
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
}
.footer a { color: var(--muted); }

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
