/* ================================
   EBZ Topic Grid
   Quadratische Kacheln, kontrollierte Maximalgröße

   Builder-Logik:
   - Row bekommt Klasse: ebz-topic-grid
   - Optional für 5-Spalten-Variante: grid-5
   - Optional für weißen Innenrahmen / Hoverlogik: kachel-container

   Verwendung im Divi-Klassenfeld, Beispiel:
   ebz-topic-grid kachel-container grid-5

   Kachel-Klassen auf Columns:
   - Normale Kachel: keine Zusatzklasse
   - Manuelle 2-Spalten-Kachel: kachel-span-2
   - Manuelle 3-Spalten-Kachel: kachel-span-3
   - Manuelle 4-Spalten-Kachel: kachel-span-4
   - Automatische 2-Spalten-Kachel per JS: is-wide

   Wichtig:
   - .grid-5 ist nur eine Grid-Variante und ändert die Spaltenlogik.
   - Die Grundstruktur bleibt immer auf .ebz-topic-grid.
   - .is-wide wird wie .kachel-span-2 behandelt.
   - grid-auto-flow: dense füllt passende Lücken mit nachfolgenden Kacheln.
================================ */


/* ================================
   EBZ Topic Grid
   Grundstruktur
================================ */

.ebz-topic-grid {
  display: grid !important;
  gap: 0 !important;
  grid-auto-flow: dense !important;

  /* Standard: 4 Spalten */
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;

  width: calc(100% - 40px) !important;
  max-width: 1800px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  margin-inline: auto !important;

  grid-auto-rows: auto !important;
  align-items: start !important;
}


/* 5-Spalten-Variante */
.ebz-topic-grid.grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  max-width: 1800px !important;
}



/* ================================
   EBZ Topic Grid
   Kachel-Grundformat
================================ */

/* Optionaler weißer Innenrahmen für Kachel-Container */
.kachel-container > .et_pb_column {
  box-shadow: inset 0 0 0 1px #ffffff;
}


/* Alle direkten Kacheln im Grid */
.ebz-topic-grid > .et_pb_column {
  width: auto !important;
  max-width: none !important;

  height: auto !important;
  min-height: 0 !important;

  margin: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;

  /*
    Wichtig für Divi:
    Divi setzt Columns je nach Breakpoint teils auf float/width.
    Im CSS Grid müssen die Columns aber echte Grid-Items bleiben.
  */
  float: none !important;
  clear: none !important;

  box-shadow: inset 0 0 0 1px #ffffff;

  /* Normale Kacheln sind quadratisch */
  aspect-ratio: 1 / 1 !important;

  padding: clamp(24px, 2vw, 40px) !important;

  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  align-items: flex-start !important;

  overflow: hidden !important;

  /*
    Für leere Bild-Columns mit Hintergrundbild.
    Das Bild wird direkt im Divi Builder auf die Column gesetzt.
  */
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}



/* ================================
   EBZ Topic Grid
   Span-Klassen
================================ */

/* 2 Spalten breite Kachel – manuell */
.ebz-topic-grid > .et_pb_column.kachel-span-2 {
  grid-column: span 2 !important;
  grid-row: span 1 !important;
  aspect-ratio: 2 / 1 !important;
}


/* 2 Spalten breite Kachel – automatisch per JS */
.ebz-topic-grid > .et_pb_column.is-wide {
  grid-column: span 2 !important;
  grid-row: span 1 !important;
  aspect-ratio: 2 / 1 !important;
}


/* 3 Spalten breite Kachel */
.ebz-topic-grid > .et_pb_column.kachel-span-3 {
  grid-column: span 3 !important;
  grid-row: span 1 !important;
  aspect-ratio: 3 / 1 !important;
}


/* 4 Spalten breite Kachel */
.ebz-topic-grid > .et_pb_column.kachel-span-4 {
  grid-column: span 4 !important;
  grid-row: span 1 !important;
  aspect-ratio: 4 / 1 !important;
}



/* ================================
   EBZ Topic Grid
   Divi-Modul- und Textabstände neutralisieren
================================ */

/* Divi-Modul-Abstände innerhalb der Grid-Kacheln neutralisieren */
.ebz-topic-grid > .et_pb_column > .et_pb_module {
  margin-bottom: 0 !important;
}


/* Textabstände innerhalb der Grid-Kacheln neutralisieren */
.ebz-topic-grid .et_pb_text,
.ebz-topic-grid .et_pb_text_inner,
.ebz-topic-grid .et_pb_text_inner p,
.ebz-topic-grid h1,
.ebz-topic-grid h2,
.ebz-topic-grid h3,
.ebz-topic-grid h4 {
  margin: 0 !important;
}



/* ================================
   EBZ Topic Grid
   Typografie
================================ */

/* Headlines in normalen 4er-Kacheln */
.ebz-topic-grid h2,
.ebz-topic-grid h3,
.ebz-topic-grid h4,
.ebz-topic-grid .hero-h3,
.ebz-topic-grid .et_pb_module_header {
  font-size: clamp(1.6rem, 1.05rem + 1.3vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}


/*
  Headlines in 5er-Kacheln.
  Maximal 1.8rem, line-height 1.1.
  Mindestgröße bewusst höher, damit h3 mobil nicht kleiner als Fließtext wirkt.
*/
.ebz-topic-grid.grid-5 h2,
.ebz-topic-grid.grid-5 h3,
.ebz-topic-grid.grid-5 h4,
.ebz-topic-grid.grid-5 .hero-h3,
.ebz-topic-grid.grid-5 .et_pb_module_header {
  font-size: clamp(1.35rem, 1.05rem + 0.75vw, 1.8rem) !important;
  line-height: 1.1 !important;
  letter-spacing: -0.03em;
}


/* Claims / Fließtext in normalen Kacheln */
.ebz-topic-grid p {
  font-size: clamp(1rem, 0.85rem + 0.35vw, 1.2rem);
  line-height: 1.25;
}


/* Claims / Meta-Text in 5er-Kacheln */
.ebz-topic-grid.grid-5 p {
  font-size: clamp(0.9rem, 0.82rem + 0.25vw, 1.05rem);
  line-height: 1.25;
}



/* ================================
   EBZ Topic Grid
   Silbentrennung für dynamische Kurs-/Topic-Titel

   Wichtig:
   - Für saubere deutsche Silbentrennung muss im HTML lang="de" gesetzt sein.
   - Kein word-break: break-all verwenden.
   - text-wrap: pretty ist ruhiger als balance.
================================ */

.ebz-course-card h1,
.ebz-course-card h2,
.ebz-course-card h3,
.ebz-course-card h4,
.ebz-course-card .et_pb_module_header,
.ebz-course-card .ebz-course-title,
.at-ebz-course-card h1,
.at-ebz-course-card h2,
.at-ebz-course-card h3,
.at-ebz-course-card h4,
.at-ebz-course-card .et_pb_module_header,
.at-ebz-course-card .ebz-course-title,
.et-ebz-course-card h1,
.et-ebz-course-card h2,
.et-ebz-course-card h3,
.et-ebz-course-card h4,
.et-ebz-course-card .et_pb_module_header,
.et-ebz-course-card .ebz-course-title,
.ebz-topic-grid h1,
.ebz-topic-grid h2,
.ebz-topic-grid h3,
.ebz-topic-grid h4,
.ebz-topic-grid .et_pb_module_header {
  hyphens: auto;
  -webkit-hyphens: auto;

  overflow-wrap: normal;
  word-break: normal;

  text-wrap: pretty;
}



/* ================================
   EBZ Topic Grid
   Breakpoint: Standard-Grid

   Ab 1600px:
   - Normales 4er-Grid wird auf 2 Spalten reduziert.
   - 5er-Grid bleibt hier ausdrücklich 5 Spalten.
================================ */

@media (max-width: 1600px) {
  .ebz-topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-width: 900px !important;
  }

  /*
    5er-Grid wieder zurück auf 5 Spalten setzen.
    Diese Regel muss innerhalb des 1600er Breakpoints nach .ebz-topic-grid stehen.
  */
  .ebz-topic-grid.grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    max-width: 1800px !important;
  }

  /*
    Im normalen 2-Spalten-Grid werden alle breiten Kacheln maximal 2 Spalten breit.
  */
  .ebz-topic-grid > .et_pb_column.kachel-span-2,
  .ebz-topic-grid > .et_pb_column.is-wide,
  .ebz-topic-grid > .et_pb_column.kachel-span-3,
  .ebz-topic-grid > .et_pb_column.kachel-span-4 {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
    aspect-ratio: 2 / 1 !important;
  }

  /*
    Im 5er-Grid bleiben die Span-Klassen bei diesem Breakpoint erhalten.
  */
  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-2,
  .ebz-topic-grid.grid-5 > .et_pb_column.is-wide {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
    aspect-ratio: 2 / 1 !important;
  }

  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-3 {
    grid-column: span 3 !important;
    grid-row: span 1 !important;
    aspect-ratio: 3 / 1 !important;
  }

  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-4 {
    grid-column: span 4 !important;
    grid-row: span 1 !important;
    aspect-ratio: 4 / 1 !important;
  }
}



/* ================================
   EBZ Topic Grid
   Breakpoint: 5er-Grid

   Ab 1200px:
   - 5er-Grid wird auf 2 Spalten reduziert.
================================ */

@media (max-width: 1200px) {
  .ebz-topic-grid.grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-width: 900px !important;
  }

  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-2,
  .ebz-topic-grid.grid-5 > .et_pb_column.is-wide,
  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-3,
  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-4 {
    grid-column: span 2 !important;
    grid-row: span 1 !important;
    aspect-ratio: 2 / 1 !important;
  }
}



/* ================================
   EBZ Topic Grid
   Finaler Mobile Override

   Ab 880px:
   - Alle Topic-Grids werden einspaltig.
   - Alle Kacheln laufen über volle Grid-Breite.
   - aspect-ratio wird deaktiviert.
   - Divi-Column-Breiten/Floats werden überschrieben.

   Dieser Block muss nach allen anderen Grid-Breakpoints stehen.
================================ */

@media (max-width: 880px) {
  .ebz-topic-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;

    width: calc(100% - 32px) !important;
    max-width: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-inline: auto !important;
  }

  .ebz-topic-grid.grid-5 {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;

    width: calc(100% - 32px) !important;
    max-width: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-inline: auto !important;
  }

  .ebz-topic-grid > .et_pb_column,
  .ebz-topic-grid > .et_pb_column.kachel-span-2,
  .ebz-topic-grid > .et_pb_column.is-wide,
  .ebz-topic-grid > .et_pb_column.kachel-span-3,
  .ebz-topic-grid > .et_pb_column.kachel-span-4 {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;

    width: 100% !important;
    max-width: none !important;

    float: none !important;
    clear: none !important;

    aspect-ratio: auto !important;
    min-height: clamp(220px, 42vw, 320px) !important;
  }

  .ebz-topic-grid.grid-5 > .et_pb_column,
  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-2,
  .ebz-topic-grid.grid-5 > .et_pb_column.is-wide,
  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-3,
  .ebz-topic-grid.grid-5 > .et_pb_column.kachel-span-4 {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;

    width: 100% !important;
    max-width: none !important;

    float: none !important;
    clear: none !important;

    aspect-ratio: auto !important;
    min-height: clamp(220px, 42vw, 320px) !important;
  }

  .ebz-topic-grid.grid-5 h2,
  .ebz-topic-grid.grid-5 h3,
  .ebz-topic-grid.grid-5 h4,
  .ebz-topic-grid.grid-5 .hero-h3,
  .ebz-topic-grid.grid-5 .et_pb_module_header {
    font-size: clamp(1.45rem, 5vw, 1.8rem) !important;
    line-height: 1.1 !important;
  }

  .ebz-topic-grid.grid-5 p {
    font-size: clamp(0.95rem, 3.6vw, 1.05rem) !important;
  }
}



/* ================================
   EBZ Kachel Hover
   Background Slide-In für klickbare Kacheln

   Container-Klasse auf Row:
   - kachel-container

   Zweck:
   - Einheitlicher Hover-Slide auf klickbaren Kacheln.
   - Overlay überschreibt keine Hintergrundbilder.
================================ */

.kachel-container .et_clickable {
  position: relative !important;
  overflow: hidden !important;
  cursor: pointer;
  isolation: isolate;
}


/* Hover-Fläche als Overlay, damit Hintergrundbilder nicht überschrieben werden */
.kachel-container .et_clickable::before {
  content: "";
  position: absolute;
  inset: 0;

  background: rgba(214, 214, 214, 0.28);

  transform: scaleX(0);
  transform-origin: left center;

  transition: transform 0.6s ease;

  pointer-events: none;
  z-index: 1;
}


/* Hover aktiviert den Slide-In */
.kachel-container .et_clickable:hover::before {
  transform: scaleX(1);
}


/* Inhalte über dem Hover-Overlay halten */
.kachel-container .et_clickable > * {
  position: relative;
  z-index: 2;
}