/* Drehbare Explosionsansicht («Im Haus zeigen»): Einstiege (Karte, Grundriss-Dialog, Wohnungsseite, Flugende) und der
   Vollbild-Dialog (scripts/explosion.js). Die Markierung nutzt das Gold der CTA aus tokens.css. */

:root {
  /* White outlines over the image: every unit, its floor and hover/focus (the chosen unit takes --color-cta). */
  --explosion-line: rgb(255 255 255 / 55%);
  --explosion-line-strong: rgb(255 255 255 / 60%);
  --explosion-floor-fill: rgb(255 255 255 / 16%);
  --explosion-hover-fill: rgb(255 255 255 / 24%);
  /* A chosen floor: the other units under a dark veil, so the floor reads on the light model too. */
  --explosion-veil: rgb(23 56 61 / 45%);
}

/* Entries carry «hidden» until the module runs; their own display rules must not show them before. */
.explosion-open[hidden] {
  display: none;
}
.unit-card__haus {
  padding: 0;
  border: 0;
  color: var(--color-ink);
  background: transparent;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.explosion-open--flug {
  display: flex;
  width: fit-content;
  margin-top: var(--space-sm);
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.dialog--detail .detail-info .explosion-open--detail {
  /* Own line below the primary CTA, like the 360° entry (hidden stays hidden through .dialog [hidden]). */
  display: flex;
  width: fit-content;
  margin-top: var(--space-xs);
}

/* Dialog frame: full dynamic viewport, page scroll locked while open. */
html:has(.dialog--explosion[open]) {
  overflow: hidden;
}
.dialog.dialog--explosion {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  color: var(--color-ink);
  background: var(--color-ink);
  overscroll-behavior: contain;
}
.dialog--explosion[open] {
  animation: explosion-ein 400ms ease-out;
}
@keyframes explosion-ein {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Overlays in a grid above the image; the grid itself lets pointers through to the stage. */
.explosion {
  --explosion-edge: var(--space-sm);
  position: relative;
  display: grid;
  grid-template-areas:
    "info . close"
    ". . floors"
    "links . rechts"
    "card . ganz";
  grid-template-columns: minmax(0, 25rem) 1fr auto;
  grid-template-rows: auto auto 1fr auto;
  gap: var(--space-xs);
  width: 100%;
  height: 100%;
  padding:
    calc(var(--explosion-edge) + env(safe-area-inset-top))
    calc(var(--explosion-edge) + env(safe-area-inset-right))
    calc(var(--explosion-edge) + env(safe-area-inset-bottom))
    calc(var(--explosion-edge) + env(safe-area-inset-left));
  pointer-events: none;
}
.explosion > * {
  z-index: 1;
  pointer-events: auto;
}
.explosion__stage,
.explosion__fallback {
  position: absolute;
  z-index: 0;
  inset: 0;
}
.explosion__stage {
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.explosion__stage.is-dragging {
  cursor: grabbing;
}
.explosion__stage.is-over-unit {
  cursor: pointer;
}
.explosion__bild,
.explosion__flaechen,
.explosion__fallback-bild,
.explosion__fallback-spots {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.explosion__flaechen {
  overflow: visible;
  pointer-events: none;
}

/* Unit outlines: every visible unit faintly, its floor brighter, hover/focus white, the chosen one in CTA gold. */
.explosion__flaeche,
.explosion__glow {
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}
.explosion__flaeche {
  fill: transparent;
  stroke: var(--explosion-line);
  stroke-width: 1;
  transition: fill var(--duration), stroke var(--duration);
}
.explosion__flaeche.is-floor {
  fill: var(--explosion-floor-fill);
  stroke: var(--color-white);
  stroke-width: 2;
}
.is-floor-mode .explosion__flaeche:not(.is-floor, .is-hover) {
  fill: var(--explosion-veil);
  stroke: transparent;
}
.explosion__flaeche.is-hover {
  fill: var(--explosion-hover-fill);
  stroke: var(--color-white);
  stroke-width: 2;
}
.explosion__flaeche.is-selected {
  fill: var(--color-highlight-faint);
  stroke: var(--color-cta);
  stroke-width: 3;
}
.explosion__glow {
  fill: none;
  stroke: var(--color-highlight-soft);
  stroke-width: 11;
}

.dialog--explosion :is(button, a):focus-visible {
  outline: 3px solid var(--color-white);
  outline-offset: 2px;
  box-shadow: 0 0 0 7px var(--color-ink);
}
.explosion__stage:focus-visible {
  outline: 3px solid var(--color-white);
  outline-offset: -6px;
}

/* Title and label */
.explosion__info,
.explosion__floors,
.explosion__card,
.explosion__close,
.explosion__ganz,
.explosion__turn,
.explosion__status {
  border-radius: var(--radius);
  background: var(--color-panel);
  box-shadow: var(--shadow-overlay);
}
.explosion__info {
  grid-area: info;
  align-self: start;
  justify-self: start;
  padding: 0.75rem 1rem;
}
.dialog--explosion .explosion__title {
  /* .dialog h2 sets the large dialog heading; the view keeps a compact overlay title. */
  margin: 0;
  font-size: clamp(1.25rem, 1rem + 0.6vw, 1.625rem);
  letter-spacing: -0.02em;
}
.explosion__title:focus,
.explosion__unit-title:focus {
  outline: none;
}
.explosion__note {
  margin: 0.3rem 0 0;
  color: var(--color-muted);
  font-size: var(--text-min);
}
.explosion__test {
  color: var(--color-accent);
  font-weight: 700;
}
.explosion__close {
  display: flex;
  grid-area: close;
  align-self: start;
  justify-self: end;
  min-height: 44px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 1rem;
  border: 0;
  color: var(--color-ink);
  font: 600 var(--text-min) / 1 var(--font-body);
  cursor: pointer;
}
.explosion__close span {
  font-size: 1.5rem;
  font-weight: 400;
}
/* «Ganzes Haus»: back to 1×, only while zoomed in. */
.explosion__ganz {
  grid-area: ganz;
  align-self: end;
  justify-self: end;
  min-height: 44px;
  padding: 0.25rem 1rem;
  border: 0;
  color: var(--color-ink);
  font: 600 var(--text-min) / 1 var(--font-body);
  cursor: pointer;
}
.explosion__status {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 0.75rem 1rem;
  transform: translate(-50%, -50%);
}
.explosion__status:empty,
:is([data-explosion-state="loaded"], [data-explosion-state="fallback"]) .explosion__status {
  /* stays a live region for screen readers, invisible on screen */
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 0;
  box-shadow: none;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Floor bar: top to bottom like the house (landscape), one row of short names in portrait. */
.explosion__floors {
  display: grid;
  grid-area: floors;
  align-self: start;
  justify-self: end;
  gap: 0.25rem;
  padding: 0.3rem;
}
.explosion__floors button {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: var(--radius);
  color: var(--color-ink);
  background: transparent;
  font: 600 var(--text-min) / 1.2 var(--font-body);
  text-align: left;
  cursor: pointer;
}
.explosion__floors button:hover {
  background: var(--color-sage);
}
.explosion__floors button[aria-pressed="true"] {
  color: var(--color-white);
  background: var(--color-accent);
}
.explosion__floor-short {
  display: none;
}

/* Turning buttons at the left and right edge, vertically centred. */
.explosion__turn {
  display: flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  align-self: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--color-ink);
  cursor: pointer;
}
.explosion__turn--links {
  grid-area: links;
  justify-self: start;
}
.explosion__turn--rechts {
  grid-area: rechts;
  justify-self: end;
}
.explosion__turn svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:is([data-explosion-state="loading"], [data-explosion-state="fallback"]) .explosion__turn {
  visibility: hidden;
}

/* Card of the chosen unit, or the units of the chosen floor. */
.explosion__card {
  grid-area: card;
  align-self: end;
  padding: 0.85rem 1rem 1rem;
}
.explosion__unit-floor {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-min);
  font-weight: 600;
}
.dialog--explosion .explosion__unit-title {
  margin: 0.1rem 0 0.5rem;
  font-size: clamp(1.375rem, 1.1rem + 0.7vw, 1.75rem);
  letter-spacing: -0.02em;
}
.explosion__unit-status {
  margin-bottom: 0.5rem;
}
.explosion__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0 0 0.75rem;
}
.explosion__facts dt {
  color: var(--color-muted);
  font-size: var(--text-min);
}
.explosion__facts dd {
  margin: 0;
  font-size: var(--text-min);
  font-weight: 700;
}
.explosion__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.explosion__action,
.explosion__unit-button {
  min-height: 44px;
  border: 1px solid var(--color-line);
  color: var(--color-ink);
  background: var(--color-white);
  font: 600 var(--text-min) / 1 var(--font-body);
  cursor: pointer;
}
.explosion__action {
  padding: 0.5rem 1rem;
  border-radius: 999px;
}
.explosion__action:hover,
.explosion__unit-button:hover {
  border-color: var(--color-ink);
}
.dialog--explosion .explosion__cta {
  flex: 1 1 auto;
  min-height: 48px;
  padding: 0.5rem 1.1rem;
}
.explosion__pick-title {
  margin: 0;
  font-size: var(--text-min);
  font-weight: 600;
}
.explosion__units {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.explosion__unit-button {
  min-width: 44px;
  padding: 0 0.6rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Fallback: the flight's end image with its floor hotspots (as on the page today). */
.explosion__fallback-bild {
  object-fit: contain;
}
.explosion__fallback-spot {
  fill: transparent;
  stroke: var(--explosion-line-strong);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.explosion__fallback-spot:hover {
  fill: var(--color-highlight-faint);
  stroke: var(--color-cta);
}

/* Portrait (format hoch): title row with close, floors in one row, card across the bottom. */
[data-explosion-format="hoch"].explosion {
  grid-template-areas:
    "info info close"
    "floors floors floors"
    "links . rechts"
    ". . ganz"
    "card card card";
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto 1fr auto auto;
}
[data-explosion-format="hoch"] .explosion__floors {
  display: flex;
  justify-self: stretch;
}
[data-explosion-format="hoch"] .explosion__floors button {
  flex: 1 1 0;
  justify-content: center;
  padding-inline: 0.25rem;
  text-align: center;
}
[data-explosion-format="hoch"] .explosion__floor-name {
  display: none;
}
[data-explosion-format="hoch"] .explosion__floor-short {
  display: inline;
}
[data-explosion-format="hoch"] .explosion__info {
  justify-self: stretch;
  padding: 0.5rem 0.75rem;
}

/* Low landscape windows (phones on their side): short floor names, a slimmer card. */
@media (max-height: 32rem) {
  .explosion__floor-name {
    display: none;
  }
  .explosion__floor-short {
    display: inline;
  }
  .explosion__floors button {
    min-height: 40px;
    padding-block: 0.25rem;
  }
  .explosion__card {
    padding: 0.5rem 0.75rem 0.6rem;
  }
  .dialog--explosion .explosion__unit-title {
    margin-bottom: 0.25rem;
  }
  .explosion__facts {
    margin-bottom: 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialog--explosion[open] {
    animation: none;
  }
  .explosion__flaeche {
    transition: none;
  }
}
