/* ==========================================================================
   Wildeshausen-App — Detailansicht (Bottom-Sheet)
   Wird von assets/sheet.js aufgebaut (Container #sheet am Ende des body).
   Farben: Rot #ba092f, Weiß, Grau #f1f1f3 — alle Ecken eckig (radius 0).
   Schrift: IBM Plex Sans, geerbt von style.css (kein zweites @font-face).
   Touch-Ziele: mindestens 44 px hoch.
   ========================================================================== */

/* ---------- 1. Overlay ---------------------------------------------------- */
#sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#sheet[hidden] { display: none !important; }

/* Während des Ausblendens keine Klicks mehr annehmen. */
#sheet:not(.ist-offen) { pointer-events: none; }

/* Verdunkelung des Hintergrunds; Tippen daneben schließt (JS). */
.ws-sheet__hintergrund {
  position: absolute;
  inset: 0;
  background: rgba(22, 22, 24, .52);
  opacity: 0;
  transition: opacity .22s ease;
}

#sheet.ist-offen .ws-sheet__hintergrund { opacity: 1; }

/* ---------- 2. Fläche ----------------------------------------------------- */
.ws-sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;          /* Fallback für alte Browser */
  max-height: 88dvh;
  background: #ffffff;
  border-top: 4px solid #ba092f;
  box-shadow: 0 -14px 44px rgba(22, 22, 24, .22);
  color: #161618;
  font-family: "PlexSans", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.22, .7, 0, 1);
  outline: none;             /* Fokus liegt programmatisch auf dem Dialog */
}

#sheet.ist-offen .ws-sheet__panel { transform: translateY(0); }

/* ---------- 3. Kopf ------------------------------------------------------- */
.ws-sheet__kopf {
  position: relative;
  flex: none;
  padding: 18px 18px 12px;
  border-bottom: 1px solid #e6e6e9;
  touch-action: pan-y;
}

/* Griff: Zierde, zugleich Andeutung „nach unten ziehen“ */
.ws-sheet__griff {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 40px;
  height: 4px;
  margin-left: -20px;
  background: #d4d4d9;
}

.ws-sheet__eyebrow {
  margin: 0 0 4px;
  color: #ba092f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.ws-sheet__titel {
  /* Zurücksetzen der globalen h2-Regel aus style.css (Abschnitts-Label) */
  display: block;
  margin: 0;
  padding: 0 46px 0 0;
  border: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -.015em;
  text-transform: none;
  color: #161618;
  text-wrap: pretty;
}

.ws-sheet__x {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: #4d4e53;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.ws-sheet__x:hover { background: #f1f1f3; color: #ba092f; }
.ws-sheet__x:focus-visible { outline: 2px solid #ba092f; outline-offset: -2px; }

/* ---------- 4. Inhalt ----------------------------------------------------- */
.ws-sheet__inhalt {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.ws-sheet__adresse {
  margin: 0;
  font-size: 14px;
  color: #4d4e53;
}

.ws-sheet__adresse span { display: block; }

.ws-sheet__dist {
  margin: 6px 0 0;
  font-size: 12px;
  letter-spacing: .01em;
  color: #6b6c73; /* 5,2:1 auf Weiß – AA für kleine Schrift */
}

.ws-sheet__desc {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: #4d4e53;
}

/* Kontaktzeilen: Telefon, Website */
.ws-sheet__kontakt {
  margin-top: 16px;
  border-top: 1px solid #e6e6e9;
}

.ws-sheet__kontaktzeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  border-bottom: 1px solid #e6e6e9;
}

.ws-sheet__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #6b6c73; /* 5,2:1 auf Weiß – AA für kleine Schrift */
}

.ws-sheet__wert {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: #ba092f;
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.ws-sheet__wert:hover { text-decoration: underline; text-underline-offset: 3px; }
.ws-sheet__wert:focus-visible { outline: 2px solid #ba092f; outline-offset: 2px; }

/* Öffnungszeiten (nur Bürgerservice) */
.ws-sheet__info {
  margin-top: 18px;
  padding: 12px 14px;
  background: #f1f1f3;
  border-left: 3px solid #ba092f;
}

.ws-sheet__info-titel {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #161618;
}

.ws-sheet__info-inhalt { font-size: 13px; color: #4d4e53; }
.ws-sheet__info-inhalt ul { margin: 0; padding: 0; list-style: none; }
.ws-sheet__info-inhalt li { padding: 2px 0; }

.ws-sheet__zeiten { margin: 0; }

.ws-sheet__zeiten dl { margin: 0; }
.ws-sheet__zeiten .zeile {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(22, 22, 24, .07);
}
.ws-sheet__zeiten .zeile:last-child { border-bottom: 0; }
.ws-sheet__zeiten dt { font-weight: 600; color: #161618; }
.ws-sheet__zeiten dd { margin: 0; text-align: right; }

/* Hinweis und Quelle unter den Zeiten (nur wenn Daten vorhanden sind) */
.ws-sheet__hinweis {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #4d4e53;
}
.ws-sheet__quelle {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted, #686971);
}
.ws-sheet__quelle a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(22, 22, 24, .25);
}
.ws-sheet__quelle a:hover { color: #ba092f; border-bottom-color: currentColor; }
.ws-sheet__quelle a:focus-visible { outline: 2px solid #ba092f; outline-offset: 2px; }

/* ---------- 5. Aktionen --------------------------------------------------- */
/* Vier gleich große Felder nebeneinander (Route, Anrufen, Website, Teilen),
   darunter „Schließen“. Fehlt ein Ziel (keine Nummer, keine Adresse), fällt
   das Feld weg; auto-fit legt dann die leere Spur zusammen, damit keine
   Lücke bleibt. */
.ws-sheet__aktionen {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e6e6e9;
  background: #ffffff;
}

.ws-sheet__aktionen-reihe {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.ws-sheet__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 60px;
  padding: 8px 6px;
  /* Umgrenzung des Bedienelements: 1.4.11 verlangt 3:1 – #d4d4d9 waren 1,48:1,
     #686971 liegt auf Weiß bei 5,46:1. */
  border: 1px solid #686971;
  border-radius: 0;
  background: #ffffff;
  color: #161618;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* Symbol rot, Text dunkel — Rot bleibt der Akzent, nicht die Fläche. */
.ws-sheet__btn svg { flex: none; color: #ba092f; }
.ws-sheet__btn-text { display: block; }

.ws-sheet__btn:hover { border-color: #ba092f; background: #fdf2f4; }
.ws-sheet__btn:active { transform: translateY(1px); }
.ws-sheet__btn:focus-visible { outline: 2px solid #ba092f; outline-offset: 2px; }

/* Route ist die Hauptaktion: einzige gefüllte Fläche. */
.ws-sheet__btn--rot {
  background: #ba092f;
  border-color: #ba092f;
  color: #ffffff;
}
.ws-sheet__btn--rot svg { color: #ffffff; }
.ws-sheet__btn--rot:hover { background: #94071f; border-color: #94071f; }
.ws-sheet__btn--rot:focus-visible { outline-color: #161618; }

/* „Schließen“ liegt leise unter der Reihe, volle Breite. */
.ws-sheet__btn--leise {
  flex-direction: row;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-color: #686971;   /* 4,84:1 auf #f1f1f3 – vorher 1,10:1 */
  background: #f1f1f3;
  font-size: 13px;
}
.ws-sheet__btn--leise:hover { background: #e8e8ec; border-color: #161618; }

/* Unsichtbares Feld für das Kopieren ohne Clipboard-API. */
.ws-sheet__kopierfeld {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;   /* verhindert den Zoom auf iOS */
  pointer-events: none;
}

/* ---------- 6. Hilfsklassen ---------------------------------------------- */
.ws-sheet__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- 7. Seiten-Scroll sperren ------------------------------------- */
/* Sperrt body, aber auch die Scrollflächen der Startseite (.body/.app),
   weil auf dem Desktop nicht body, sondern .body scrollt. */
html.ws-sheet-offen,
html.ws-sheet-offen body,
html.ws-sheet-offen .body,
html.ws-sheet-offen .app {
  overflow: hidden !important;
}

/* ---------- 8. Weniger Bewegung ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  #sheet .ws-sheet__hintergrund,
  .ws-sheet__panel {
    transition: none !important;
  }
  .ws-sheet__panel { transform: none; }
  .ws-sheet__btn:active { transform: none; }
}

/* ---------- 9. Schmale Geräte ------------------------------------------- */
@media (max-width: 480px) {
  .ws-sheet__panel {
    max-height: 92vh;
    max-height: 92dvh;
    border-top-width: 3px;
  }
  .ws-sheet__kopf { padding: 18px 16px 12px; }
  .ws-sheet__titel { font-size: 21px; }
  .ws-sheet__inhalt { padding: 12px 16px 16px; }
  .ws-sheet__aktionen { padding-left: 16px; padding-right: 16px; }
  .ws-sheet__btn { font-size: 11.5px; }
}

/* Querformat mit wenig Höhe */
@media (max-height: 460px) {
  .ws-sheet__panel { max-height: 100dvh; }
  .ws-sheet__kopf { padding-top: 14px; }
}

@media print {
  #sheet { display: none !important; }
}

/* ---------- Kontrastmodus (forced-colors) -------------------------------
   Die gefüllte Hauptaktion (Route) verliert im Systemmodus ihre rote Fläche;
   ein kräftigerer Rahmen hält sie erkennbar. */
@media (forced-colors: active) {
  .ws-sheet__btn--rot { border-width: 2px; border-style: solid; }
  .ws-sheet__btn--leise { border-color: CanvasText; }
  .ws-sheet__x:focus-visible,
  .ws-sheet__btn:focus-visible,
  .ws-sheet__wert:focus-visible { outline-color: Highlight; }
}
