/* FORAMIND Corporate V1.0.61 — iPhone Safari & mobile browser viewport rules.
 * Scoped to touch-size activity pages; desktop/projector layouts remain intact.
 * iOS Safari cannot guarantee native fullscreen in a normal browser tab:
 * these rules use the visible viewport, safe areas and sensible scrolling.
 */
html[data-fm-mobile-layout="true"]{
  --fm-usable-height:100dvh;
  --fm-safe-top:env(safe-area-inset-top,0px);
  --fm-safe-bottom:env(safe-area-inset-bottom,0px);
  --fm-safe-left:env(safe-area-inset-left,0px);
  --fm-safe-right:env(safe-area-inset-right,0px);
  -webkit-text-size-adjust:100%;
}
/* The global box model and iOS input zoom guard apply only to the named
 * activity runtimes. The Blurting runtime ("generic") owns its own box model
 * and compact controls; these resets must not leak into it. */
html[data-fm-mobile-layout="true"][data-fm-runtime]:not([data-fm-runtime="generic"]) *,
html[data-fm-mobile-layout="true"][data-fm-runtime]:not([data-fm-runtime="generic"]) *::before,
html[data-fm-mobile-layout="true"][data-fm-runtime]:not([data-fm-runtime="generic"]) *::after{box-sizing:border-box}
html[data-fm-mobile-layout="true"][data-fm-runtime]:not([data-fm-runtime="generic"]) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-fm-mobile-layout="true"][data-fm-runtime]:not([data-fm-runtime="generic"]) textarea,
html[data-fm-mobile-layout="true"][data-fm-runtime]:not([data-fm-runtime="generic"]) select{font-size:max(16px,1em)}
html[data-fm-mobile-layout="true"] [role="dialog"],
html[data-fm-mobile-layout="true"] .nv-mode-dialog,
html[data-fm-mobile-layout="true"] .nv-personal-dialog,
html[data-fm-mobile-layout="true"] .study-modal-card,
html[data-fm-mobile-layout="true"] .rush-card,
html[data-fm-mobile-layout="true"] .pres-card{max-width:100%;min-width:0}
html[data-fm-mobile-layout="true"] :is(.nv-mode-dialog,.nv-personal-dialog,.study-modal-card,.rush-join-form,.pres-card) { -webkit-overflow-scrolling:touch;overscroll-behavior:contain }
/* Notes Map: Safari topbar wraps when the navigation/actions grow. The map and
 * overlay use the actual measured header, not a fixed 82/125/142 px guess. */
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"],
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] body{
  width:100%;max-width:100%;height:var(--fm-usable-height,100dvh);overflow:hidden;
}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] body{display:flex;flex-direction:column;min-height:0}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-topbar{flex:0 0 auto;min-width:0;padding-top:max(6px,var(--fm-safe-top))}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-stage{flex:1 1 auto;height:auto!important;min-height:0!important}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-note-layer,
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] body.nv-study-context .nv-note-layer{inset:var(--fm-notes-header-height,82px) 0 0!important;padding:clamp(6px,2.3vw,15px)}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-note-card{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-notes-header-height,82px) - 18px);max-width:calc(100vw - 14px);padding:16px 14px}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-note-stack{min-height:0;min-width:0;max-height:min(47dvh,380px);overflow-y:auto;touch-action:pan-y}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-personal-layer{padding:calc(8px + var(--fm-safe-top)) calc(6px + var(--fm-safe-right)) calc(8px + var(--fm-safe-bottom)) calc(6px + var(--fm-safe-left))}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-personal-dialog{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-safe-top) - var(--fm-safe-bottom) - 12px)!important;max-width:100%;overflow-y:auto;touch-action:pan-y}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-mode-dialog{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-safe-top) - var(--fm-safe-bottom) - 12px)!important;overflow-y:auto}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-anki-actions{gap:6px;margin-top:8px;padding-top:9px}
html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-anki-actions button{min-height:43px;font-size:11px}
/* Study Path and Presentation use the actual visible viewport for fullscreen
 * maps and keep the dock / note drawer within the iPhone safe bottom edge. */
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-app,
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-app{
  height:var(--fm-usable-height,100dvh)!important;min-height:0!important;max-height:var(--fm-usable-height,100dvh)!important;overflow:hidden;
}
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-panel{max-height:min(46%,360px);overflow:hidden}
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-stage-content{min-height:0;overflow-y:auto;touch-action:pan-y}
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-controls{bottom:max(6px,var(--fm-safe-bottom))!important;max-width:calc(100vw - var(--fm-safe-left) - var(--fm-safe-right) - 12px);overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-modal{padding:calc(8px + var(--fm-safe-top)) calc(8px + var(--fm-safe-right)) calc(8px + var(--fm-safe-bottom)) calc(8px + var(--fm-safe-left))}
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-modal-card{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-safe-top) - var(--fm-safe-bottom) - 14px)}
html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-modal-body{min-height:0;overflow-y:auto;touch-action:pan-y}
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-controls{max-width:calc(100vw - var(--fm-safe-left) - var(--fm-safe-right) - 12px);overflow-x:auto;overscroll-behavior-x:contain;bottom:max(7px,var(--fm-safe-bottom))}
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-screen{max-height:var(--fm-usable-height,100dvh);overflow-y:auto;-webkit-overflow-scrolling:touch}
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-question-student>article{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-safe-top) - var(--fm-safe-bottom) - 22px);overflow-y:auto}
/* The followed Presentation must not force students to rotate between
 * portrait for answering and landscape for exploring. iPhone/iPad may use
 * either orientation, including Safari's non-native fullscreen fallback. */
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-rotate,
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-question-rotate{display:none!important}
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-question-student{visibility:visible!important}
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-gate{padding:calc(10px + var(--fm-safe-top)) calc(9px + var(--fm-safe-right)) calc(10px + var(--fm-safe-bottom)) calc(9px + var(--fm-safe-left))}
html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-gate-card{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-safe-top) - var(--fm-safe-bottom) - 18px);overflow-y:auto;-webkit-overflow-scrolling:touch}
@media(max-height:500px) and (orientation:landscape){
 html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-question-student{padding:max(4px,var(--fm-safe-top)) 8px max(4px,var(--fm-safe-bottom))}
 html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-question-student>article{padding:10px 13px}
 html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-question-student textarea{min-height:75px}
 html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] body.pres-student-client .pres-question-student .pres-question-clock{height:48px;min-width:48px;font-size:24px;margin:4px auto}
}
/* Rush: portrait and landscape screens both scroll within the visual viewport,
 * including setup cards, lobby and responsive student option panels. */
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"],
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] body{height:var(--fm-usable-height,100dvh);max-height:var(--fm-usable-height,100dvh);overflow:hidden}
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-shell,
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-student-shell{height:100%!important;min-height:0!important;overflow:hidden}
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-main,
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-student-main{min-height:0!important;overflow:auto;-webkit-overflow-scrolling:touch}
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-setup,
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-lobby-main,
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-join-screen{min-height:0;overflow-y:auto;touch-action:pan-y}
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-setup-card{width:min(100%,560px);margin-inline:auto}
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-student-round{height:100%;min-height:0;overflow-y:auto}
html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-student-options{min-height:190px}
/* General mobile editor + floating dialogs. Do not freeze the whole Studio. */
html[data-fm-mobile-layout="true"] .fvp{max-width:100%;min-width:0}
html[data-fm-mobile-layout="true"] .fvp-screen{min-height:0}
html[data-fm-mobile-layout="true"][data-fm-runtime="studio"] [role="dialog"]{max-height:calc(var(--fm-usable-height,100dvh) - var(--fm-safe-top) - var(--fm-safe-bottom) - 16px);overflow-y:auto;-webkit-overflow-scrolling:touch}
@media(max-height:530px) and (orientation:landscape){
 html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-note-card{max-height:calc(var(--fm-usable-height) - var(--fm-notes-header-height,60px) - 8px)}
 html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-note-stack{max-height:45dvh}
 html[data-fm-mobile-layout="true"][data-fm-runtime="notes"] .nv-personal-node{height:95px;margin:6px auto}
 html[data-fm-mobile-layout="true"][data-fm-runtime="study"] .study-panel{max-height:calc(var(--fm-usable-height) - 85px)}
 html[data-fm-mobile-layout="true"][data-fm-runtime="presentation"] .pres-controls{bottom:max(3px,var(--fm-safe-bottom))}
 html[data-fm-mobile-layout="true"][data-fm-runtime="rush"] .rush-student-options{min-height:148px}
}
