/* Stage 2 — First Aid setup short-viewport resilience only.
   Loaded after stage2-firstaid-setup.css. First Aid Live remains untouched. */

body[data-stage1-view="firstaid"] #faSetupScreen select,
body[data-stage1-view="firstaid"] #faSetupScreen input:not([type="checkbox"]):not([type="radio"]){
  min-height:38px;
  line-height:1.2;
}

body[data-stage1-view="firstaid"] #faSetupScreen select{
  height:38px;
  padding:6px 30px 6px 10px;
}

body[data-stage1-view="firstaid"] #faSetupScreen input:not([type="checkbox"]):not([type="radio"]){
  padding:6px 10px;
}

body[data-stage1-view="firstaid"] .fa-revive-state>summary{
  min-height:38px;
  display:flex;
  align-items:center;
  gap:7px;
  padding:6px 8px!important;
  border:1px solid #285f48;
  border-radius:6px;
  background:#06110c;
  line-height:1.2;
  list-style:none;
  cursor:pointer;
}

body[data-stage1-view="firstaid"] .fa-revive-state>summary::-webkit-details-marker{
  display:none;
}

body[data-stage1-view="firstaid"] .fa-revive-state>summary::before{
  content:"▸";
  width:12px;
  flex:0 0 12px;
  color:#9dbbad;
  text-align:center;
  transform-origin:center;
  transition:transform .12s ease;
}

body[data-stage1-view="firstaid"] .fa-revive-state[open]>summary::before{
  transform:rotate(90deg);
}

body[data-stage1-view="firstaid"] .fa-revive-state>.grid2,
body[data-stage1-view="firstaid"] .fa-revive-state>small{
  margin-left:20px;
  width:calc(100% - 20px);
}

body[data-stage1-view="firstaid"] .fa-revive-state>.grid2{
  margin-top:7px;
}

body[data-stage1-view="firstaid"] .fa-revive-state>small{
  display:block;
  margin-top:5px;
  line-height:1.3;
}

/* Wide desktop setup uses the viewport-constrained workspace established by Stage 2. */
@media(min-width:1500px){
  body.stage2-firstaid-setup-active .fa-setup-scenario,
  body.stage2-firstaid-setup-active .fa-setup-config{
    max-height:100%;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    scrollbar-gutter:stable;
  }

  body.stage2-firstaid-setup-active .fa-setup-config{
    grid-template-rows:auto auto minmax(0,1fr);
  }

  body.stage2-firstaid-setup-active .fa-setup-config-lower{
    min-height:0;
    height:100%;
    align-items:stretch;
  }

  body.stage2-firstaid-setup-active .fa-setup-mannequin-region{
    position:relative;
    min-width:0;
    min-height:0;
    height:100%;
    overflow:hidden;
    display:flex;
    align-items:center;
    justify-content:center;
  }

  /* Match the approved ~.92 mannequin size at 1080px, then let the real box
     shrink with the available lower-region height. No transform overflow. */
  body.stage2-firstaid-setup-active .fa-setup-body{
    position:relative;
    flex:0 0 auto;
    height:min(434px,100%);
    width:auto;
    max-width:100%;
    aspect-ratio:250 / 472;
    margin:0 auto;
    transform:none!important;
    transform-origin:center;
  }

  body.stage2-firstaid-setup-active .fa-setup-part{
    font-size:clamp(.62rem,calc(.48rem + .26vh),.76rem);
  }

  body.stage2-firstaid-setup-active .fa-setup-part.head{left:36%;top:1.06%;width:28%;height:14.83%;border-radius:50%}
  body.stage2-firstaid-setup-active .fa-setup-part.chest{left:28%;top:17.37%;width:44%;height:25%}
  body.stage2-firstaid-setup-active .fa-setup-part.groin{left:32.8%;top:43.43%;width:34.4%;height:12.29%}
  body.stage2-firstaid-setup-active .fa-setup-part.larm{left:7.2%;top:18.22%;width:18.8%;height:25.42%}
  body.stage2-firstaid-setup-active .fa-setup-part.rarm{right:7.2%;top:18.22%;width:18.8%;height:25.42%}
  body.stage2-firstaid-setup-active .fa-setup-part.lhand{left:3.6%;top:44.7%;width:19.2%;height:11.02%}
  body.stage2-firstaid-setup-active .fa-setup-part.rhand{right:3.6%;top:44.7%;width:19.2%;height:11.02%}
  body.stage2-firstaid-setup-active .fa-setup-part.lleg{left:28.4%;top:57.2%;width:19.2%;height:31.78%}
  body.stage2-firstaid-setup-active .fa-setup-part.rleg{right:28.4%;top:57.2%;width:19.2%;height:31.78%}
  body.stage2-firstaid-setup-active .fa-setup-part.lfoot{left:22.8%;top:90.47%;width:24.8%;height:9.53%}
  body.stage2-firstaid-setup-active .fa-setup-part.rfoot{right:22.8%;top:90.47%;width:24.8%;height:9.53%}

  body.stage2-firstaid-setup-active .fa-setup-final-actions{
    width:100%;
    justify-content:flex-start;
    flex-wrap:wrap;
    margin-top:10px!important;
    padding-top:9px;
  }

  body.stage2-firstaid-setup-active .fa-setup-final-actions .sim-start-btn{
    min-width:190px;
  }
}

/* As height tightens, reduce optional spacing before allowing either major
   panel's own vertical auto-overflow to become visible. */
@media(min-width:1500px) and (max-height:900px){
  body.stage2-firstaid-setup-active #faSetupScreen{
    --fa-setup-gap:6px;
  }

  body.stage2-firstaid-setup-active #faSetupScreen>.sim-setup-head{
    padding-block:6px;
  }

  body.stage2-firstaid-setup-active .fa-setup-scenario,
  body.stage2-firstaid-setup-active .fa-setup-config{
    padding-top:9px;
    padding-bottom:9px;
  }

  body.stage2-firstaid-setup-active #faPresets{
    gap:6px;
    margin-bottom:6px;
  }

  body.stage2-firstaid-setup-active #faPresets .fa-preset{
    min-height:54px;
    padding-block:6px;
  }

  body.stage2-firstaid-setup-active .fa-setup-patient{
    padding-bottom:5px;
    margin-bottom:5px;
  }

  body.stage2-firstaid-setup-active .fa-setup-patient .compact-fields,
  body.stage2-firstaid-setup-active .fa-setup-patient .fa-revive-state{
    margin-top:5px;
  }

  body.stage2-firstaid-setup-active .fa-setup-config-lower{
    gap:10px;
  }

  body.stage2-firstaid-setup-active .fa-setup-injury{
    align-self:start;
  }

  body.stage2-firstaid-setup-active .fa-setup-injury>.statusline{
    margin:6px 0 7px;
  }

  body.stage2-firstaid-setup-active .fa-setup-final-actions{
    margin-top:7px!important;
    padding-top:7px;
  }
}

@media(min-width:1500px) and (max-height:820px){
  body.stage2-firstaid-setup-active .fa-setup-scenario>h2,
  body.stage2-firstaid-setup-active .fa-setup-config-title{
    position:sticky;
    top:0;
    z-index:3;
    background:#10281d;
  }

  body.stage2-firstaid-setup-active .fa-setup-scenario>h2{
    padding:2px 0 5px;
  }

  body.stage2-firstaid-setup-active .fa-setup-config-title{
    padding-top:2px;
  }

  body.stage2-firstaid-setup-active #faPresets{
    flex:none;
  }

  body.stage2-firstaid-setup-active .fa-setup-scenario .random-row{
    margin-top:6px;
  }
}

@media(min-width:1500px) and (max-height:740px){
  body.stage2-firstaid-setup-active .fa-setup-final-actions{
    gap:6px;
  }

  body.stage2-firstaid-setup-active .fa-setup-final-actions .sim-start-btn{
    min-width:170px;
  }
}

@media(prefers-reduced-motion:reduce){
  body[data-stage1-view="firstaid"] .fa-revive-state>summary::before{
    transition:none;
  }
}
