/*
 * The math sim's banner and full-screen layer (contract D12, MS-PR4c), shared by both course pages.
 * The banner wears the sim's own palette (CEP's qimah-cep-math-sim.css: forest #10301d, gold #f4bf54, cream #f6eeda),
 * so the door looks like the room it opens. Class names avoid the theme's dark-mode substring blankets.
 */

/* ---------- the banner ---------- */
.qms-door { content-visibility: visible; contain: none; contain-intrinsic-size: none; scroll-margin-top: 100px; }
.qms-door--course { margin: 18px 0 22px; }
.qms-door__card {
	direction: rtl; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 18px 28px;
	padding: 22px 26px; border-radius: 14px; background: #10301d; color: #f6eeda;
	border: 2px solid #0a2214; box-shadow: 6px 6px 0 rgba(10, 34, 20, 0.35);
}
.qms-door__text { flex: 1 1 320px; min-width: 0; }
.qms-door__kicker { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.04em; color: #f4bf54; }
.qms-door__card h2 { margin: 0; font-size: clamp(20px, 2.4vw, 26px); line-height: 1.35; font-weight: 700; color: #f6eeda; }
.qms-door__line { margin: 8px 0 0; font-size: 16px; line-height: 1.7; color: #d6dfd0; }
.qms-door__chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 14px 0 0; padding: 0; }
.qms-door__chips li {
	padding: 4px 12px; border-radius: 999px; font-size: 13px; line-height: 1.6; color: #f6eeda;
	background: rgba(246, 238, 218, 0.08); border: 1px solid rgba(246, 238, 218, 0.24);
}
/* (0,2,1) and up: over style.css button:hover, reset.css a:hover (0,1,1) and both sheets' [type="button"]:focus (0,2,0),
   which paint a focused button pink (#c36) or inherit the page's ink. Focus keeps the resting look, plus the ring. */
body .qms-door .qms-door__go,
body .qms-door .qms-door__go:focus {
	flex: 0 0 auto; display: inline-flex; align-items: center; gap: 10px; padding: 12px 24px; border-radius: 6px;
	font: inherit; font-size: 16px; font-weight: 700; line-height: 1.3; text-decoration: none; cursor: pointer;
	background: #f4bf54; color: #0a2214; border: 2px solid #0a2214; box-shadow: 4px 4px 0 #0a2214;
	transition: background 0.12s ease, box-shadow 0.12s ease;
}
/* style.css paints every button:hover green with white text: pin both, and never move it on hover. */
body .qms-door .qms-door__go:hover { background: #f7cb6e; color: #0a2214; box-shadow: 5px 5px 0 #0a2214; }
/* (0,3,1): style.css's html[data-theme="dark"] :focus-visible is (0,2,1) and would paint the ring green. */
body .qms-door .qms-door__go:focus-visible { outline: 3px solid #f4bf54; outline-offset: 3px; }
@media (max-width: 600px) {
	.qms-door__card { padding: 18px; }
	/* box-sizing here, not from Hello's reset.css, which the theme dequeues on some pages. */
	body .qms-door .qms-door__go { width: 100%; box-sizing: border-box; justify-content: center; }
}

/* ---------- the layer ---------- */
.qms-layer {
	position: fixed; inset: 0; z-index: 100000; /* above the header (10001), the app shell, the buy bar and WhatsApp */
	/* A column of flex items: «رجوع» and the toggle (sticky, no room of their own: see below), then the body. Flex items never
	   collapse margins, so the buttons' negative margins cannot pull the body's or the bar's margins with them. */
	display: flex; flex-direction: column;
	overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
	background-color: #f6eeda; background-image: radial-gradient(rgba(16, 48, 29, 0.08) 1px, transparent 1.2px); background-size: 9px 9px;
}
html[data-theme="dark"] .qms-layer { background-color: #10301d; background-image: radial-gradient(rgba(246, 238, 218, 0.05) 1px, transparent 1.2px); }
.qms-layer[hidden] { display: none; }
/* A flex item with auto side margins shrinks to its content, so the width is said: the full layer up to 1200, the 16px
   padding inside, as before the flex layer. box-sizing here, not from Hello's reset.css (measured border-box on the course
   pages, but the theme dequeues that sheet on some pages). */
.qms-layer__body { flex-shrink: 0; box-sizing: border-box; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; }
/* The layer covers the site topbar, and the sim bar is pinned to the layer's top (below), so the sim's sticky bands start
   under the bar's 60px (D12; founder 2026-11-13: pin the bar AND the question band). !important beats the runner's inline
   --qm-top, which it measures off .qimah-app-topbar. */
.qms-layer #qimah-major-sim-mount { --qm-top: 60px !important; }
/* CS101's runner renames the theme mount to #qimah-cep-major-sim; from CEP 1.126.0 it draws the CS102 shell in one
   .qm-shell inside it. That mount is already transparent, so only the bands and the bar's room for «رجوع» are said again. */
.qms-layer #qimah-cep-major-sim .qm-shell { --qm-top: 60px !important; }
/* One dot grid: the layer paints it and does not scroll, the mount's own would scroll over it as a seam. */
.qms-layer #qimah-major-sim-mount.is-math { background: transparent; }
/* Room for «رجوع» on the bar's right end, so the brand ellipsizes before it slides under the button (360 and 320). */
/* The bar is pinned to the top of the layer while the sim scrolls (founder, 2026-11-13), 60px tall so the bands below can start
   at a known line (--qm-top above), over the question band (z 20) and under «رجوع», the toggle (25) and the switch (26). Its
   4px ring in the page colour fills the rounded corners, so no paper shows through them when it is pinned. CS101 in a paper:
   the stage is a sibling of .qm-shell, so the bar stops with the shell (it pins on the intro, the picker and the results). */
#qms-layer #qimah-major-sim-mount .qm-bar,
#qms-layer #qimah-cep-major-sim .qm-shell .qm-bar {
	position: sticky; top: 0; z-index: 22; height: 60px; box-sizing: border-box; padding-right: 160px;
	box-shadow: 0 0 0 4px var(--bg, #f6eeda);
}
/* A phone keeps only what «رجوع» and the toggle take: placeButtons() sets «رجوع» 14px inside the bar's right edge (81px wide)
   and the toggle (34px) 8px left of it, 137px in all; with the bar's 2px border, 143px leaves the brand 8px clear of the
   toggle. The 160px cut "Final Lab simulator" short at 390 (lane J of cs101-final-sim, measured on staging 2026-11-15:
   102px of text in 82px). Wide screens keep 160px. */
@media (max-width: 520px) {
	#qms-layer #qimah-major-sim-mount .qm-bar,
	#qms-layer #qimah-cep-major-sim .qm-shell .qm-bar { padding-right: 144px; }
}
/* CS101's «الميجر» | «الفاينل لاب» switch (K8): two links, each its own page load. One pill track holding both, the current
   one filled. qimah-major-layer.js moves it INTO the sim bar (.is-on-bar, centred between the brand and «رجوع») when
   the bar has room; otherwise (a phone, or before the runner draws its bar) it is the same switch above the mount. Both
   states share every size, so the script measures one width for either. Colour only on hover, never a raise. (0,2,1)
   and up so style.css a:hover / reset.css a:hover cannot repaint them. On open it drops in and its gold glow pulses six
   times, then rests: a pulse that never stops would flash beside the code box for the whole sitting. */
#qms-layer .qms-simpick {
	direction: rtl; display: flex; gap: 0; width: max-content; max-width: calc(100% - 32px); box-sizing: border-box;
	margin: 14px auto 6px; padding: 4px; border-radius: 999px;
	background: #fbf6e9; border: 1.5px solid #10301d;
	animation: qms-simpick-drop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2), qms-simpick-pulse 1.5s ease-out 0.5s 6;
}
#qms-layer .qms-simpick a.qms-simpick__opt {
	display: inline-flex; align-items: center; justify-content: center; min-width: 136px; padding: 7px 26px;
	border-radius: 999px; border: 0;
	font: inherit; font-size: 17px; font-weight: 800; line-height: 1.5; text-decoration: none; white-space: nowrap;
	color: #10301d; background: transparent;
	transition: background 0.15s ease, color 0.15s ease;
}
#qms-layer .qms-simpick a.qms-simpick__opt:hover { background: rgba(16, 48, 29, 0.08); color: #10301d; }
#qms-layer .qms-simpick a.qms-simpick__opt.is-on,
#qms-layer .qms-simpick a.qms-simpick__opt.is-on:hover {
	color: #f6eeda; background: #10301d;
	animation: qms-simpick-fill 0.5s ease-out 0.15s backwards;
}
#qms-layer .qms-simpick a.qms-simpick__opt:focus-visible { outline: 3px solid #f4bf54; outline-offset: 2px; }
/* On the bar: cream on forest, the current sim gold. Placed (top / left) by the script; translateX centres it on left. */
/* Sticky like the buttons: qimah-major-layer.js gives it its resting margin, its pinned top and its centring margin. */
#qms-layer .qms-simpick.is-on-bar {
	position: sticky; z-index: 26; margin: 0 auto 0 0; max-width: none; transform: translateX(-50%);
	background: rgba(246, 238, 218, 0.1); border-color: rgba(246, 238, 218, 0.35);
	animation-name: qms-simpick-drop-bar, qms-simpick-pulse;
}
#qms-layer .qms-simpick.is-on-bar a.qms-simpick__opt { color: #f6eeda; }
#qms-layer .qms-simpick.is-on-bar a.qms-simpick__opt:hover { background: rgba(246, 238, 218, 0.12); color: #f6eeda; }
#qms-layer .qms-simpick.is-on-bar a.qms-simpick__opt.is-on,
#qms-layer .qms-simpick.is-on-bar a.qms-simpick__opt.is-on:hover,
html[data-theme="dark"] #qms-layer .qms-simpick a.qms-simpick__opt.is-on,
html[data-theme="dark"] #qms-layer .qms-simpick a.qms-simpick__opt.is-on:hover { background: #f4bf54; color: #0a2214; }
html[data-theme="dark"] #qms-layer .qms-simpick { background: rgba(246, 238, 218, 0.06); border-color: rgba(246, 238, 218, 0.45); }
html[data-theme="dark"] #qms-layer .qms-simpick a.qms-simpick__opt { color: #f6eeda; }
html[data-theme="dark"] #qms-layer .qms-simpick a.qms-simpick__opt:hover { background: rgba(246, 238, 218, 0.1); color: #f6eeda; }
/* 1.63.0, the X1 tabs: a squarer track, an icon and a «done/total» count on each tab, and one pill under the selected tab that
   the script places (.has-pill) and slides to a clicked tab with transform only. Without the script the .is-on fill above
   stays. Colour and depth only on hover. */
#qms-layer .qms-simpick { position: relative; padding: 5px; border-radius: 14px; box-shadow: 3px 3px 0 #10301d; }
#qms-layer .qms-simpick.is-on-bar { position: sticky; box-shadow: none; }
#qms-layer .qms-simpick a.qms-simpick__opt { position: relative; z-index: 1; gap: 8px; padding: 7px 18px; border-radius: 10px; }
#qms-layer .qms-simpick__pill {
	position: absolute; top: 5px; bottom: 5px; left: 0; width: 0; border-radius: 10px; pointer-events: none; opacity: 0;
	background: #10301d; box-shadow: inset 0 0 0 2px #f4bf54, inset 0 -3px 0 rgba(0, 0, 0, 0.25);
	transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
#qms-layer .qms-simpick.has-pill .qms-simpick__pill { opacity: 1; }
#qms-layer .qms-simpick.has-pill a.qms-simpick__opt.is-on,
#qms-layer .qms-simpick.has-pill a.qms-simpick__opt.is-on:hover { background: transparent; color: #f6eeda; animation: none; }
#qms-layer .qms-simpick__ic { display: inline-grid; place-items: center; opacity: 0.7; transition: opacity 0.25s ease, color 0.25s ease; }
#qms-layer .qms-simpick__ic svg { display: block; }
#qms-layer .qms-simpick a.qms-simpick__opt.is-on .qms-simpick__ic { opacity: 1; color: #f4bf54; }
#qms-layer .qms-simpick__n {
	font-size: 12px; font-weight: 800; line-height: 1.4; border-radius: 999px; padding: 1px 8px;
	background: #fbf6e9; border: 1.5px solid rgba(16, 48, 29, 0.25); color: #586b5a;
	transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
#qms-layer .qms-simpick a.qms-simpick__opt.is-on .qms-simpick__n { background: #f4bf54; border-color: #f4bf54; color: #0a2214; }
/* On the bar and in dark mode the selected tab is gold: the pill turns gold, its ink dark. */
#qms-layer .qms-simpick.is-on-bar .qms-simpick__pill,
html[data-theme="dark"] #qms-layer .qms-simpick .qms-simpick__pill { background: #f4bf54; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
#qms-layer .qms-simpick.is-on-bar.has-pill a.qms-simpick__opt.is-on,
#qms-layer .qms-simpick.is-on-bar.has-pill a.qms-simpick__opt.is-on:hover,
html[data-theme="dark"] #qms-layer .qms-simpick.has-pill a.qms-simpick__opt.is-on,
html[data-theme="dark"] #qms-layer .qms-simpick.has-pill a.qms-simpick__opt.is-on:hover { color: #0a2214; }
#qms-layer .qms-simpick.is-on-bar a.qms-simpick__opt.is-on .qms-simpick__ic,
html[data-theme="dark"] #qms-layer .qms-simpick a.qms-simpick__opt.is-on .qms-simpick__ic { color: #0a2214; }
#qms-layer .qms-simpick.is-on-bar a.qms-simpick__opt.is-on .qms-simpick__n,
html[data-theme="dark"] #qms-layer .qms-simpick a.qms-simpick__opt.is-on .qms-simpick__n { background: #0a2214; border-color: #0a2214; color: #f4bf54; }
#qms-layer .qms-simpick.is-on-bar .qms-simpick__n,
html[data-theme="dark"] #qms-layer .qms-simpick .qms-simpick__n { background: rgba(246, 238, 218, 0.1); border-color: rgba(246, 238, 218, 0.3); color: #f6eeda; }
html[data-theme="dark"] #qms-layer .qms-simpick { box-shadow: none; }
@keyframes qms-simpick-wiggle { 0% { transform: rotate(0); } 30% { transform: rotate(-14deg); } 60% { transform: rotate(8deg); } 100% { transform: rotate(0); } }
#qms-layer .qms-simpick a.qms-simpick__opt.is-on .qms-simpick__ic svg { animation: qms-simpick-wiggle 0.55s ease-out 0.2s both; }
#qms-layer .qms-simpick.is-calm a.qms-simpick__opt.is-on .qms-simpick__ic svg { animation: none; }
/* The switch transition (1.63.0): qimah-major-layer.js sets data-switch on the layer. out-<side>: the screen under the bar slides
   away from the clicked side and fades while the next page loads; in-<side>: the new page's screen arrives from that side. Sideways
   only (nothing rises), the bar and the tabs never move, and the script removes the attribute when it is done. */
@keyframes qms-switch-out { to { opacity: 0; transform: translateX(var(--qms-sw, 0)); filter: blur(2px); } }
@keyframes qms-switch-in { from { opacity: 0; transform: translateX(var(--qms-sw, 0)); filter: blur(2px); } }
#qms-layer[data-switch="out-left"] { --qms-sw: 40px; }
#qms-layer[data-switch="out-right"] { --qms-sw: -40px; }
#qms-layer[data-switch="in-left"] { --qms-sw: -40px; }
#qms-layer[data-switch="in-right"] { --qms-sw: 40px; }
#qms-layer[data-switch^="out-"] .scr { animation: qms-switch-out 0.18s cubic-bezier(0.4, 0, 1, 1) forwards; pointer-events: none; }
#qms-layer[data-switch^="in-"] .scr { animation: qms-switch-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both; }
@media (prefers-reduced-motion: reduce) {
	#qms-layer[data-switch] .scr { animation: none; }
	#qms-layer .qms-simpick__pill { transition: none; }
	#qms-layer .qms-simpick a.qms-simpick__opt.is-on .qms-simpick__ic svg { animation: none; }
}
@keyframes qms-simpick-drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes qms-simpick-drop-bar { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes qms-simpick-pulse {
	0% { box-shadow: 0 0 0 0 rgba(244, 191, 84, 0.7); }
	70% { box-shadow: 0 0 0 14px rgba(244, 191, 84, 0); }
	100% { box-shadow: 0 0 0 0 rgba(244, 191, 84, 0); }
}
@keyframes qms-simpick-fill { from { background-color: transparent; } }
@media (prefers-reduced-motion: reduce) {
	#qms-layer .qms-simpick, #qms-layer .qms-simpick a.qms-simpick__opt.is-on { animation: none; }
}
/* Played once (the script adds .is-calm after the last pulse): coming back from an exam or moving to the bar does not replay
   it. (1,3,0) over the bar's (1,2,0) animation-name. */
#qms-layer .qms-simpick.is-calm, #qms-layer .qms-simpick.is-on-bar.is-calm,
#qms-layer .qms-simpick.is-calm a.qms-simpick__opt.is-on, #qms-layer .qms-simpick.is-calm a.qms-simpick__opt.is-on:hover { animation: none; }
/* THREE chips on a phone (CS101: الفاينل | الميجر | الفاينل لاب, lane N of cs101-final-sim): 136 / 150 / 181px of chips in a 309px
   switch at 390 (measured), and the RTL strip ran the last chip out at the left. Below 600px a three-chip switch drops its icons
   (the gold pill still marks the current one) and tightens its padding, gap and type, so the three fit; a two-chip switch and every
   width from 600px up keep the look above. The pill re-measures itself (its ResizeObserver in qimah-major-layer.js). Kept above the
   exam hide: nothing after it may set display inside the switch. */
@media (max-width: 600px) {
#qms-layer .qms-simpick:has(> a.qms-simpick__opt:nth-of-type(3)) a.qms-simpick__opt { min-width: 0; gap: 5px; padding: 7px 8px; font-size: 16px; }
#qms-layer .qms-simpick:has(> a.qms-simpick__opt:nth-of-type(3)) .qms-simpick__ic { display: none; }
#qms-layer .qms-simpick:has(> a.qms-simpick__opt:nth-of-type(3)) .qms-simpick__n { font-size: 11px; padding: 1px 5px; }
}
/* Inside a paper or the lab (the runner's state 'exam', on the layer as data-sim) the switch steps aside: a timed sitting has
   no one-click way out to the other sim's page load. The intro, the picker and the results keep it. */
#qms-layer[data-sim="exam"] .qms-simpick { display: none; }
/* Until the runner draws .qm-bar (or if it never does), «رجوع» and the toggle sit in their default corner. On a phone the
   centred switch reaches that corner; on a wide screen it does not, but it still shares the corner's band, so the drop
   applies at every width - one rule, no breakpoint to keep in step with the switch width. Once the bar exists the
   script places both buttons on it inline, which wins over this. In an exam the switch is hidden, so the corner is free. */
#qms-layer:not([data-sim="exam"]):has(.qms-simpick) .qms-layer__back,
#qms-layer:not([data-sim="exam"]):has(.qms-simpick) .qms-layer__back:focus,
#qms-layer:not([data-sim="exam"]):has(.qms-simpick) .qms-layer__theme,
#qms-layer:not([data-sim="exam"]):has(.qms-simpick) .qms-layer__theme:focus { margin-top: 82px; margin-bottom: -116px; }

/* The page under the layer does not scroll; the layer does. */
html.qms-open, html.qms-open body { overflow: hidden !important; }
/* MathLive's LaTeX suggestion popover (z 100 by default) sits above the layer. */
html.qms-open { --suggestion-zindex: 100020; }
/* MathLive's keyboard is a child of <body>, outside the layer: lift it (and its variants panel, +1) above it. */
html.qms-open .ML__keyboard { --_keyboard-zindex: 100010 !important; }

/* «رجوع»: on the sim bar's empty right end, pinned with it. Sticky, and taking no room: margin-top is where it rests in the
   flow, margin-bottom gives that and its 34px back, top is where it pins and right is its distance from the layer's right
   edge (a sticky threshold: the layer is its scroll box). qimah-major-layer.js writes all four from the bar; these are the
   default corner for a layer with no bar. */
/* Under the layer's id: the button has focus when the layer opens, and [type="button"]:focus would win otherwise. */
#qms-layer .qms-layer__back,
#qms-layer .qms-layer__back:focus {
	position: sticky; top: 0; right: 34px; z-index: 25; direction: rtl; flex-shrink: 0;
	margin: 24px 0 -58px auto; height: 34px; box-sizing: border-box;
	display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 6px;
	font: inherit; font-size: 15px; font-weight: 700; line-height: 1.3; cursor: pointer;
	background: #10301d; color: #f6eeda; border: 1.5px solid rgba(246, 238, 218, 0.45);
	transition: background 0.12s ease;
}
/* A forest fill, so it reads on the sim bar and on the bare cream layer alike (no bar: a note, or an older runner). */
#qms-layer .qms-layer__back:hover { background: #1b4a2e; color: #f6eeda; }
#qms-layer .qms-layer__back:focus-visible { outline: 3px solid #f4bf54; outline-offset: 2px; }

/* The light/dark toggle, left of «رجوع» on the bar (placed by qimah-major-layer.js); the same forest button, square. */
#qms-layer .qms-layer__theme,
#qms-layer .qms-layer__theme:focus {
	position: sticky; top: 0; right: 140px; z-index: 25; flex-shrink: 0;
	margin: 24px 0 -58px auto; box-sizing: border-box;
	display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
	border-radius: 6px; cursor: pointer; line-height: 1;
	background: #10301d; color: #f6eeda; border: 1.5px solid rgba(246, 238, 218, 0.45);
	transition: background 0.12s ease;
}
#qms-layer .qms-layer__theme:hover { background: #1b4a2e; color: #f6eeda; }
#qms-layer .qms-layer__theme:focus-visible { outline: 3px solid #f4bf54; outline-offset: 2px; }
#qms-layer .qms-layer__theme span { display: inline-flex; }
html[data-theme="dark"] #qms-layer .qms-layer__sun { display: none; }
html:not([data-theme="dark"]) #qms-layer .qms-layer__moon { display: none; }
