/* Responsive: Tablet (<1024), Mobile (<768), Small (<480), Tiny (<360) */

/* --- Tablet (< 1024px) --- */
@media (max-width: 1024px) {
  .main-wrap {
    grid-template-columns: 1fr;
    padding: var(--sp-5);
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-6);
  }

  .hero-inner {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
  }

  .hero-right {
    max-width: 560px;
  }

  .cta-card {
    grid-column: 1 / -1;
  }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 768px) {
  :root {
    --header-h: 72px;
    --sp-5: 16px;
    --sp-6: 20px;
    --sp-8: 24px;
  }

  .container {
    padding: 0 var(--sp-4);
  }

  .header-nav {
    display: none;
  }

  .hamburger {
    display: inline-flex;
  }

  /* Text-Groesse-Toggle auf Mobile kompakter */
  .text-size-toggle {
    margin-right: var(--sp-2);
  }

  /* Touch-Target WCAG-konform (44x44 Empfehlung): visuell bleiben die Buttons
     28x28, aber padding erweitert die Hit-Area auf 44x44. */
  .text-size-btn {
    width: 28px;
    height: 28px;
    position: relative;
  }
  .text-size-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
  }

  .mobile-menu {
    display: block;
  }

  .logo-img {
    height: 64px;
  }

  /* Hero luftiger auf Mobile - mehr Atmung zwischen den Bloecken */
  .hero {
    padding: var(--sp-10) var(--sp-6) var(--sp-12);
  }

  /* "Termine entdecken" entfaellt auf Mobile (scrollen reicht) */
  .hero-action-primary {
    display: none;
  }

  /* "Veranstalter werden" dezenter und kleiner, mit deutlich mehr Abstand zu den Stats */
  .hero-actions {
    margin-bottom: var(--sp-8);
  }

  .hero-actions .btn--secondary.btn--lg {
    padding: 12px 18px;
    font-size: var(--fs-sm);
    min-height: 44px; /* WCAG Touch-Target */
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.8);
  }

  .hero-actions .btn--secondary.btn--lg:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
  }

  .hero::before {
    width: 260px;
    height: 260px;
    top: -80px;
    right: -60px;
  }

  .hero h1 {
    /* Etwas groesser, ohne dass "Nordbahngemeinden" gehyphenisiert wird */
    font-size: clamp(2rem, 7.4vw, 2.8rem);
    line-height: 1.16;
    margin-bottom: var(--sp-5);
    /* Keine Auto-Silbentrennung: das lange Wort bricht am Wortanfang um, nicht mittendrin */
    hyphens: manual;
    overflow-wrap: normal;
  }

  .hero-eyebrow {
    margin-bottom: var(--sp-5);
  }

  .hero-sub {
    font-size: var(--fs-md);
    margin-bottom: var(--sp-8);
    line-height: 1.55;
  }

  /* Stats auf Mobile: 3 Spalten in einer Zeile, jeweils zentriert in ihrer Spalte */
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-3);
    padding-top: var(--sp-6);
  }

  .hero-stat {
    min-width: 0;
    align-items: center;
    text-align: center;
  }

  .hero-stat-head {
    justify-content: center;
  }

  .hero-stat-num {
    font-size: var(--fs-lg);
  }

  .hero-stat-label {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }

  /* Toolbar: nicht mehr sticky auf Mobile, sonst blockiert sie beim Hochscrollen */
  .toolbar {
    position: static;
  }

  .toolbar-inner {
    padding: var(--sp-3) var(--sp-4) var(--sp-5);
    gap: var(--sp-6);
  }

  .toolbar-section {
    gap: 10px;
  }

  .toolbar-section-label {
    font-size: 0.78rem;
    letter-spacing: 0.14em;
  }

  /* Scroll-Container entspannen: Grid/Wrap braucht kein horizontales Scrollen,
     overflow:auto fing Touch-Events ab und verhinderte vertikales Scrollen */
  #gemeinde-chips.toolbar-scroll,
  #category-chips.toolbar-scroll {
    overflow-x: visible;
    -webkit-overflow-scrolling: auto;
  }

  /* Zeile 3: auf Mobile - Ansicht linksbuendig, Monatsnav in eigene Zeile mittig */
  .toolbar-row--between {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: var(--sp-3);
  }

  .toolbar-row--between > .segmented  { justify-self: auto; }
  .toolbar-row--between > .month-nav  { justify-self: auto; }

  /* Ansicht-Switcher auf Mobile auf volle Breite, alle 4 Buttons gleichmaessig verteilt */
  .segmented {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    display: flex;
  }

  .segmented-btn {
    flex: 1 1 0;
    padding: 6px 6px;
    font-size: var(--fs-xs);
    min-height: 36px;
    text-align: center;
  }

  .month-nav {
    flex-basis: 100%;
    justify-content: center;
  }

  .month-nav-btn {
    width: 44px;
    height: 44px;
  }

  .month-label {
    font-size: var(--fs-sm);
    min-width: 100px;
    text-align: center;
  }

  .chip {
    padding: 6px 12px;
    font-size: var(--fs-xs);
    min-height: 34px;
  }

  /* Gemeinden auf Mobile zweispaltig */
  #gemeinde-chips.toolbar-scroll {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }

  .chip--gemeinde {
    font-size: var(--fs-xs);
    padding: 7px 10px;
    min-height: 36px;
  }

  /* Kategorien auf Mobile wie Desktop: Bubble-Cloud mit flex-wrap, linksbuendig */
  #category-chips.toolbar-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    justify-content: flex-start;
  }

  .chip--cat {
    padding: 6px 10px 6px 6px;
    min-height: 34px;
    font-size: var(--fs-xs);
    white-space: nowrap;
  }

  .chip--cat .chip-icon {
    width: 22px;
    height: 22px;
    font-size: 0.85rem;
  }

  /* Main */
  .main-wrap {
    padding: var(--sp-4);
    gap: var(--sp-4);
  }

  .sidebar {
    grid-template-columns: 1fr;
    gap: var(--sp-6);
  }

  /* Kalender */
  .cal-body {
    border-radius: var(--radius-sm);
  }

  .cal-day {
    min-height: 70px;
    padding: 4px;
  }

  .cal-num {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
  }

  .cal-event {
    font-size: 0.58rem;
    padding: 1px 4px;
  }

  .cal-more {
    font-size: 0.58rem;
  }

  /* Week */
  .week-grid {
    grid-template-columns: repeat(7, minmax(130px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .week-col {
    min-height: 160px;
    padding: 6px;
  }

  .week-nav-label {
    font-size: var(--fs-sm);
    min-width: 180px;
  }

  /* List */
  .event-card {
    padding: var(--sp-3) var(--sp-4);
    gap: var(--sp-3);
    flex-wrap: nowrap;
  }

  .event-card-icon {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    border-radius: var(--radius-sm);
  }

  .date-box {
    min-width: 44px;
  }

  .date-box-day {
    font-size: 1.3rem;
  }

  .event-title {
    font-size: var(--fs-md);
  }

  .event-meta {
    font-size: var(--fs-xs);
    gap: var(--sp-2);
  }

  /* Map */
  .map-container {
    height: 380px;
    border-radius: var(--radius-sm);
  }

  /* Modal */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 94vh;
  }

  .modal-header {
    padding: var(--sp-5) var(--sp-4) var(--sp-3);
  }

  .modal-header h2 {
    font-size: var(--fs-lg);
  }

  .modal-body {
    padding: var(--sp-4);
  }

  .modal-detail-grid {
    grid-template-columns: 1fr;
    gap: var(--sp-3);
  }

  .business-meta {
    grid-template-columns: 1fr;
  }

  .modal-detail-icon {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .modal-map {
    height: 180px;
  }

  .modal-actions {
    gap: var(--sp-2);
  }

  /* Form */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Search */
  .search-overlay {
    padding-top: 8vh;
  }

  .search-box {
    width: 96%;
  }

  /* Footer */
  .footer-inner {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
    padding: var(--sp-6) var(--sp-4);
  }

  .footer-brand .logo-img {
    height: 52px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    padding: var(--sp-4);
  }

  .footer-credits {
    justify-content: center;
  }

  /* Preview-Banner: bleibt prominent, nur leicht kompakter */
  .preview-banner {
    font-size: var(--fs-xs);
    padding: 8px var(--sp-3);
    letter-spacing: 0.06em;
  }
}

/* --- Small Phones (< 480px) --- */
@media (max-width: 480px) {
  .logo-img {
    height: 48px;
  }

  /* Kalender: nur Dots */
  .cal-header span {
    font-size: 0.56rem;
    letter-spacing: 0;
  }

  .cal-event,
  .cal-more {
    display: none;
  }

  .cal-day {
    min-height: 44px;
    padding: 3px;
  }

  .cal-num {
    width: 20px;
    height: 20px;
    font-size: 0.62rem;
    margin-bottom: 2px;
  }

  .cal-day.has-event::after {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-accent);
    margin: 1px auto 0;
  }

  /* Hero auf kleinen Phones - kompakter, aber weiterhin luftig */
  .hero {
    padding: var(--sp-8) var(--sp-5) var(--sp-10);
  }

  .hero h1 {
    font-size: 1.95rem;
    line-height: 1.16;
  }

  .hero-sub {
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-6);
  }

  /* Event-Cards */
  .event-card {
    padding: var(--sp-3);
    gap: var(--sp-3);
  }

  .event-card-icon {
    display: none;
  }

  .date-box-day {
    font-size: 1.15rem;
  }

  .event-title {
    font-size: var(--fs-sm);
  }

  /* Map */
  .map-container {
    height: 280px;
  }

  /* Modal */
  .modal-header h2 {
    font-size: var(--fs-md);
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

/* --- Tiny (< 360px) --- */
@media (max-width: 360px) {
  .hero h1 {
    font-size: 1.7rem;
  }

  .logo-img {
    height: 42px;
  }

  .month-label {
    font-size: var(--fs-xs);
    min-width: 90px;
  }
}
