/* ============================================================
   Apothekenverzeichnis — styles.css
   Glassmorphism + Emerald Theme, Mobile-First
   ============================================================ */

/* ============================================================
   1. Design Tokens
   ============================================================ */
:root {
  --clr-primary: #059669;           /* Emerald-600 */
  --clr-primary-light: #10b981;     /* Emerald-500 */
  --clr-primary-dark: #047857;      /* Emerald-700 */
  --clr-bg: #f0fdf4;                /* Green-50 background */
  --clr-bg-card: rgba(255,255,255,0.72);
  --clr-text: #064e3b;              /* Emerald-900 */
  --clr-text-muted: #6b7280;        /* Gray-500 */
  --clr-border: rgba(255,255,255,0.6);
  --radius-card: 16px;
  --radius-btn: 10px;
  --shadow-card: 0 4px 24px rgba(5,150,105,0.10);
  --shadow-hover: 0 8px 32px rgba(5,150,105,0.20);
  --blur: blur(14px);
  --transition: 0.2s ease;
}

/* Alpine x-cloak: hide before Alpine initialises to prevent CLS flash */
[x-cloak] { display: none !important; }

/* ============================================================
   2. Reset + Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.5;
}

a {
  color: var(--clr-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

ul, ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ============================================================
   3. Glassmorphism Utility
   ============================================================ */
.glass-card {
  background: var(--clr-bg-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* ============================================================
   4. Header
   ============================================================ */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  background: rgba(255,255,255,0.85);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--clr-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--clr-primary);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.count-badge {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  background: rgba(5,150,105,0.1);
  padding: 0.2em 0.6em;
  border-radius: 999px;
}

header nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.9rem;
}

header nav a {
  color: var(--clr-text-muted);
  transition: color var(--transition);
}

header nav a:hover {
  color: var(--clr-primary);
  text-decoration: none;
}

/* ============================================================
   5. Search Bar
   ============================================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.25rem;
  margin: 1rem 1.5rem;
}

#gps-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-btn);
  background: var(--clr-primary);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: background var(--transition);
}

#gps-btn:hover {
  background: var(--clr-primary-dark);
}

#search-input {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.875rem;
  border: 1.5px solid rgba(5,150,105,0.25);
  border-radius: var(--radius-btn);
  background: rgba(255,255,255,0.8);
  font-size: 0.95rem;
  color: var(--clr-text);
  transition: border-color var(--transition);
}

#search-input:focus-visible {
  border-color: var(--clr-primary);
  outline: 2px solid var(--clr-primary);
  outline-offset: -1px;
}

#search-input::placeholder {
  color: var(--clr-text-muted);
}

.radius-pills {
  display: flex;
  gap: 0.4rem;
}

.radius-pills button {
  padding: 0.4rem 0.875rem;
  border-radius: 999px;
  cursor: pointer;
  border: 1.5px solid var(--clr-primary);
  background: transparent;
  color: var(--clr-primary);
  font-size: 0.85rem;
  transition: background var(--transition), color var(--transition);
}

.radius-pills button.active,
.radius-pills button:hover {
  background: var(--clr-primary);
  color: white;
}

/* ============================================================
   6. Loading Bar
   ============================================================ */
.loading-bar {
  /* Fixed so it never shifts the document layout (prevents CLS) */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  text-align: center;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  color: var(--clr-primary);
  background: rgba(240,253,244,0.95);
  border-top: 1px solid rgba(5,150,105,0.15);
  backdrop-filter: var(--blur);
}

/* ============================================================
   7. Split-View Layout (desktop ≥1024px)
   ============================================================ */
#app {
  display: flex;
  height: calc(100vh - 140px); /* subtract header + search bar height */
  overflow: hidden;
}

#list-panel {
  width: 360px;
  min-width: 280px;
  max-width: 420px;
  overflow-y: auto;
  padding: 0.75rem;
  border-right: 1px solid var(--clr-border);
  background: rgba(240,253,244,0.6);
}

#map {
  flex: 1;
  z-index: 0;
  /* Solid background prevents map tile flicker from being LCP candidate */
  background: #e8f5e9;
}

.results-count {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60%;
  text-align: center;
  color: var(--clr-text-muted);
  font-size: 0.9rem;
}

/* ============================================================
   8. Pharmacy Cards
   ============================================================ */
.pharmacy-card {
  padding: 0.875rem 1rem;
  margin-bottom: 0.625rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.pharmacy-card:hover {
  box-shadow: var(--shadow-hover);
}

.pharmacy-card.selected {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 2px var(--clr-primary-light), var(--shadow-hover);
}

.pharmacy-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.pharmacy-card address {
  font-style: normal;
  font-size: 0.83rem;
  color: var(--clr-text-muted);
}

.pharmacy-card .distance {
  font-size: 0.8rem;
  color: var(--clr-primary);
  font-weight: 500;
  margin-top: 0.25rem;
}

.pharmacy-card .opening-hours {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  margin-top: 0.25rem;
}

.contact-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.contact-links a {
  font-size: 0.8rem;
  color: var(--clr-primary);
}

/* ============================================================
   9. Leaflet Popup
   ============================================================ */
.leaflet-popup-content-wrapper {
  background: rgba(255,255,255,0.96) !important;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-radius: 14px !important;
  box-shadow: var(--shadow-hover) !important;
  border: 1px solid var(--clr-border);
}

.leaflet-popup-tip {
  background: rgba(255,255,255,0.96) !important;
}

.popup-content h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--clr-text);
}

.popup-content p {
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  margin-bottom: 0.25rem;
}

.popup-oh {
  color: var(--clr-text-muted);
}

.popup-dist {
  font-size: 0.8rem;
  color: var(--clr-primary);
  font-weight: 600;
}

.popup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.popup-action {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: rgba(5,150,105,0.08);
  color: var(--clr-primary);
  transition: background var(--transition);
}

.popup-action:hover {
  background: rgba(5,150,105,0.16);
  text-decoration: none;
}

/* ============================================================
   10. Drag Handle (hide on desktop, show on mobile)
   ============================================================ */
.drag-handle {
  display: none;
}

@media (max-width: 767px) {
  .drag-handle {
    display: block;
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: #d1d5db;
    margin: 0.75rem auto 0.5rem;
    cursor: pointer;
  }
}

/* ============================================================
   11. Mobile Layout (<768px) — Karte oben, Pull-up Sheet unten
   ============================================================ */
@media (max-width: 767px) {
  #app {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  #map {
    flex: none; /* reset flex-basis: 0 so height: 55vh is respected */
    height: 55vh;
    width: 100%;
    position: relative;
    z-index: 0;
  }

  #list-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    overflow-y: auto;
    border-right: none;
    border-radius: 20px 20px 0 0;
    background: white;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    transform: translateY(calc(100% - 72px));
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 500;
    padding-top: 0;
  }

  #list-panel.open {
    transform: translateY(0);
  }

  /* Hide pull-up sheet when Leaflet popup is open */
  body.leaflet-popup-open #list-panel {
    transform: translateY(100%) !important;
  }

  .search-bar {
    margin: 0.5rem;
  }
}

/* ============================================================
   12. Tablet Layout (768–1023px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  #list-panel {
    width: 280px;
  }
}

/* ============================================================
   13. SEO Sections (below fold)
   ============================================================ */
.seo-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.seo-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.city-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 2rem;
}

.city-chip {
  padding: 0.4rem 0.875rem;
  border-radius: 999px;
  background: rgba(5,150,105,0.08);
  color: var(--clr-primary);
  font-size: 0.875rem;
  border: 1px solid rgba(5,150,105,0.2);
  transition: background var(--transition);
}

.city-chip:hover {
  background: rgba(5,150,105,0.16);
  text-decoration: none;
}

.city-chip span {
  color: var(--clr-text-muted);
  font-size: 0.8rem;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

/* ============================================================
   14. Ratgeber / Article Cards
   ============================================================ */
.guide-card {
  padding: 1.25rem;
  transition: box-shadow var(--transition);
}

.guide-card:hover {
  box-shadow: var(--shadow-hover);
}

.guide-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.guide-card p {
  font-size: 0.875rem;
  color: var(--clr-text-muted);
}

/* ============================================================
   15. FAQ List
   ============================================================ */
.faq-list {
  max-width: 720px;
}

.faq-list dt {
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 1.25rem;
  cursor: pointer;
  color: var(--clr-primary);
}

.faq-list dd {
  font-size: 0.9rem;
  color: var(--clr-text-muted);
  margin-top: 0.35rem;
}

/* ============================================================
   16. Detail Page Layout
   ============================================================ */
.detail-layout {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.detail-card {
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.detail-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.detail-card address {
  font-style: normal;
  font-size: 1rem;
  color: var(--clr-text-muted);
}

.detail-map {
  height: 320px;
  border-radius: var(--radius-card);
  overflow: hidden;
  margin: 1rem 0;
}

/* ============================================================
   17. Footer
   ============================================================ */
footer {
  background: rgba(255,255,255,0.7);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--clr-border);
  padding: 2rem 1.5rem;
  margin-top: 3rem;
}

.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2rem;
}

footer h4 {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

footer a {
  display: block;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  margin-bottom: 0.35rem;
  transition: color var(--transition);
}

footer a:hover {
  color: var(--clr-primary);
  text-decoration: none;
}

footer p {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
}

/* ============================================================
   18. Utility Buttons
   ============================================================ */
.btn-primary {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  background: var(--clr-primary);
  color: white;
  border-radius: var(--radius-btn);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition);
}

.btn-primary:hover {
  background: var(--clr-primary-dark);
  text-decoration: none;
}

/* ============================================================
   19. Accessibility: Focus Styles
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   20. Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   21. Article / Ratgeber Pages
   ============================================================ */
.article-layout {
  max-width: 760px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.article-body {
  padding: 2rem;
}

.article-body h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.article-body h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 1.75rem 0 0.5rem;
}

.article-body p {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.article-body ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  list-style: disc;
}

.article-body li {
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}

.article-breadcrumb {
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  margin-bottom: 1.5rem;
}

.article-breadcrumb a {
  color: var(--clr-primary);
}

/* ============================================================
   21. Subpage Layout — Page Container, Pharmacy Cards, Breadcrumbs
   ============================================================ */

/* Centered content column for all static subpages */
.page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ── Breadcrumbs ────────────────────────────────────────────────────────────── */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.breadcrumb a {
  color: var(--clr-text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.breadcrumb a:hover { color: var(--clr-primary); }

.breadcrumb span { color: var(--clr-border); }

/* ── City page pharmacy list ──────────────────────────────────────────────── */
.apo-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: grid;
  gap: 1rem;
}

.apo-card {
  background: rgba(255,255,255,0.75);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

.apo-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.apo-card h2 {
  font-size: 1.1rem;
  margin: 0 0 0.4rem;
}

.apo-card h2 a {
  color: var(--clr-primary);
  text-decoration: none;
}

.apo-card h2 a:hover { text-decoration: underline; }

.apo-card address {
  font-style: normal;
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.apo-phone,
.apo-oh {
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  margin: 0.2rem 0;
}

.apo-website {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-primary);
  text-decoration: none;
}

.apo-website:hover { text-decoration: underline; }

/* ── Detail page ────────────────────────────────────────────────────────────── */
.detail-card {
  background: rgba(255,255,255,0.8);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

/* ── Legal / content pages (Impressum, Datenschutz) ────────────────────────── */
.prose {
  max-width: 720px;
}

.prose h2 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--clr-heading);
  font-size: 1.25rem;
}

.prose p,
.prose li {
  line-height: 1.75;
  color: var(--clr-text);
}

.prose ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

/* ── Ratgeber index grid ────────────────────────────────────────────────────── */
.ratgeber-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.ratgeber-card {
  background: rgba(255,255,255,0.75);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow var(--transition), transform var(--transition);
}

.ratgeber-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}

.ratgeber-card h2,
.ratgeber-card h3 {
  color: var(--clr-primary);
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.ratgeber-card p {
  font-size: 0.875rem;
  color: var(--clr-text-muted);
  margin: 0;
}

.article-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: grid;
  gap: 0.75rem;
}

.article-list li a {
  display: block;
  background: rgba(255,255,255,0.7);
  backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  border-radius: calc(var(--radius) - 4px);
  padding: 1rem 1.25rem;
  color: var(--clr-primary);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition);
}

.article-list li a:hover {
  background: rgba(255,255,255,0.95);
  box-shadow: var(--shadow-sm);
}

.article-list li a small {
  display: block;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  margin-top: 0.15rem;
}
