/* ============================================================
   Property Detail — Editorial-Layout (Variante)
   Aktiv via <main id="property" class="layout-editorial"> (property_layout).
   Nur die Galerie weicht ab: Hero-Grid (Leitbild links + 2×2 rechts) statt Slider,
   wahlweise full-bleed (property_gallery=grid|grid-full). Der restliche Body erbt
   das classic-Markup/-CSS (pages/property.css).
   Alles hier streng auf #property.layout-editorial gescoped.
   ============================================================ */

/* --- Hero-Grid (property_gallery = 'grid' / 'grid-full'): Leitbild links + 2×2 rechts.
   Feste Höhen-Bandbreite (kein Aspect-Ratio) → auf breiten/full-bleed Screens nicht zu hoch. */
#property.layout-editorial .hero-grid {
  display: grid;
  gap: var(--space-2);
  height: var(--property-grid-height);
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* Full-bleed-Variante: gesamte Galerie über die volle Viewport-Breite.
   100vw zählt die Scrollbar mit → die Galerie ragte je eine halbe Scrollbar-Breite (Windows ~7px) links und
   rechts über den Rand hinaus (abgeschnitten via body overflow-x: clip) und die Badges links standen um diesen
   Betrag weiter außen als der Topbar-Text. Deshalb: body nur auf DIESER Seite als Container, Breite in cqw
   (= Seitenbreite ohne Scrollbar). 100vw bleibt als Fallback für Browser ohne :has()/Container-Einheiten. */
body:has(#property.layout-editorial > .gallery-full) {
  container-type: inline-size;
}
#property.layout-editorial .gallery-full {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  width: 100cqw;
  margin-inline: calc(50% - 50cqw);
}

/* Runde Ecken + randlos (Dirk 30.10.2026: „Wenn die Bilder auf runde Ecken eingestellt sind, sollten die Bilder immer etwas Abstand
   zum Rand haben, gleiche Größe wie die Innenabstände“): Kern-Regel ohne Schalter — mit Eckenradius (Design-Token --radius > 0)
   bekommt die randlose Galerie links/rechts den Fugen-Abstand der Kacheln (--space-2); eckig (0) bleibt sie bis an den Rand.
   --galerie-radius ist als Länge registriert: so wird auch ein einheitenloses „0“ (Tier basic, 99-theme, Design-Editor) zu 0px
   und die Rechnung bleibt gültig. Radius > 0,08px → voller Abstand. */
@property --galerie-radius {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
#property.layout-editorial .gallery-full {
  --galerie-radius: var(--radius);
  --galerie-rand: min(var(--space-2), calc(var(--galerie-radius) * 100));
  padding-inline: var(--galerie-rand);
  /* Badges IM Leitbild stehen relativ zur Kachel, die jetzt um den Rand nach innen rückt → abziehen, damit sie weiter mit
     dem Text der Kontaktleiste fluchten (die Status-Marke steht relativ zur Galerie und braucht das nicht). */
  --lead-badge-kachel: calc(var(--lead-badge-inset) - var(--galerie-rand));
}
#property.layout-editorial .gallery-full .lead {
  --lead-badge-inset: var(--lead-badge-kachel);
}

#property.layout-editorial .hero-grid > a {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--color-bg-alt);
}

#property.layout-editorial .hero-grid .lead {
  grid-column: 1;
  grid-row: 1 / 3;
}

#property.layout-editorial .hero-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-slow);
}

#property.layout-editorial .hero-grid > a:hover img {
  transform: scale(1.03);
}

/* Degradation nach Kachelzahl (data-count = gerenderte Kacheln) */
#property.layout-editorial .hero-grid[data-count="1"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
#property.layout-editorial .hero-grid[data-count="1"] .lead { grid-row: 1; }

#property.layout-editorial .hero-grid[data-count="2"] {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr;
}
#property.layout-editorial .hero-grid[data-count="2"] .lead { grid-row: 1; }

#property.layout-editorial .hero-grid[data-count="3"] {
  grid-template-columns: 2fr 1fr;
}

#property.layout-editorial .hero-grid[data-count="4"] {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: repeat(3, 1fr);
}
#property.layout-editorial .hero-grid[data-count="4"] .lead { grid-row: 1 / 4; }

/* "Alle Fotos"-Overlay auf der letzten Kachel */
#property.layout-editorial .gallery-all-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--scrim-heavy);
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  /* Icon über dem Text, beides zentriert; mehrzeiliger Label-Text mittig. */
  text-align: center;
}

/* --- Badges unten links auf dem Leitbild: dieselben Bausteine wie auf der Kachel
   (PropertyCard::image_badges → .media-badges [.media-hints Solar/Internet + .media-counts] / .energy-mini), nur größer.
   Energie + Solar bilden die Zeile ÜBER den Medien-Zählern; deren Höhe steht wie auf der
   Kachel in EINER Variablen (--lead-badge-bottom), s. Begründung in property-card.css.
   Farben der Energieklassen kommen global aus pages/property.css (.energy-mini[data-class]). */
#property.layout-editorial > .gallery {
  --lead-badge-inset: var(--space-3);
}

/* Brotkrumen stehen beim Editorial-Layout UNTER der Galerie (FrontendView::breadcrumb_after_gallery, Dirk 27.10.2026)
   — mit Abstand zum Bild; der Abstand nach unten kommt aus components/breadcrumb.css. Gilt auch, wenn die Seitenleiste
   den Inhalt in .page-body einpackt. */
#property.layout-editorial .gallery + nav.breadcrumb {
  margin-block-start: var(--space-5);
}
/* Full-bleed (property_gallery = 'grid-full'): Das Leitbild beginnt am Viewport-Rand. Die Badges links
   (Status oben, Energie/Solar/Medien unten) fluchten mit dem Text der Topbar ganz oben — gleicher
   Randabstand wie #topbar (04-layout.css: --padding-page; unter 79.5rem --space-4, components/header.css;
   Pro-Tier links weiter --padding-page, components/service-nav.css). Ändert sich dort der Abstand,
   hier mitziehen. */
#property.layout-editorial > .gallery-full {
  --lead-badge-inset: var(--padding-page);
}
@media (max-width: 73.999rem), (max-width: 79.499rem) and (orientation: portrait) {
  #property.layout-editorial > .gallery-full {
    --lead-badge-inset: var(--space-4);
  }
}
/* Pro: Topbar links wieder --padding-page (Query wortgleich zu components/service-nav.css). */
@media (min-width: 79.5rem),
       (min-width: 45rem) and (orientation: landscape) {
  [data-tier="pro"] #property.layout-editorial > .gallery-full {
    --lead-badge-inset: var(--padding-page);
  }
}
#property.layout-editorial .hero-grid .lead {
  --lead-badge-bottom: calc(var(--space-3) + 2.75rem);
}

/* Status-Badge oben links (Verkauft, Dachterrasse …) auf DENSELBEN Randabstand wie die Badges unten links.
   Es erbt sonst die Kachel-Regel aus property-card.css (--space-2 = 8px), unten stehen hier --space-3 (12px) —
   das obere wirkte gegenüber den unteren verrutscht (Nutzerhinweis 30.09.2026). */
#property.layout-editorial > .gallery > mark {
  top: var(--space-3);
  left: var(--lead-badge-inset);
}

#property.layout-editorial .lead .media-badges {
  position: absolute;
  bottom: var(--space-3);
  left: var(--lead-badge-inset);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  --mb-gap: var(--space-3);
  --mb-pad: var(--space-2) var(--space-3);
  gap: var(--mb-gap);
  padding: var(--mb-pad);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-inverse);
  background: var(--scrim-medium);
  border-radius: var(--radius);
}

#property.layout-editorial .lead .energy-mini {
  position: absolute;
  left: var(--lead-badge-inset);
  bottom: var(--lead-badge-bottom);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
}

#property.layout-editorial .lead .energy-mini {
  min-width: 2.25rem;
  padding: 0 var(--space-3);
  padding-inline-end: calc(var(--space-3) + 0.625rem);
  font-size: var(--text-base);
  font-weight: 700;
  clip-path: polygon(0 0, calc(100% - 0.625rem) 0, 100% 50%, calc(100% - 0.625rem) 100%, 0 100%);
}

/* Solar/Internet (20.11.2026, Dirk: „in die untere Reihe als neue Gruppe links neben den Icons“ / „zwei getrennte inline Blöcke“):
   zwei eigene, GLEICH HOHE dunkle Kästchen nebeneinander — erst .media-counts (Zähler), dann .media-hints (Sonne, Globus); einfarbig
   wie die Zähler. Maße je Stufe aus --mb-pad/--mb-gap der Leiste, die selbst dann nur noch Halter ohne Hintergrund ist. */
#property.layout-editorial .lead .media-badges:has(.media-hints) {
  align-items: stretch;   /* beide Kästchen so hoch wie das höhere (Zähler mit Schriftzeile) */
  padding: 0;
  gap: var(--space-2);
  background: none;
}
#property.layout-editorial .lead .media-badges > :is(.media-hints, .media-counts) {
  display: inline-flex;
  align-items: center;
  gap: var(--mb-gap);
  padding: var(--mb-pad);
  background: var(--scrim-medium);
  border-radius: var(--radius);
}
#property.layout-editorial .lead .media-hint { display: inline-flex; }
/* Zähler einzeln mit Trennstrich (Dirk 20.11.2026) — Regel wie components/property-card.css, hier abgesichert, falls die Seite die Kachel-CSS nicht lädt. */
#property.layout-editorial .lead .media-count {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}
#property.layout-editorial .lead .media-count + .media-count {
  padding-inline-start: var(--mb-gap);
  border-inline-start: 1px solid color-mix(in srgb, var(--color-text-inverse) 35%, transparent);
}
/* Feiner Trennstrich zwischen Sonne und Globus (Dirk 20.11.2026); Abstand davor = gap, dahinter gleich viel Innenabstand. */
#property.layout-editorial .lead .media-hint + .media-hint {
  padding-inline-start: var(--mb-gap);
  border-inline-start: 1px solid color-mix(in srgb, var(--color-text-inverse) 35%, transparent);
}

/* Handy: Badges in Kachelgröße und nah am Bildrand — die großen Desktop-Maße nahmen am Handy ein
   Viertel des Leitbilds ein (Nutzerhinweis ips.saarland 01.10.2026). Werte 1:1 aus
   components/property-card.css; ändern sich die dort, hier mitziehen. Icons 14px wie auf der Kachel
   (PHP liefert 18px, die CSS-Größe gewinnt gegen das width/height-Attribut). */
@media (max-width: 44.999rem) {
  #property.layout-editorial > .gallery,
  #property.layout-editorial > .gallery-full {
    --lead-badge-inset: var(--space-2);
  }
  #property.layout-editorial > .gallery > mark {
    top: var(--space-2);
  }
  #property.layout-editorial .hero-grid .lead {
    --lead-badge-bottom: calc(var(--space-2) + 2rem);
  }
  #property.layout-editorial .lead .media-badges {
    bottom: var(--space-2);
    --mb-gap: var(--space-2);
    --mb-pad: var(--space-1) var(--space-2);
    gap: var(--mb-gap);
    padding: var(--mb-pad);
    font-size: var(--text-xs);
  }
  #property.layout-editorial .lead .media-badges svg {
    width: 14px;
    height: 14px;
  }
  #property.layout-editorial .lead .energy-mini {
    height: 1.75rem;
  }
  #property.layout-editorial .lead .energy-mini {
    min-width: 1.75rem;
    padding: 0 var(--space-2);
    padding-inline-end: calc(var(--space-2) + 0.5rem);
    font-size: var(--text-sm);
    clip-path: polygon(0 0, calc(100% - 0.5rem) 0, 100% 50%, calc(100% - 0.5rem) 100%, 0 100%);
  }
  #property.layout-editorial .lead .media-hint svg {
    width: 14px;
    height: 14px;
  }
}

/* Tablet: Zwischenstufe zwischen Handy und Desktop — die Desktop-Maße wirkten auf dem Tablet zu wuchtig
   (Nutzerhinweis 08.10.2026). Plakette 32px statt 36/28, Schrift text-sm, Icons 16px. */
@media (min-width: 45rem) and (max-width: 73.999rem), (min-width: 45rem) and (max-width: 79.499rem) and (orientation: portrait) {
  #property.layout-editorial .hero-grid .lead {
    --lead-badge-bottom: calc(var(--space-3) + 2.25rem);
  }
  #property.layout-editorial .lead .media-badges {
    --mb-gap: var(--space-2);
    --mb-pad: var(--space-1) var(--space-2);
    gap: var(--mb-gap);
    padding: var(--mb-pad);
    font-size: var(--text-sm);
  }
  #property.layout-editorial .lead .media-badges svg {
    width: 16px;
    height: 16px;
  }
  #property.layout-editorial .lead .energy-mini {
    height: 2rem;
  }
  #property.layout-editorial .lead .energy-mini {
    min-width: 2rem;
    padding: 0 var(--space-2);
    padding-inline-end: calc(var(--space-2) + 0.5625rem);
    font-size: var(--text-sm);
    clip-path: polygon(0 0, calc(100% - 0.5625rem) 0, 100% 50%, calc(100% - 0.5625rem) 100%, 0 100%);
  }
  #property.layout-editorial .lead .media-hint svg {
    width: 16px;
    height: 16px;
  }
}

/* Mobile: Leitbild voll oben, Kacheln als 2er-Grid darunter.
   ⚠ Selektoren mit [data-count]: Die Degradations-Regeln oben (.hero-grid[data-count="3"] → 2fr 1fr,
   [data-count="4"] .lead → grid-row 1/4) sind spezifischer als ein schlichtes .hero-grid und gewannen
   sonst auch am Handy — die rechte Kachel war dann nur halb so breit und (4:3) halb so hoch wie die
   linke (gemeldet 07.10.2026). */
@media (max-width: 59.999rem) {
  #property.layout-editorial .hero-grid,
  #property.layout-editorial .hero-grid[data-count] {
    height: auto;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: none;
  }
  #property.layout-editorial .hero-grid .lead,
  #property.layout-editorial .hero-grid[data-count] .lead {
    grid-column: 1 / 3;
    grid-row: auto;
    aspect-ratio: var(--property-hero-aspect);
  }
  #property.layout-editorial .hero-grid > a:not(.lead) {
    aspect-ratio: 4 / 3;
  }
  /* Bleibt eine Kachel allein in der letzten Reihe (2 oder 4 Fotos), nimmt sie die volle Breite
     statt einer leeren Hälfte daneben. Kind 1 ist das Leitbild → allein steht sie bei gerader Position. */
  #property.layout-editorial .hero-grid > a:not(.lead):nth-child(even):last-child {
    grid-column: 1 / 3;
    aspect-ratio: var(--property-hero-aspect);
  }
}

/* ============================================================
   Phase B.2 — Editorial Content-Restyle (rein CSS)
   ============================================================ */

/* --- Typografie: großer, ruhiger Titel + prominenter Preis --- */
#property.layout-editorial article > header h1 {
  font-size: var(--text-4xl);
  line-height: var(--leading-tight);
  margin-block-end: var(--space-4);
}

#property.layout-editorial article > section.price > h2 {
  font-size: var(--text-3xl);
  line-height: var(--leading-heading);
}

/* Mehr Luft zwischen den Inhalts-Sektionen (Editorial-Rhythmus). */
#property.layout-editorial article > section {
  margin-block-end: var(--gap-section);
}

/* --- 2-Spalten ab Desktop: Inhalt + sticky Kontakt-Aside --- */
@media (min-width: 64rem) {
  /* Aside exakt so breit wie EINE Hero-Spalte: dann fluchtet ihre linke Kante mit der
     Fuge zwischen den beiden rechten Bildkacheln — und ihre rechte Kante ohnehin.

     Warum gerechnet statt fest: Das Hero-Raster ist proportional (2fr 1fr 1fr = 4 Einheiten
     + 2 Gaps), eine feste Aside-Breite trifft es nur bei genau EINER Fensterbreite. Die
     vorherigen 22rem passten bei ~1440px; bei der gedeckelten Seitenbreite (95rem = 1520px)
     war die Aside 24px zu schmal, darunter zu breit. Ändert sich --space-2 (Hero-Gap) oder
     das Spaltenverhältnis, muss der Divisor hier mitgezogen werden.

     Untergrenze --sidebar-width (= classic-Aside): Das Editorial-Grid startet schon bei
     64rem, dort wäre die gerechnete Spalte nur ~15.75rem und würde die Kontaktkarte
     quetschen. Bis ~89rem gewinnt also die Untergrenze (kein Fluchten, aber benutzbar),
     darüber die Rasterbindung. */
  #property.layout-editorial .content {
    display: grid;
    grid-template-columns:
      minmax(0, 1fr)
      max(var(--sidebar-width), calc((100% - 2 * var(--space-2)) / 4));
    gap: var(--gap-section);
    align-items: start;
  }

  /* Kontakt/Aktionen bleiben beim Scrollen sichtbar. --sticky-offset wird von
     header.js mit der echten Header-Höhe befüllt (wie bei der Preis-Section). */
  #property.layout-editorial .content > aside {
    position: sticky;
    top: calc(var(--sticky-offset, 0px) + var(--space-5));
    /* Aside steht ab hier NEBEN dem Content (eine Hero-Spalte breit) → wieder einspaltig. Hebt die
       geteilte Tablet-2-Spalten-Regel (property-aside.css, bis 79.5rem) auf, deren
       Bereich sich sonst mit diesem früheren Editorial-Grid (64rem) überschneidet
       und die schmale Aside fälschlich zweispaltig quetscht. */
    flex-direction: column;
    flex-wrap: nowrap;
  }
  #property.layout-editorial .content > aside > section {
    flex: 0 1 auto;
  }
}
