/* Dialogs share the viewport instead of creating a second scrolling page. */
html.has-modal,html.has-modal body{overscroll-behavior:none}
dialog{max-height:calc(100dvh - 32px);overflow:hidden;overscroll-behavior:contain}
dialog [hidden]{display:none!important}
dialog .dialog-close{z-index:3;width:44px;height:44px;top:2px;right:6px}

:is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog)[open]{
  display:block;
  width:min(1220px,calc(100% - 32px));
  height:min(800px,calc(100dvh - 32px));
  max-height:calc(100dvh - 32px);
  padding:48px 28px 24px;
  overflow:hidden;
}
#municipal-dialog[open]{width:min(1320px,calc(100% - 32px))}
:is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.project-main,.viewer-main){
  display:grid;
  grid-template-columns:minmax(0,1.7fr) minmax(240px,1fr);
  gap:28px;
  height:100%;
  min-height:0;
  min-width:0;
}
:is(.project-gallery,.viewer-gallery){display:flex;flex-direction:column;gap:10px;min-height:0;min-width:0}
:is(#project-dialog,#progress-dialog,#render-dialog) :is(.project-photo-frame,.progress-figure,.render-figure){
  position:relative;flex:1 1 0;min-height:0;min-width:0;overflow:hidden;margin:0;
}
.progress-figure{display:flex;background:#252729}
#progress-dialog .progress-figure>:is(img,video){width:100%;height:100%;min-height:0;max-height:none;object-fit:contain;align-self:stretch}
#project-dialog .project-photo-frame>img{width:100%;height:100%;min-height:0;object-fit:contain}
#render-dialog .render-photo-frame{height:100%;min-height:0}
#render-dialog #render-photo{width:100%;height:100%;min-height:0;object-fit:contain}
.viewer-info{display:flex;flex-direction:column;gap:20px;min-height:0;min-width:0}
.viewer-info :is(.progress-dialog-heading,.municipal-heading,.render-heading){margin:0}
.viewer-info .eyebrow{margin:0 0 8px;color:#626569;font-size:.75rem;line-height:1.4}
.viewer-info h2{font-size:clamp(1.55rem,2.7vw,2.2rem);line-height:1.15}
.viewer-info header>p:not(.eyebrow){margin:10px 0 0;font-size:.875rem;line-height:1.5}
.progress-meta{display:grid;gap:8px}
.progress-meta p,#render-dialog #render-caption{margin:0;font-size:.875rem;line-height:1.5}
.progress-meta .progress-publication{font-weight:600}

:is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) .gallery-controls{flex:none;gap:10px;margin:0;min-height:44px}
:is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) .gallery-step{min-height:44px;line-height:1.4;font-size:.875rem;padding:8px 14px;white-space:nowrap}
:is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.gallery-thumbnails,.progress-thumbnails,.municipal-thumbnails){
  position:relative;display:flex;flex:none;flex-wrap:nowrap;gap:8px;
  min-width:0;height:72px;padding:3px 2px 7px;margin:0;
  overflow-x:auto;overflow-y:hidden;overscroll-behavior:contain;
  scrollbar-width:none;scroll-snap-type:x proximity;
}
:is(.gallery-thumbnails,.progress-thumbnails,.municipal-thumbnails)::-webkit-scrollbar{display:none}
:is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.gallery-thumbnail,.progress-thumbnail,.municipal-thumbnail){
  flex:0 0 84px;width:84px;height:62px;scroll-snap-align:center;
}
#project-dialog .project-photo-caption{flex:none;margin:0;font-size:.75rem;line-height:1.4}
#project-dialog .project-info{padding:0;min-width:0;min-height:0}
#project-dialog .project-info h2{font-size:clamp(1.55rem,2.7vw,2.2rem)}
#project-dialog .project-info .eyebrow{margin:0 0 8px;line-height:1.4}
#project-dialog .project-info dl{margin:18px 0}
#project-dialog .project-info dl>div{margin-bottom:14px}
#project-dialog .project-info dt{margin-bottom:4px}
#project-dialog .project-info dd{font-size:.875rem;line-height:1.5}
#project-dialog .project-info .button{margin:0;min-height:44px;padding:10px 16px}
#project-dialog .project-recognition{margin:0 0 12px;padding:8px 0;font-size:.875rem;line-height:1.4}

#municipal-dialog .municipal-stage{flex:1 1 0;width:100%;height:auto;min-height:0;padding:12px;overflow:auto;scrollbar-width:thin}
#municipal-dialog .municipal-toolbar{display:flex;flex-direction:column;align-items:stretch;gap:12px;margin:0}
#municipal-dialog #municipal-name{font-size:.875rem;line-height:1.4}
#municipal-dialog .municipal-zoom{display:grid;grid-template-columns:1fr 1fr;gap:8px;align-items:center}
#municipal-dialog .municipal-zoom .gallery-step{padding:8px}
#municipal-dialog #municipal-zoom-label{text-align:center;min-width:0;font-size:.875rem}

/* Keep the contact form complete too; text fields retain their native editing. */
#consult-dialog[open]{display:grid;gap:8px;padding:38px 24px 22px;width:min(630px,calc(100% - 32px))}
#consult-dialog .eyebrow{margin:0;line-height:1.4}
#consult-dialog h2{font-size:1.8rem;line-height:1.12}
#consult-dialog .dialog-intro{margin:0;font-size:.875rem;line-height:1.5}
#consult-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 14px;min-height:0}
#consult-form>label{margin:0;gap:4px;font-size:.875rem;line-height:1.4;min-width:0}
#consult-form>label:has(:is(select,textarea)),#consult-form>.button,#consult-form>.form-note,#consult-status{grid-column:1/-1}
#consult-form :is(input:not(.form-honeypot),select){min-height:44px;height:44px;padding:8px 10px;font-size:1rem}
#consult-form textarea{height:90px;min-height:0;resize:none;padding:8px 10px;font-size:1rem;line-height:1.4}
#consult-form .button{min-height:44px;padding:10px 16px}
#consult-form .form-note,#consult-status{margin:0;font-size:.75rem;line-height:1.4}
#consult-status:empty{display:none}
#consult-result{padding:40px 24px 24px}
#consult-result .eyebrow{margin:0 0 8px}
#consult-result h2{font-size:clamp(1.6rem,4vw,2.2rem)}
#consult-result .dialog-intro{margin:12px 0 18px}

@media(max-width:700px){
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog)[open]{
    width:calc(100% - 20px);height:calc(100dvh - 20px);max-height:calc(100dvh - 20px);padding:40px 16px 16px;
  }
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.project-main,.viewer-main){
    grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:12px;
  }
  :is(.viewer-info,.project-info){grid-column:1;grid-row:1}
  :is(.viewer-gallery,.project-gallery){grid-column:1;grid-row:2;gap:8px}
  .viewer-info{gap:10px}
  .viewer-info .eyebrow{margin-bottom:4px}
  .viewer-info h2,#project-dialog .project-info h2{font-size:1.55rem;line-height:1.12}
  .viewer-info header>p:not(.eyebrow){margin-top:4px;line-height:1.4}
  .progress-meta{gap:3px}
  .progress-meta p,#render-dialog #render-caption{line-height:1.4}
  #project-dialog .project-info{display:grid;gap:8px}
  #project-dialog .project-info .eyebrow{margin:0}
  #project-dialog .project-info dl{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 14px;margin:0}
  #project-dialog .project-info dl>div{margin:0}
  #project-dialog .project-info dl>div:last-child{grid-column:1/-1}
  #project-dialog .project-info dt{margin-bottom:2px;line-height:1.3}
  #project-dialog .project-info dd{line-height:1.4}
  #project-dialog .project-recognition{margin:0;padding:4px 0}
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.gallery-thumbnails,.progress-thumbnails,.municipal-thumbnails){height:56px;padding-bottom:5px}
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.gallery-thumbnail,.progress-thumbnail,.municipal-thumbnail){flex-basis:66px;width:66px;height:48px}
  #municipal-dialog .municipal-toolbar{gap:6px}
  #municipal-dialog .municipal-zoom{grid-template-columns:auto auto auto auto;gap:6px}
  #municipal-dialog .municipal-zoom .gallery-step{padding:7px 6px}
  #municipal-dialog .municipal-stage{padding:8px}
  #consult-dialog[open]{width:calc(100% - 20px);padding:38px 18px 18px}
}
@media(max-height:700px){
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog)[open]{padding-top:38px;padding-bottom:14px}
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.project-main,.viewer-main){gap:12px}
  .viewer-info{gap:10px}
  .viewer-info h2,#project-dialog .project-info h2{font-size:1.45rem;line-height:1.1}
  .viewer-info .eyebrow,#project-dialog .project-info .eyebrow{margin-bottom:4px}
  #project-dialog .project-info dl{margin:10px 0}
  #project-dialog .project-info dl>div{margin-bottom:8px}
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.gallery-thumbnails,.progress-thumbnails,.municipal-thumbnails){height:52px;padding-bottom:3px}
  :is(#project-dialog,#progress-dialog,#render-dialog,#municipal-dialog) :is(.gallery-thumbnail,.progress-thumbnail,.municipal-thumbnail){flex-basis:66px;width:66px;height:44px}
  #consult-dialog[open]{gap:6px;padding-top:36px;padding-bottom:16px}
  #consult-dialog .eyebrow{display:none}
  #consult-dialog h2{font-size:1.55rem}
  #consult-form{gap:6px 12px}
  #consult-form textarea{height:64px}
}
@media(max-width:700px) and (max-height:700px){
  #project-dialog .project-info{gap:6px}
  #project-dialog .project-info dl{gap:6px 12px;margin:0}
  #project-dialog .project-info dl>div{margin:0}
}
@media(max-height:600px){
  #project-dialog .project-info dl{display:block;margin:8px 0}
  #project-dialog .project-info dl>div{margin:0 0 5px;font-size:.875rem;line-height:1.4}
  #project-dialog .project-info dt{display:inline;margin-right:6px;font-size:.75rem;line-height:inherit}
  #project-dialog .project-info dd{display:inline;font-size:.875rem;line-height:inherit}
}
@media(max-width:700px) and (max-height:600px){
  #project-dialog .project-info dl{margin:0}
  #project-dialog .project-info>.eyebrow{display:none}
  #project-dialog .project-gallery>.gallery-thumbnails{display:none}
}
@media(min-width:600px) and (max-height:500px){
  #consult-dialog[open]{width:min(980px,calc(100% - 32px));grid-template-columns:minmax(160px,.7fr) minmax(0,1.6fr);grid-template-rows:auto 1fr;column-gap:20px;align-items:start}
  #consult-dialog h2{grid-column:1;grid-row:1}
  #consult-dialog .dialog-intro{grid-column:1;grid-row:2}
  #consult-form{grid-column:2;grid-row:1/3;gap:5px 12px}
  #consult-form>label{gap:2px}
  #consult-form textarea{height:52px}
}
