/* ============================================================
   Wettesinger Dorfflohmarkt — Stylesheet
   Tech: CSS3 (Custom Properties, Grid, Flexbox, clamp())
   Responsive: Mobile-First (Basis mobil, min-width erweitert)
   ============================================================ */

/* ===== DESIGN TOKENS ===== */
:root {
  /* Farben — abgeleitet aus dem Original-Lageplan (Creme/Grün/Rot/Navy) */
  --color-bg:            #F7F2E7;
  --color-surface:       #FFFFFF;
  --color-surface-sunk:  #EFE8D8;
  --color-ink:           #26231C;
  --color-ink-soft:      #4A4738;
  --color-green:         #1F5D3A;
  --color-green-deep:    #163F28;
  --color-red:           #B23A2E;
  --color-red-deep:      #8E2C22;
  --color-navy:          #1C3A5E;
  --color-gold:          #C79A3F;
  --color-border:        #E1D8C0;

  /* Typografie */
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-script:  "Caveat", cursive;
  --font-body:    "Work Sans", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", "SF Mono", monospace;

  --text-xs:   0.85rem;
  --text-sm:   0.95rem;
  --text-base: clamp(1.05rem, 2.2vw, 1.15rem);
  --text-lg:   clamp(1.2rem,  2.8vw,  1.3rem);
  --text-xl:   clamp(1.4rem,  4vw,  1.7rem);
  --text-2xl:  clamp(1.8rem,  5vw,  2.2rem);

  /* Abstände */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2.25rem;

  /* Radius & Schatten */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 3px rgba(38,35,28,0.10);
  --shadow-md: 0 8px 24px rgba(38,35,28,0.14);
  --shadow-lg: 0 16px 40px rgba(38,35,28,0.20);

  /* Layout */
  --header-h: 88px;
  --tabbar-h: 74px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --transition-fast: 150ms ease;
  --transition-base: 240ms cubic-bezier(.4,0,.2,1);
}

/* ===== TEXTGRÖSSEN-STUFEN (per Umschalter in den Infos) ===== */
html[data-textsize="gross"] {
  --text-xs:   0.95rem;
  --text-sm:   1.1rem;
  --text-base: clamp(1.2rem, 2.6vw, 1.3rem);
  --text-lg:   clamp(1.35rem, 3.2vw, 1.5rem);
  --text-xl:   clamp(1.55rem, 4.4vw, 1.9rem);
  --text-2xl:  clamp(1.95rem, 5.4vw, 2.4rem);
}
html[data-textsize="riesig"] {
  --text-xs:   1.05rem;
  --text-sm:   1.25rem;
  --text-base: clamp(1.35rem, 3vw, 1.5rem);
  --text-lg:   clamp(1.5rem, 3.6vw, 1.7rem);
  --text-xl:   clamp(1.7rem, 4.8vw, 2.1rem);
  --text-2xl:  clamp(2.1rem, 5.8vw, 2.6rem);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-ink);
  background: var(--color-bg);
  min-height: 100dvh;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
ul { list-style: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; overflow-wrap: break-word; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0;
}
.skip-link {
  position: absolute; top: -100%; left: var(--space-md);
  background: var(--color-green-deep); color: #fff;
  padding: var(--space-sm) var(--space-md); border-radius: var(--radius-sm);
  z-index: 1000; transition: top var(--transition-fast);
}
.skip-link:focus { top: calc(var(--space-md) + var(--safe-top)); }

:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== HEADER ===== */
.app-header {
  position: sticky; top: 0; z-index: 40;
  padding-top: var(--safe-top);
  background: var(--color-green-deep);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.bunting {
  height: 11px;
  background-image: repeating-linear-gradient(
    100deg,
    #7B5EA7 0 12px,
    #E08A34 12px 24px,
    var(--color-gold) 24px 36px,
    #3B8A8C 36px 48px,
    var(--color-red) 48px 60px,
    var(--color-green) 60px 72px,
    var(--color-navy) 72px 84px
  );
  clip-path: polygon(0 0,100% 0,100% 60%,96.5% 100%,93% 60%,89.5% 100%,86% 60%,82.5% 100%,79% 60%,75.5% 100%,72% 60%,68.5% 100%,65% 60%,61.5% 100%,58% 60%,54.5% 100%,51% 60%,47.5% 100%,44% 60%,40.5% 100%,37% 60%,33.5% 100%,30% 60%,26.5% 100%,23% 60%,19.5% 100%,16% 60%,12.5% 100%,9% 60%,5.5% 100%,2% 60%,0 100%);
  opacity: 0.95;
}
.app-header__row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md) var(--space-md);
}
.app-header__eyebrow {
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #CFE0D2;
  margin-bottom: 2px;
}
.app-header__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.05;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.app-header__ribbon {
  font-family: var(--font-script);
  font-weight: 600;
  font-size: clamp(1.15rem, 4vw, 1.4rem);
  color: #fff;
  background: var(--color-navy);
  text-align: center;
  padding: 6px var(--space-lg) 9px;
  margin: 0 var(--space-md) var(--space-sm);
  border-radius: var(--radius-sm);
  position: relative;
}
.app-header__ribbon::before,
.app-header__ribbon::after {
  content: "";
  position: absolute; top: 0; bottom: 0; width: 14px;
  background: var(--color-navy);
}
.app-header__ribbon::before { left: -10px; clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.app-header__ribbon::after  { right: -10px; clip-path: polygon(100% 50%, 0 0, 0 100%); }
.app-header__status {
  display: flex; align-items: center; gap: var(--space-xs);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.12);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.app-header__status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-gold);
  flex-shrink: 0;
}
.app-header__status[data-state="live"] .app-header__status-dot { background: #6FCF97; box-shadow: 0 0 0 3px rgba(111,207,151,0.3); }
.app-header__status[data-state="upcoming"] .app-header__status-dot { background: var(--color-gold); }
.app-header__status[data-state="over"] .app-header__status-dot { background: #C98A8A; }

/* ===== MAIN / VIEWS ===== */
main {
  min-height: calc(100dvh - var(--header-h) - var(--tabbar-h));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-md));
}
.view { padding: var(--space-md); }

/* ---- Toolbars ---- */
.map-toolbar {
  display: flex; gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.list-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.list-toolbar .search-field { flex: 1 1 100%; }
.list-toolbar .sort-field { flex: 1 1 100%; }
.list-toolbar .sort-field select { width: 100%; }
@media (min-width: 480px) {
  .list-toolbar .search-field { flex: 1 1 auto; }
  .list-toolbar .sort-field { flex: 0 0 auto; }
  .list-toolbar .sort-field select { width: auto; }
}
.search-field {
  flex: 1;
  position: relative;
  display: flex; align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding-inline: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.search-field__icon { width: 18px; height: 18px; color: var(--color-ink-soft); flex-shrink: 0; }
.search-field input {
  border: none; background: transparent; width: 100%;
  padding: 0.95rem var(--space-sm);
}
.search-field input:focus { outline: none; }
.search-field:focus-within { border-color: var(--color-green); }

.icon-btn {
  width: 52px; height: 52px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  color: var(--color-green-deep);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.icon-btn:hover { background: var(--color-surface-sunk); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.is-active { background: var(--color-green); color: #fff; border-color: var(--color-green); }

.sort-field select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0.6rem var(--space-md);
  box-shadow: var(--shadow-sm);
}

/* ---- Map ---- */
.map {
  width: 100%;
  height: min(56vh, 480px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--color-surface-sunk);
}
.leaflet-popup-content-wrapper { border-radius: var(--radius-md); font-family: var(--font-body); }
.leaflet-popup-content { margin: var(--space-sm) var(--space-md); font-size: var(--text-sm); }

.map-pin {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--color-red);
  color: #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: var(--shadow-sm);
  border: 2px solid #fff;
}
.map-pin span { transform: rotate(45deg); font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
.map-pin--essen { background: var(--color-navy); }
.map-pin--user {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2E7DD6; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(46,125,214,0.25);
}
.map-cluster {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--color-red);
  color: #fff;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: var(--shadow-md);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
}

.category-chips-wrap { position: relative; }
.category-chips-wrap::after {
  content: "";
  position: absolute; top: 0; right: 0; bottom: 0; width: 40px;
  background: linear-gradient(to right, transparent, var(--color-bg));
  pointer-events: none;
  opacity: 1; transition: opacity var(--transition-fast);
}
.category-chips-wrap.is-at-end::after { opacity: 0; }

.category-chips {
  display: flex; gap: var(--space-xs);
  overflow-x: auto;
  padding-block: var(--space-md) var(--space-2xs);
  scrollbar-width: none;
}
.category-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 12px 18px;
  min-height: 48px;
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.chip.is-active {
  background: var(--color-green);
  border-color: var(--color-green);
  color: #fff;
}
.chip[data-empty="true"] { opacity: 0.45; }

/* ---- List ---- */
.list-count { color: var(--color-ink-soft); font-size: var(--text-sm); margin-bottom: var(--space-sm); }

.stand-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.stand-card {
  display: flex; align-items: center; gap: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-height: 64px;
  box-shadow: var(--shadow-sm);
  text-align: left;
  width: 100%;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.stand-card:hover { box-shadow: var(--shadow-md); }
.stand-card:active { transform: scale(0.98); }
.stand-card__nr {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-lg);
  color: #fff;
  background: var(--color-red);
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
}
.stand-card__body { flex: 1; min-width: 0; }
.stand-card__street { font-weight: 600; font-size: var(--text-lg); }
.stand-card__meta { font-size: var(--text-sm); color: var(--color-ink-soft); }
.stand-card__chevron { color: var(--color-ink-soft); flex-shrink: 0; width: 22px; height: 22px; }

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--color-ink-soft);
}

/* ---- Info ---- */
.info-card {
  background: var(--color-surface);
  border: 2px solid var(--color-gold);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
}
.info-card h3 {
  font-size: var(--text-lg);
  color: var(--color-green-deep);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-xs);
}
.info-card__hint { color: var(--color-ink-soft); font-size: var(--text-sm); margin-bottom: var(--space-sm); }

/* Termin-Box — betont goldumrandet wie im Original, Wochentag in Schreibschrift */
.info-card--date {
  text-align: center;
  border-width: 3px;
  padding-block: var(--space-lg);
}
.info-card__weekday {
  font-family: var(--font-script);
  font-weight: 600;
  font-size: clamp(1.6rem, 5vw, 2rem);
  color: var(--color-navy);
  line-height: 1;
}
.info-card__date {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.9rem, 6vw, 2.4rem);
  color: var(--color-ink);
  margin: var(--space-2xs) 0;
}
.info-card__time {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  color: var(--color-green);
}

/* 48-Stände-Box */
.info-card--stands { text-align: center; }
.info-card__stands-nr {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--color-green-deep);
}
.info-card__stands-sub { font-size: var(--text-base); color: var(--color-ink-soft); }

.textsize-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
}
.textsize-btn {
  background: var(--color-surface-sunk);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-2xs);
  min-height: 64px;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-ink);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.textsize-btn span { font-size: 1.3em; }
.textsize-btn[data-textsize="gross"] span { font-size: 1.55em; }
.textsize-btn[data-textsize="riesig"] span { font-size: 1.8em; }
.textsize-btn[aria-pressed="true"] {
  background: var(--color-green);
  border-color: var(--color-green);
  color: #fff;
}

/* Herz-Bullets wie im Original ("Gut zu wissen") */
.info-list { list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 8px; }
.info-list--heart li { padding-left: 1.6em; position: relative; }
.info-list--heart li::before {
  content: "♡";
  position: absolute; left: 0; top: 0.05em;
  color: var(--color-green);
  font-size: 1.1em;
}

/* Original-Footer-Zeile (Kartendaten-Credit + Tagline) */
.poster-footer {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-ink-soft);
  padding: var(--space-sm) 0 var(--space-md);
  display: flex; flex-direction: column; gap: 4px;
}
.poster-footer__claim {
  font-family: var(--font-script);
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  color: var(--color-green-deep);
  font-weight: 600;
}
.app-version { text-align: center; font-size: var(--text-xs); color: var(--color-ink-soft); }

/* ---- Route Buttons ---- */
.btn-route {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--color-green);
  color: #fff;
  padding: 0.9rem 1.3rem;
  min-height: 52px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-base);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.btn-route:hover { background: var(--color-green-deep); }
.btn-route:active { transform: scale(0.97); }
.btn-route--primary { width: 100%; padding: 1.1rem; font-size: var(--text-lg); }

/* ===== STAND DETAIL SHEET ===== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(38,35,28,0.45);
  opacity: 0; transition: opacity var(--transition-base);
}
.sheet-backdrop:not([hidden]) { opacity: 1; }

.stand-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-md) var(--space-lg) calc(var(--space-lg) + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--transition-base);
  max-width: 560px; margin-inline: auto;
}
.stand-sheet:not([hidden]) { transform: translateY(0); }
.stand-sheet__handle {
  width: 40px; height: 4px; border-radius: var(--radius-full);
  background: var(--color-border);
  margin: 0 auto var(--space-md);
}
.stand-sheet__close {
  position: absolute; top: var(--space-md); right: var(--space-md);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--color-surface-sunk);
  font-size: 14px;
}
.stand-sheet__badge {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  font-family: var(--font-mono); font-weight: 700;
  background: var(--color-red); color: #fff;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
}
.stand-sheet__title { font-size: var(--text-xl); color: var(--color-green-deep); }
.stand-sheet__category { color: var(--color-ink-soft); margin: var(--space-2xs) 0 var(--space-md); }
.stand-sheet__actions { display: flex; gap: var(--space-sm); }

/* ===== BOTTOM TAB BAR ===== */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 16px rgba(38,35,28,0.08);
}
.tab-bar__btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 0 10px;
  min-height: 60px;
  color: var(--color-ink-soft);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color var(--transition-fast);
}
.tab-bar__btn svg { width: 26px; height: 26px; }
.tab-bar__btn.is-active { color: var(--color-green-deep); font-weight: 700; }

/* ===== TOAST ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  transform: translateX(-50%);
  background: var(--color-ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  z-index: 70;
  box-shadow: var(--shadow-md);
}

/* ===== RESPONSIVE (Tablet / Desktop) ===== */
@media (min-width: 640px) {
  .app-header__title { font-size: 2.3rem; }
  .stand-sheet { border-radius: var(--radius-lg); left: 50%; right: auto; bottom: var(--space-lg); transform: translate(-50%, 20px); }
  .stand-sheet:not([hidden]) { transform: translate(-50%, 0); }
}

@media (min-width: 1024px) {
  main { max-width: 720px; margin-inline: auto; }
  .tab-bar { max-width: 720px; margin-inline: auto; left: 0; right: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .map { height: 60vh; }
}
