/* Stable mobile layout and menu organization */
.update-banner{display:none!important}
html{scroll-behavior:auto!important}
body.site-menu-open{overflow:hidden}

/* Stable readable quiz: long questions scroll instead of shrinking and reflowing. */
@media (max-width:760px){
  body.quiz-one-screen .stage{overflow:visible!important}
  body.quiz-one-screen .qtext{font-size:clamp(1.02rem,4vw,1.16rem)!important;line-height:1.43!important}
  body.quiz-one-screen .opt{font-size:clamp(.9rem,3.55vw,1rem)!important;line-height:1.42!important;padding:10px!important}
  body.quiz-one-screen.fit-compact .qtext,
  body.quiz-one-screen.fit-dense .qtext,
  body.quiz-one-screen.fit-ultra .qtext{font-size:clamp(1.02rem,4vw,1.16rem)!important;line-height:1.43!important}
  body.quiz-one-screen.fit-compact .opt,
  body.quiz-one-screen.fit-dense .opt,
  body.quiz-one-screen.fit-ultra .opt{font-size:clamp(.9rem,3.55vw,1rem)!important;line-height:1.42!important;padding:10px!important}
  .swipe-hint{display:none!important}

  /* Use the clean right-side drawer style shared with תורת המקצוע. */
  .bottom-sheet{
    top:0!important;
    right:0!important;
    left:auto!important;
    bottom:0!important;
    width:min(82vw,430px)!important;
    max-width:none!important;
    max-height:none!important;
    height:100dvh!important;
    margin:0!important;
    padding:calc(18px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom))!important;
    border-radius:0!important;
    transform:translateX(105%)!important;
    transition:transform .16s ease-out!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
    box-shadow:-14px 0 38px rgba(0,0,0,.22)!important;
  }
  .bottom-sheet.open{transform:translateX(0)!important}
  .sheet-handle{display:none!important}
  .sheet-backdrop.open{animation:none!important}
  .site-menu-head{
    position:sticky;top:calc(-18px - env(safe-area-inset-top));z-index:3;
    display:flex;align-items:center;justify-content:space-between;
    margin:calc(-18px - env(safe-area-inset-top)) -14px 14px;
    padding:calc(18px + env(safe-area-inset-top)) 18px 14px;
    background:color-mix(in srgb,var(--card) 96%,transparent);
    border-bottom:1px solid var(--opt-border);
    backdrop-filter:none;-webkit-backdrop-filter:none;
    font-size:1.18rem;color:var(--ink);
  }
  .site-menu-head button{
    width:44px;height:44px;border:0;border-radius:13px;
    background:var(--opt-bg);color:var(--blue);font-size:1.8rem;line-height:1;
  }
  .sheet-grid{grid-template-columns:1fr 1fr!important;gap:9px!important}
  .sheet-btn{min-height:92px!important;border-radius:17px!important;font-size:.92rem!important;justify-content:center!important}
  .sheet-btn .sheet-ico{font-size:1.45rem!important}
  .sheet-btn small{display:block;font-size:.68rem;color:var(--muted);font-weight:600}
  .sheet-group-title{
    grid-column:1/-1;
    text-align:right;
    font-weight:900;
    font-size:1rem;
    color:var(--ink);
    padding:14px 3px 5px;
    border-bottom:1px solid var(--opt-border);
  }
  .sheet-group-title:first-child{padding-top:0}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
}


/* Prevent accidental horizontal gestures and layout jumps on iPhone. */
#quizStage,.stage,.options,.opt{touch-action:pan-y}
#nextBtn,#prevBtn{touch-action:manipulation}
body.site-menu-open{width:100%;overflow:hidden!important}
.bottom-sheet{contain:layout paint}
.update-banner,#updateBanner{display:none!important}

/* Calm UI: avoid expensive visual effects while answering. */
.stage,.quiz-card{animation:none!important}
.opt,.option{will-change:auto!important}
.question-visual{content-visibility:auto}

/* V5.6.0 — lighter delegated controls and stable locked answers */
.opt.locked{cursor:default;touch-action:pan-y}
.opt.locked:active{transform:none}
.index-grid button.index-cell{font:inherit;appearance:none;-webkit-appearance:none;padding:0}
.search-results button.search-result-item{display:block;width:100%;font:inherit;text-align:right;color:inherit}
.option,.opt,.nav-btn,.sheet-btn,.drawer-grid button{touch-action:manipulation}

/* V5.6.0 — lower repaint cost and prevent Safari scroll anchoring jumps. */
html,body{overscroll-behavior-y:none}
.stage,.quiz-card,.options,#options,#feedbackBox,.feedback{overflow-anchor:none}
button,.opt,.option,.sheet-btn,.drawer-grid a{-webkit-tap-highlight-color:transparent}
.bottom-sheet,.drawer,.panel{-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
@media (hover:none){
  .opt:hover,.option:hover,.sheet-btn:hover,.nav:hover,.nav-btn:hover{box-shadow:none!important;transform:none!important}
}

/* V5.1 — keep progress counters readable inside RTL pages */
#posLabel,#scoreLabel,#sessionProgress{direction:ltr;unicode-bidi:isolate}

/* V5.6.0 — release memory sooner and reduce unnecessary Safari repaints */
body.subject-safety .bottom-sheet:not(.open),
body.subject-theory .drawer:not(.open){visibility:hidden}
body.subject-safety .bottom-sheet.open,
body.subject-theory .drawer.open{visibility:visible}
body.subject-safety #quizStage,
body.subject-theory .quiz-card{isolation:isolate}
body.subject-safety .options,
body.subject-theory #options{contain:layout paint;overflow-anchor:none}
body.subject-safety .sheet-grid,
body.subject-theory .drawer-grid{content-visibility:auto;contain-intrinsic-size:420px}
