/**
 * danceapp.ch – Modern UI (Mobile-First, ergänzt style.css)
 * Admin lädt diese Datei nicht ($includeModernUi aus).
 */

/* Performance: Listen-Bereich erst bei Bedarf layouten (unteres Viewport; nur grobe Höhe nötig) */
.hp-events-grid--modern > .hp-event-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}

/* Sofort sichtbarer heller Untergrund bis das Flyer-Foto geladen ist (Text/Suchbereich bleiben lesbar) */
.hero-fullwidth.modern-hero,
.modern-hero .hero-fullwidth-bg {
  background-color: #ebe7f4;
}

.modern-hero__backdrop {
  background-color: #ebe7f4;
}

/* ---- Mobile zuerst (Standard) ---- */
:root {
  --modern-hero-min-height: 50vh;
  --modern-event-image-height: auto;
}

.modern-hero {
  position: relative;
  overflow: hidden;
  min-height: var(--modern-hero-min-height);
  display: flex;
  flex-direction: column;
}

/* Schichtung: Verlauf → Foto → Scrim → Inhalt */
.hero-fullwidth-bg {
  z-index: 0 !important;
}

.modern-hero .hero-fullwidth-bg {
  opacity: 0.55;
}

/* Mobil: cover + center = kein „Stretch“; kein Zoom (vermeidet seitlichen Overflow) */
.modern-hero__backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: saturate(1.08) contrast(1.03);
  transform: none;
  pointer-events: none;
}

.modern-hero.modern-hero--event-photo .modern-hero__backdrop {
  filter: saturate(1.12) contrast(1.05);
}

/* Lesbarkeit: heller „Film“ über dem Flyer (Titel & Fliesstext nutzen var(--text)) */
.modern-hero__scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    165deg,
    rgba(255, 253, 255, 0.94) 0%,
    rgba(248, 245, 255, 0.82) 38%,
    rgba(235, 231, 244, 0.9) 100%
  );
  pointer-events: none;
}

.modern-hero.modern-hero--event-photo .modern-hero__scrim {
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(245, 241, 252, 0.76) 42%,
    rgba(228, 222, 245, 0.88) 100%
  );
}

[data-theme='dark'] .modern-hero__scrim {
  background: linear-gradient(
    165deg,
    rgba(22, 20, 38, 0.9) 0%,
    rgba(14, 12, 26, 0.78) 48%,
    rgba(18, 16, 32, 0.92) 100%
  );
}

[data-theme='dark'] .modern-hero.modern-hero--event-photo .modern-hero__scrim {
  background: linear-gradient(
    165deg,
    rgba(16, 14, 28, 0.92) 0%,
    rgba(10, 8, 22, 0.82) 45%,
    rgba(14, 12, 26, 0.94) 100%
  );
}

.modern-hero__inner {
  position: relative;
  z-index: 3;
  isolation: isolate;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2.75rem !important;
  padding-bottom: 1.75rem !important;
  padding-left: max(0.75rem, env(safe-area-inset-left)) !important;
  padding-right: max(0.75rem, env(safe-area-inset-right)) !important;
}

.modern-hero .hero-wave {
  position: relative;
  z-index: 4;
  margin-top: auto;
}

.modern-hero__headline-rest {
  font-weight: 800;
}

.modern-hero__region-lead {
  max-width: 40rem;
  margin-top: 0.5rem;
  font-size: 1rem;
  line-height: 1.55;
  opacity: 0.95;
  padding: 0 0.25rem;
}

.modern-hero-search {
  margin: 0.85rem 0 0.25rem;
  width: 100%;
  max-width: 56rem;
  padding: 0 0.25rem;
  box-sizing: border-box;
}

.modern-hero-search--over-image .modern-hero-search__inner {
  background-color: rgba(255, 252, 255, 0.94);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 246, 252, 0.92));
  border: 1px solid rgba(30, 20, 60, 0.12);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  color: var(--text);
}

[data-theme='dark'] .modern-hero-search--over-image .modern-hero-search__inner {
  background-color: rgba(18, 16, 32, 0.92);
  background-image: none;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.modern-hero-search--over-image .modern-hero-search__field label {
  color: var(--text-muted);
  opacity: 1;
}

.modern-hero-search__inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-radius: 1rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.modern-hero-search__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  width: 100%;
  flex: 1 1 auto;
}

.modern-hero-search__field label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.88;
  color: inherit;
}

.modern-hero-search__field input,
.modern-hero-search__field select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border-radius: 0.65rem;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  color: var(--text);
  font-size: 16px;
}

.modern-hero-search__submit {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  align-items: stretch;
  padding-bottom: 0;
}

.modern-hero-search__submit .btn {
  width: 100%;
}

.modern-hero-search-hint {
  margin: 0.35rem 0.25rem 0.45rem;
  font-size: 0.8rem;
  opacity: 0.95;
  max-width: 42rem;
  color: var(--text-muted);
  text-shadow: none;
}

[data-theme='dark'] .modern-hero-search-hint {
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Hero Preview */
.modern-hero-preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
  padding: 0 0.25rem;
  box-sizing: border-box;
}

.modern-hero-preview-card--visual {
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
  border-radius: 1rem !important;
  background: color-mix(in srgb, var(--card) 94%, transparent) !important;
}

.modern-hero-preview-card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  width: 100%;
  min-height: 8rem;
  overflow: hidden;
  background: var(--bg);
}

.modern-hero-preview-card__img {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modern-hero-preview-card__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, transparent 55%);
  pointer-events: none;
}

.modern-hero-preview-card__date {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.modern-hero-preview-card__body {
  padding: 0.65rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}

.modern-hero-preview-card__body strong {
  font-size: 0.95rem;
  line-height: 1.35;
}

.modern-hero-preview-card__body span {
  font-size: 0.8rem;
  opacity: 0.88;
}

.hero-preview-card.modern-hero-preview-card:not(.modern-hero-preview-card--visual) {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.hero-preview-card.modern-hero-preview-card:not(.modern-hero-preview-card--visual):hover {
  transform: translateY(-3px);
}

.modern-hero-preview-card--visual:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

/* Event-Bereich: 1 Spalte mobil */
.container--home-events {
  max-width: min(1240px, 100%);
  padding-left: max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
  box-sizing: border-box;
}

.hp-section--next-events .hp-section-header {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 0.75rem;
  padding: 0 0.125rem;
}

.hp-events-grid--modern {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-top: 8px;
}

/* Bild: volle Breite, Container mit Seitenverhältnis – img mit cover (keine feste Pixelbreite) */
.hp-events-grid--modern .hp-event-card.modern-event-card {
  overflow: hidden;
  border-radius: 1.05rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.hp-events-grid--modern .hp-event-card.modern-event-card .hp-event-img {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
  aspect-ratio: 16 / 10;
  border-radius: 0;
}

.hp-events-grid--modern .hp-event-img-el {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  display: block;
}

.hp-events-grid--modern .hp-event-img::after {
  background: linear-gradient(
    to bottom,
    transparent 22%,
    rgba(0, 0, 0, 0.45) 78%,
    color-mix(in srgb, var(--bg) 96%, transparent) 100%
  );
}

.hp-event-card.modern-event-card {
  border-radius: 1.05rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease;
}

.hp-event-card.modern-event-card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 22px 52px rgba(233, 30, 99, 0.14),
    0 8px 22px rgba(0, 0, 0, 0.12);
}

[data-theme='dark'] .hp-event-card.modern-event-card {
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.45);
}

.modern-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 0.85rem;
  margin-top: 1.1rem;
  padding: 0.65rem 0.25rem 0;
}

.modern-pagination__info {
  font-size: 0.85rem;
  opacity: 0.85;
  text-align: center;
}

.hp-events-pagination {
  border-top: 1px solid var(--border);
}

/* ---- Tablet ab 768px: 2 Spalten, mehr Luft ---- */
@media (min-width: 768px) {
  :root {
    --modern-hero-min-height: clamp(440px, 62vh, 840px);
  }

  .modern-hero__backdrop {
    background-position: center 28%;
    transform: scale(1.03);
  }

  .modern-hero__inner {
    padding-top: 3.25rem !important;
    padding-bottom: 2.5rem !important;
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  .modern-hero-search {
    margin: 1.2rem 0 0.35rem;
    padding: 0;
  }

  .modern-hero-search__inner {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 0.9rem;
    padding: 1rem 1.1rem;
    border-radius: 1.15rem;
  }

  .modern-hero-search__field {
    min-width: 8rem;
    flex: 1 1 9rem;
  }

  .modern-hero-search__submit {
    width: auto;
    align-items: flex-end;
    padding-bottom: 0.12rem;
  }

  .modern-hero-search__submit .btn {
    width: auto;
  }

  .modern-hero-search-hint {
    margin: 0.45rem 0 0.55rem;
    font-size: 0.85rem;
  }

  .modern-hero-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 0;
  }

  .modern-hero-preview-card__body {
    padding: 0.85rem 1rem 1rem;
  }

  .hp-events-grid--modern {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(16px, 2.5vw, 24px);
  }

  .hp-section--next-events .hp-section-header {
    flex-direction: row;
    align-items: flex-end !important;
    justify-content: space-between;
    padding: 0;
  }
}

/* ---- Desktop ab 1024px: 3 Spalten ---- */
@media (min-width: 1024px) {
  :root {
    --modern-hero-min-height: clamp(520px, 72vh, 920px);
  }

  .hp-events-grid--modern {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(18px, 3vw, 28px);
  }

  .modern-hero-preview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }

  /* Etwas höhere Flyer-Fläche auf großen Screens */
  .hp-events-grid--modern .hp-event-card.modern-event-card .hp-event-img {
    aspect-ratio: 16 / 9;
  }
}

/*
 * Mobil (≤767px): „Verzogen“ kommt oft von
 * - animiertem .hero-fullwidth-bg (300% Background + heroGradient)
 * - zu großen clamp()-Überschriften / starken Filtern auf dem Backdrop
 * - Safari + aspect-ratio + absolute img → min-height auf dem Bild-Container
 */
@media (max-width: 767px) {
  .modern-hero {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Adressleiste: dvh/svh statt nur vh (Fallback-Kette) */
    min-height: max(50vh, 260px);
    min-height: max(50dvh, 260px);
    min-height: max(50svh, 260px);
  }

  /* Animierter Vollflächen-Verlauf aus style.css abschalten → ruht das Bild darüber */
  .modern-hero .hero-fullwidth-bg {
    animation: none !important;
    background: linear-gradient(
      145deg,
      rgba(233, 30, 99, 0.14),
      rgba(124, 77, 255, 0.12),
      rgba(68, 138, 255, 0.1)
    ) !important;
    background-size: 100% 100% !important;
    background-position: center center !important;
    opacity: 0.48 !important;
  }

  .modern-hero .hero-fullwidth-bg::after {
    display: none !important;
    animation: none !important;
  }

  /* Foto-Schicht: nur cover + center, kein Filter-Stretching auf schwachen GPUs */
  .modern-hero__backdrop {
    filter: none !important;
    transform: none !important;
    background-size: cover !important;
    background-position: center center !important;
    will-change: auto;
  }

  /* Überschriften aus style.css entschärfen (sonst zu große vw-Werte) */
  .modern-hero .hero-inner h1 {
    font-size: clamp(1.28rem, 5.2vw, 1.95rem) !important;
    letter-spacing: -0.4px !important;
    line-height: 1.2 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .modern-hero .hero-inner h1 .gradient {
    font-size: clamp(1.38rem, 5.8vw, 2.05rem) !important;
  }

  .modern-hero .hero-inner p {
    font-size: 0.92rem !important;
    line-height: 1.45 !important;
    margin-bottom: 1rem !important;
    max-width: 100% !important;
    padding: 0 0.15rem;
  }

  .modern-hero .container.hero-inner {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .hero-preview {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Flyer: Mindesthöhe hilft WebKit bei aspect-ratio + absolute img */
  .hp-events-grid--modern .hp-event-card.modern-event-card .hp-event-img {
    min-height: 11.5rem;
  }

  .modern-hero-preview-card__media {
    min-height: 10rem;
  }
}

/* Kein Hover-Lift auf Touch-Geräten → weniger „Springen“ */
@media (hover: none) and (max-width: 767px) {
  .hp-event-card.modern-event-card:active {
    transform: none;
  }

  .modern-hero-preview-card--visual:active {
    transform: none;
  }
}

/* Reset / Mobile: einspaltiges Event-Raster + Hero-Hintergrund */
@media (max-width: 768px) {
  .event-grid,
  .hp-events-grid,
  .hp-events-grid--modern {
    grid-template-columns: 1fr !important;
  }

  .modern-hero,
  .hero-fullwidth.modern-hero,
  .modern-hero__backdrop {
    background-size: cover !important;
    background-position: center center !important;
  }

  /* Nicht überschreiben: heller Grund bis das Foto da ist */
  .hero-fullwidth.modern-hero,
  .modern-hero__backdrop {
    background-color: #ebe7f4 !important;
  }
}
