/* Steadier page loads (SEO & speed passes, 13–14 Nov 2026). Replaces ml-cls.2.css (kept for rollback).
   Pass 1: the home and /courses pages no longer jump while the main area is redrawn. While the redrawn area
   lacks the SAT / PSAT cards it is kept invisible (space kept, nothing moves) and always shows after 1.5 s. */
@keyframes mlClsShow { to { visibility: visible; } }
main#app:has(> .ml-courses):not(:has(> .ml-prep-pair)) {
  visibility: hidden;
  animation: mlClsShow 0s linear 1.5s forwards;
}
/* Course cards in study order from the first frame (mathlab-v2 courseCopy sets the same order a moment later). */
main#app .ml-courses > section.grade[aria-label="Algebra 2"] { order: 19 !important; }
main#app .ml-courses > section.grade:not(.ml-soon) { order: 20 !important; }
main#app .ml-courses > section.grade[aria-label="Calculus"] { order: 21 !important; }

/* Pass 2: space for what the scripts add a moment after the page appears. Every reserved height is the
   smallest final height measured for visitors and signed-in accounts (13 Nov 2026), so the header never
   ends up taller than it would be anyway.
   Main site header on phones and tablets: the Courses / Search / account row arrives after the logo row. */
@media (max-width: 767.98px) {
  body > header { min-height: 111px; align-content: start; }
}
/* SAT / PSAT pages: the section bar (Overview · Learn & Practice · …) is added under the header.
   The server marks these pages on <html> (typography-entry.mjs startClass). */
html.ml-secbar body:not(:has(> .mlsec-bar)) > header { margin-bottom: 46px; }
html.ml-secbar-chooser body:not(:has(> .mlsec-bar)) > header { margin-bottom: 56px; }
/* Rebuilt course pages (lessons, course pages, practice): the Courses / Search / theme / account buttons
   join the top bar after it is drawn; on narrow screens they take extra rows. */
.wrap > header.topbar { align-content: flex-start; }
@media (max-width: 414px) { .wrap > header.topbar:has(> nav.tabs) { min-height: 223px; } }
@media (min-width: 415px) and (max-width: 600px) { .wrap > header.topbar:has(> nav.tabs) { min-height: 173px; } }
@media (min-width: 601px) { .wrap > header.topbar:has(> nav.tabs) { min-height: 123px; } }
@media (max-width: 540px) { .wrap > header.topbar:not(:has(> nav.tabs)) { min-height: 121px; } }
/* SAT/PSAT pages drawn by a layer (My Progress, Official Resources, the Math Course): the page's own content is
   hidden from the start, so the footer first sat right under the header and was then pushed down. It stays
   invisible until the layer's section is on the page (and always shows after 2 s). */
html.ml-sec-on body:not(:has(#ml-sec:not([hidden]))) > footer,
html.ml-course-on body:not(:has(#ml-course)) > footer {
  visibility: hidden;
  animation: mlClsShow 0s linear 2s forwards;
}
/* 14 Nov 2026: the home page's visitor sign-up section (ml-signup) is added at the top after the account check,
   which pushed the whole page down (layout shift 0.77 on phones). For a likely visitor (html.ml-likely-visitor, set
   by ml-dedupe.3.js) the home page's main area stays invisible until that section is in (space kept; always
   visible again after 1.5 s). Signed-in browsers are not affected. */
html.ml-home.ml-likely-visitor main#app:not(:has(> .ml-su-hero)) {
  visibility: hidden;
  animation: mlClsShow 0s linear 1.5s forwards;
}
@media print {
  main#app, body > footer { visibility: visible !important; animation: none !important; }
  body > header, .wrap > header.topbar { min-height: 0 !important; margin-bottom: 0 !important; }
}
