/* Dialog dimensions follow the visible area, including when the on-screen keyboard appears. */
body > .dlg, body > .kov-lb {
  box-sizing: border-box;
  top: var(--gate-view-top, 0px);
  bottom: auto;
  height: var(--gate-view-height, 100dvh);
}
body > .dlg:not(.photo-dlg) {
  --dialog-space: clamp(8px, 2.5vmin, 24px);
  padding: max(var(--dialog-space), env(safe-area-inset-top)) max(var(--dialog-space), env(safe-area-inset-right)) max(var(--dialog-space), env(safe-area-inset-bottom)) max(var(--dialog-space), env(safe-area-inset-left));
  align-items: center;
}
.gate-dialog-frame {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  max-height: 100%;
}
#lead-dlg .gate-dialog-frame, #thanks-dlg .gate-dialog-frame { max-width: 460px; }
#pf-dlg .gate-dialog-frame { max-width: 1080px; }
#vid-dlg .gate-dialog-frame {
  width: min(100%, 1040px, calc((var(--gate-view-height, 100dvh) - 2 * var(--dialog-space) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * var(--gate-media-ratio, .5625)));
}

.dlg .gate-dialog-frame > .dlg-box {
  width: 100%;
  max-width: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: clamp(16px, 2vw, 24px);
}
.gate-dialog-frame > .x {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 8;
  width: 44px;
  height: 44px;
  background: var(--paper);
  box-shadow: 0 2px 10px #17141026;
}
#lead-dlg .lead-box { padding: clamp(22px, 4vw, 34px) clamp(18px, 4vw, 32px); gap: 12px; }
#lead-dlg .lead-box > * { flex-shrink: 0; }
#lead-dlg .kicker, #pf-dlg .h3 { padding-right: 46px; }
#lead-dlg .h3 { padding-right: 0; }
#lead-dlg .lead-ctx { max-width: 100%; overflow-wrap: anywhere; }
#vid-dlg .vid-box { display: block; height: auto; padding: 0; }
#vid-dlg video {
  display: block;
  height: auto;
  width: 100%;
  aspect-ratio: var(--gate-media-ratio, .5625);
  max-height: calc(var(--gate-view-height, 100dvh) - 2 * var(--dialog-space) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  object-fit: contain;
}

dialog.gate-viewer {
  width: fit-content;
  max-width: calc(100% - 24px);
  max-height: calc(100dvh - 16px);
  margin: auto;
  padding: 56px 12px 12px;
  overscroll-behavior: contain;
}
dialog.gate-viewer figure img {
  --photo-height: max(60px, calc(100dvh - 186px));
  display: block;
  aspect-ratio: var(--gate-photo-ratio, 1.333);
  width: min(var(--gate-photo-width, 860px), calc(var(--photo-height) * var(--gate-photo-ratio, 1.333)));
  height: auto;
  max-width: min(860px, calc(100vw - 52px));
  max-height: calc(100dvh - 186px);
  margin-inline: auto;
}
dialog.gate-viewer figcaption { overflow-wrap: anywhere; }
dialog.gate-viewer .x { top: 6px; right: 8px; }
dialog.gate-viewer .gate-viewer-controls .btn { min-width: 44px; min-height: 44px; }
#delivery .mount ul { grid-template-columns: 1fr; gap: 12px; }
#delivery .mount li > span { min-width: 0; }
@media (min-width:761px) {
  #delivery .mount { grid-template-columns: minmax(180px, .75fr) minmax(0, 1.25fr); gap: clamp(20px, 3vw, 48px); }
}
@media (min-width:761px) and (max-width:960px) {
  #delivery .mount { grid-template-columns: 1fr; }
}
@media (max-width:420px) {
  #consult .consult-online { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #consult .consult-online .btn { min-width: 0; gap: 5px; padding-inline: 6px; }
}
@media (max-width:600px) and (min-height:501px) {
  body > #lead-dlg, body > #thanks-dlg, body > #pf-dlg {
    align-items: flex-end;
    padding: max(8px, env(safe-area-inset-top)) 0 0;
  }
  #lead-dlg .gate-dialog-frame, #thanks-dlg .gate-dialog-frame { max-width: none; }
  .dlg .gate-dialog-frame > :is(.lead-box,.pf-box) { border-radius: 22px 22px 0 0; }
  #lead-dlg .lead-box, #thanks-dlg .thanks-box { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}
@media (max-height:500px) {
  #pf-dlg .pf-foot { position: static; }
  body > .kov-lb { padding: 8px 60px; }
  body > .kov-lb:not(.kov-lb--rev) figure { width: 100%; height: 100%; flex-direction: row; justify-content: center; gap: 12px; }
  body > .kov-lb:not(.kov-lb--rev) figure img {
    width: auto; min-width: 0; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; background: transparent; box-shadow: none;
  }
  body > .kov-lb:not(.kov-lb--rev) figure:has(figcaption:not([hidden])) img { max-width: calc(100% - min(38%, 240px) - 12px); }
  body > .kov-lb figcaption:not([hidden]) { width: min(38%, 240px); min-width: 0; flex: none; justify-content: center; text-align: center; }
  body > .kov-lb--rev img { max-height: calc(100dvh - 32px); }
  body > .kov-lb .kov-lb-end { max-height: 100%; overflow-y: auto; }
  dialog.gate-viewer { padding: 8px 56px; }
  dialog.gate-viewer figure img { --photo-height: max(60px, calc(100dvh - 120px)); max-width: calc(100vw - 144px); max-height: calc(100dvh - 120px); }
  #ph-dlg .ph-stage { padding: 12px 68px 42px; }
  #ph-dlg .ph-fig img { max-height: calc(100dvh - 58px); }
}
html:has(body > .dlg:not([hidden]), body > .kov-lb:not([hidden]), body > dialog[open]) {
  overflow: hidden !important;
}
@media (pointer: fine) and (min-width: 761px) { html { scrollbar-gutter: stable; } }

/* A project card is ready to use as soon as its cover is loaded. */
.rv-on #pf-grid .pf-card.rv { opacity:1; transform:none; transition:none; }
#pf-gal[data-project-previews] > .ph[style*="--project-preview"]:not(.ld) {
  background-image:var(--project-preview);
  background-position:center;
  background-size:contain;
  background-repeat:no-repeat;
}
#pf-gal[data-project-previews].rows > .ph > img { transition:none; }
