/* Begehbare Musterwohnung: full-screen dialog (scripts/musterwohnung.js); its entry sits in the card of «Meine Wohnung». */

/* Dialog frame: full dynamic viewport, page scroll locked while open. */
html:has(.dialog--musterwohnung[open]) {
  overflow: hidden;
}
.dialog.dialog--musterwohnung {
  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;
}
.musterwohnung {
  --musterwohnung-edge: var(--space-sm);
  position: relative;
  width: 100%;
  height: 100%;
}
.musterwohnung__viewer,
.musterwohnung__fallback {
  position: absolute;
  inset: 0;
}
.musterwohnung__viewer {
  touch-action: none;
  cursor: grab;
}
.musterwohnung__viewer:active {
  cursor: grabbing;
}
.musterwohnung__canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.dialog--musterwohnung :is(button, a):focus-visible {
  outline: 3px solid var(--color-white);
  outline-offset: 2px;
  box-shadow: 0 0 0 7px var(--color-ink);
}
.musterwohnung__viewer:focus-visible {
  outline: 3px solid var(--color-white);
  outline-offset: -6px;
}

/* Still image with a short note and the 360° tour when the 3D view cannot run. */
.musterwohnung__fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}
.musterwohnung__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.musterwohnung__fallback-box {
  position: relative;
  display: grid;
  max-width: 34rem;
  justify-items: start;
  gap: 0.75rem;
  margin: var(--space-lg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--color-panel);
  box-shadow: var(--shadow-overlay);
}

/* Overlays */
.musterwohnung__info,
.musterwohnung__status,
.musterwohnung__hint {
  position: absolute;
  z-index: 3;
  border-radius: var(--radius);
  box-shadow: var(--shadow-overlay);
}
.musterwohnung__info {
  top: calc(var(--musterwohnung-edge) + env(safe-area-inset-top));
  left: calc(var(--musterwohnung-edge) + env(safe-area-inset-left));
  max-width: min(28rem, calc(100% - 2 * var(--musterwohnung-edge) - 9.5rem));
  padding: 0.75rem 1rem;
  background: var(--color-panel);
}
.musterwohnung__floor {
  margin: 0 0 0.2rem;
  color: var(--color-muted);
  font-size: var(--text-min);
}
.musterwohnung__floor:empty {
  display: none;
}
.dialog--musterwohnung .musterwohnung__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;
}
.musterwohnung__title:focus {
  outline: none;
}
/* The decided label stays in view as long as the dialog is open. */
.musterwohnung__label {
  width: fit-content;
  margin-top: 0.4rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  color: var(--color-white);
  background: var(--color-ink);
  font-size: var(--text-min);
  font-weight: 600;
}
.musterwohnung__note {
  margin-top: 0.35rem;
  color: var(--color-muted);
  font-size: var(--text-min);
}
.musterwohnung__unit-note {
  display: block;
}
.musterwohnung__close {
  position: absolute;
  z-index: 4;
  top: calc(var(--musterwohnung-edge) + env(safe-area-inset-top));
  right: calc(var(--musterwohnung-edge) + env(safe-area-inset-right));
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 1rem;
  border: 0;
  border-radius: var(--radius);
  color: var(--color-ink);
  background: var(--color-panel);
  box-shadow: var(--shadow-overlay);
  font: 600 var(--text-min) / 1 var(--font-body);
  cursor: pointer;
}
.musterwohnung__close span {
  font-size: 1.5rem;
  font-weight: 400;
}
.musterwohnung__status {
  top: 50%;
  left: 50%;
  padding: 0.75rem 1rem;
  background: var(--color-panel);
  transform: translate(-50%, -50%);
}
.musterwohnung__status:empty,
:is([data-musterwohnung-state="loaded"], [data-musterwohnung-state="fallback"]) .musterwohnung__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;
}
.musterwohnung__hint {
  bottom: calc(5.75rem + env(safe-area-inset-bottom));
  left: 50%;
  padding: 0.5rem 1rem;
  color: var(--color-white);
  background: var(--color-overlay);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}
[data-musterwohnung-state="loading"] .musterwohnung__hint {
  display: none;
}

/* Bottom bar: rooms and inquiry. */
.musterwohnung__bar {
  position: absolute;
  z-index: 3;
  right: calc(var(--musterwohnung-edge) + env(safe-area-inset-right));
  bottom: calc(var(--musterwohnung-edge) + env(safe-area-inset-bottom));
  left: calc(var(--musterwohnung-edge) + env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}
[data-musterwohnung-state="fallback"] .musterwohnung__rooms {
  display: none;
}
.musterwohnung__rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 1.5rem;
  background: var(--color-panel);
  box-shadow: var(--shadow-overlay);
}
.musterwohnung__rooms button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 999px;
  color: var(--color-ink);
  background: transparent;
  font: 600 var(--text-min) / 1 var(--font-body);
  cursor: pointer;
}
.musterwohnung__rooms button[aria-pressed="true"] {
  color: var(--color-white);
  background: var(--color-accent);
}
.musterwohnung__cta {
  flex: none;
  margin-left: auto;
}

@media (max-width: 48rem) {
  /* Phones: the close button sits in the title row of a full-width info card. */
  .musterwohnung__info {
    right: calc(var(--musterwohnung-edge) + env(safe-area-inset-right));
    max-width: none;
    padding: 0.5rem 0.75rem;
  }
  .musterwohnung__floor {
    min-height: 2.75rem;
    padding-right: 8rem;
  }
  .dialog--musterwohnung .musterwohnung__title {
    line-height: 1.15;
  }
  .musterwohnung__floor:empty + .musterwohnung__title {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding-right: 8.5rem;
  }
  .musterwohnung__close {
    top: calc(var(--musterwohnung-edge) + 0.5rem + env(safe-area-inset-top));
    right: calc(var(--musterwohnung-edge) + 0.5rem + env(safe-area-inset-right));
    box-shadow: none;
    background: var(--color-sage);
  }
  /* Bar in two rows: rooms in three columns, inquiry. */
  .musterwohnung__bar {
    display: grid;
  }
  .musterwohnung__rooms {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .musterwohnung__rooms button {
    justify-content: center;
    padding-inline: 0.5rem;
  }
  .musterwohnung__cta {
    min-height: 48px;
    margin-left: 0;
    padding: 0.5rem 1rem;
  }
  .musterwohnung__hint {
    top: 50%;
    right: var(--musterwohnung-edge);
    bottom: auto;
    left: var(--musterwohnung-edge);
    transform: translateY(-50%);
    white-space: normal;
    text-align: center;
  }
}
