/* The hub at every width (Mitch, 2026-11-13: "work on mobile and all other
   form factors", for him and for students). This replaces the teacher
   side's 1200px minimum (MQ23). Loaded last, so it adjusts the screens'
   own files; tokens only. Check with tools/dev/reach_widths.py, which opens
   every screen at 360, 390, 844x390, 768, 1024, 1280 and 1920 wide. */

/* ---- the teacher's top bar -------------------------------------------- */
.navmenu { position: relative; display: none; }
.menu-toggle {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 40px; padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-md); background: none; color: var(--on-band-muted);
  font: var(--t-body); font-weight: var(--w-medium); white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
@media (hover: hover) { .menu-toggle:hover { color: var(--on-band); background: rgba(211, 255, 233, .08); } }
.navmenu.open .menu-toggle, .menu-toggle[aria-current="page"] { color: var(--white); background: rgba(211, 255, 233, .12); }
.menu-panel {
  --focus-shadow: var(--focus-ring);
  position: absolute; top: calc(100% + var(--s-2)); right: 0; z-index: 60;
  width: 260px; max-width: calc(100vw - 2 * var(--s-4));
  display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-2);
  background: var(--surface); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--e4);
  animation: fade 150ms var(--ease);
}
.menu-item {
  display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 0 var(--s-3);
  border-radius: var(--r-md); color: var(--ink); text-decoration: none; font-weight: var(--w-medium);
}
.menu-item .icon { color: var(--primary); }
@media (hover: hover) { .menu-item:hover { background: var(--surface-quiet); } }
.menu-item[aria-current="page"] { background: var(--surface-mint); }

@media (max-width: 1179px) {
  .topbar.teacher { gap: var(--s-3); }
  .topbar.teacher .mainnav { margin-left: var(--s-2); }
  .topbar.teacher .mainnav > .nav-more { display: none; }
  .topbar.teacher .navmenu { display: block; }
}
@media (max-width: 720px) {
  .topbar.teacher { gap: var(--s-2); padding-inline: var(--s-4); }
  .topbar.teacher .brand > img:first-child { display: none; }
  .topbar.teacher .brand .brand-ed { display: block; }
  .topbar.teacher .brand { min-width: 44px; justify-content: center; }
  .topbar.teacher .mainnav { margin-left: 0; flex: 1; }
  .topbar.teacher > .grow { display: none; }
  .topbar.teacher .nav-switch { flex: 1; max-width: none; }
  .topbar.teacher .nav-switch > svg:first-child,
  .topbar.teacher .nav-word,
  .topbar.teacher .who > span:first-child { display: none; }
  .topbar.teacher .mainnav > a, .topbar.teacher .nav-switch, .topbar.teacher .menu-toggle { padding: 0 var(--s-2); }
  .topbar.teacher .switcher { min-width: 0; flex: 1; }
  .topbar.teacher .mainnav > a.nav-mark { flex-shrink: 0; }
}

/* the switcher and the menus: a sheet under the bar on a phone */
@media (max-width: 720px) {
  .sw-panel, .menu-panel, .acct-panel {
    position: fixed; top: calc(var(--topbar-h) + var(--s-2)); left: var(--s-3); right: var(--s-3);
    width: auto; max-width: none;
  }
  .sw-list { max-height: calc(100vh - var(--topbar-h) - 200px); max-height: calc(100dvh - var(--topbar-h) - 200px); }
}

/* ---- page structure on small screens (as the student view has had since
   2026-10-16, now everywhere) ------------------------------------------- */
@media (max-width: 720px) {
  .hero-in { padding-inline: var(--s-4); }
  .hero::after { right: -120px; }
  .page-body { padding: var(--s-5) var(--s-4) var(--s-12); gap: var(--s-5); }
  .card { padding: var(--s-5) var(--s-4); }
  .card.flush { padding: 0; }
  .hero.size-lg .hero-in { padding-bottom: var(--s-8); }
  .hero.size-lg h1 { font: var(--t-h1); }
  .hero h1 { overflow-wrap: anywhere; }
  /* the hero's actions go under its words, and wrap */
  .hero-row { flex-wrap: wrap; }
  .hero-actions { flex-shrink: 1; flex-wrap: wrap; width: 100%; }
  .toast { min-width: 0; }
}

/* ---- touch: every control a fingertip can hit is 44px, on every page
   (the student view's rules in screens.css, now for the teacher too) ---- */
@media (any-pointer: coarse) {
  .topbar .brand, .topbar .mainnav > a, .nav-switch, .menu-toggle, .view-chip { min-height: 44px; }
  .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
  .crumbs ol { margin-bottom: var(--s-2); margin-top: calc(-1 * var(--s-2)); }
  .btn-small { --btn-h: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .toast-x { width: 44px; height: 44px; }
  .toast-action { height: 44px; }
}

/* ---- Overview: below 900px each student is a card, not a table row
   (a phone would scroll a 980px table sideways) ------------------------ */
@media (max-width: 899px) {
  .ov-scroll { overflow: visible; }
  .ov-table, .ov-table tbody, .ov-table tr, .ov-table td { display: block; min-width: 0; width: auto; }
  .ov-table thead { display: none; }
  .ov-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3) var(--s-4);
    padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); }
  .ov-table tbody tr:first-child { border-top: 0; }
  .ov-table td, .ov-table :is(th, td):nth-child(n) { padding: 0; border: 0; width: auto; }
  .ov-table td[data-label] { grid-column: 1 / -1; }
  .ov-table td[data-label]:not(:has(.ov-pill))  { display: none; }
  .ov-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: var(--s-2);
    font: var(--t-caption); color: var(--muted); }
  .ov-next { align-self: center; }
}

/* ---- All skills: one column of skills, then (phone) each skill's progress
   on its own line under the name ---------------------------------------- */
@media (max-width: 1023px) {
  .as-rows { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .as-unit-head { flex-wrap: wrap; gap: var(--s-2) var(--s-4); padding: var(--s-4); }
  .as-unit-head h2 { flex: 1 0 100%; }
  .as-bar.big { width: auto; flex: 1 1 120px; }
  .as-topic { padding: var(--s-4); }
  .as-topic-head, .as-quiet summary { flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
  .as-topic h3, .as-quiet summary h3 { flex: 1 0 100%; }
  .as-quiet summary .caption { flex: 1; }
  .as-row { grid-template-columns: 30px minmax(0, 1fr) auto; row-gap: var(--s-1); padding-block: var(--s-2); }
  .as-row > :nth-child(3) { grid-column: 2; grid-row: 2; }
  .as-row > :nth-child(4) { grid-column: 3; grid-row: 1 / span 2; }
}
/* a segmented control fills the width and its words wrap, rather than
   running off the screen */
@media (max-width: 720px) {
  .seg { display: flex; max-width: 100%; }
  .seg button { flex: 1 1 auto; white-space: normal; height: auto; min-height: 36px; padding: var(--s-1) var(--s-2); line-height: 1.2; }
}

/* ---- marking (practice, To check, the diagnostic): the photo above the
   lines below 1024px; on a phone the before/after rows and the save bar
   reflow, and the key hints go (no keyboard) --------------------------- */
@media (max-width: 1023px) {
  .mk-layout, .dg-layout, .mk-choose { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .mk-photo { position: relative; top: auto; height: min(70vh, 640px); min-height: 320px; }
  .mk-photo:has(.mk-photo-none) { height: auto; min-height: 0; }
  .mk-photo:has(.mk-photo-none) .mk-photo-view { padding-block: var(--s-4); }
}
@media (max-width: 720px) {
  .mk-compare { grid-template-columns: minmax(0, 1fr); grid-column: 1 / -1; }
  .mk-sol { min-width: 0; overflow-x: auto; }
  .mk-moves, .mk-moves.compact, .mk-moves:not(.compact) { grid-template-columns: minmax(0, 1fr) auto auto; column-gap: var(--s-3); }
  .mk-move-name { grid-column: 1 / -1; }
  .mk-move-cards { display: none; }
  .mk-effect { padding: var(--s-4); }
  .mk-quiz-q { padding: var(--s-4); }
  .mk-savebar { flex-wrap: wrap; padding: var(--s-2) var(--s-3); }
  .mk-save-info, .mk-save-state { flex: 1 1 100%; }
  .mk-savebar .btn-big { flex: 1 1 auto; }
  .mk-keys, .mk-photo-btn kbd, .btn kbd { display: none; }
}

/* ---- two-column screens go to one column: Book content and its review,
   the weekly email, the skill picker; the side panel stops being sticky -- */
@media (max-width: 1023px) {
  .cl-cols, .cr-cols, .em-cols, .sp-cols { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .cr-side, .em-side { position: static; }
  .cl-nav { display: none; }   /* the topic list repeats the page's own headings; the page scrolls instead */
}
@media (max-width: 720px) {
  .cl-tools { flex-wrap: wrap; gap: var(--s-3); }
  .cl-tools .search { max-width: none; margin-left: 0; flex: 1 1 100%; }
  .cl-topic-head { flex-wrap: wrap; align-items: flex-start; gap: var(--s-3); padding: var(--s-4); }
  .cl-topic-prog { align-items: flex-start; }
  .cl-row { gap: var(--s-3); }
  .start-card { flex-direction: column; align-items: flex-start; gap: var(--s-5); padding: var(--s-5); }
  .start-card .btn { white-space: normal; height: auto; min-height: var(--btn-h); }
  .em-env dl div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* ---- the student's bar on a narrow phone: "Lessons", "Sessions", "PSMT"
   and the Exit chip as its icon, so all three fit at 360px ------------- */
.nav-long { white-space: pre; }
.nav-short { display: none; }
@media (max-width: 420px) {
  .topbar.student-mode .nav-long { display: none; }
  .topbar.student-mode .nav-short { display: inline; }
  .topbar.student-mode .view-chip .vc-exit { padding: 0 var(--s-2); font-size: 0; gap: 0; }
  .topbar.student-mode .view-chip .vc-exit svg { font-size: 16px; }
  .topbar.student-mode .acct-btn > .icon { display: none; }
}

/* a hero fact longer than the screen (an email address) may break inside
   itself; the others still break only between facts */
@media (max-width: 720px) {
  .hero-sub .hs-part { max-width: 100%; overflow-wrap: anywhere; }
}

/* ---- the interactions gallery: the live figure first, the list under it;
   on a phone "fill" is upright, so the controls fit under the figure ---- */
@media (max-width: 1023px) {
  .ixg { grid-template-columns: minmax(0, 1fr); }
  .ixg-view { order: -1; }
  .ixg-list { position: static; max-height: 50vh; }
}
@media (max-width: 720px) {
  .ixg-frame.is-fill { aspect-ratio: 3 / 4; max-height: calc(100vh - var(--topbar-h) - var(--s-8)); }
}

/* ---- touch, the rest: icon-only links in the bar, small icon buttons,
   marking's right/wrong, segmented buttons; text links (a name, a pill)
   keep their look and get an invisible hit area ------------------------ */
@media (any-pointer: coarse) {
  .topbar .mainnav > a, .menu-toggle, .view-chip { min-width: 44px; justify-content: center; }
  .icon-btn.small, .icon-btn.bare.small { width: 44px; height: 44px; }
  .mk-btn { width: 44px; height: 44px; }
  .seg button { min-height: 44px; }
  .sp-unit-name { min-height: 44px; }
  .ov-pill { min-height: 44px; }
  .ov-name, .as-name, .ov-check { position: relative; }
  .ov-name::after, .as-name::after, .ov-check::after { content: ''; position: absolute; inset: -10px -4px; }
}

/* ---- the teaching view on a phone (it is cast from a laptop or tablet,
   but Mitch may check a page on his phone): the bar takes two lines, the
   page fits the width when upright, and the bar's arrows turn the pages
   (the big side arrows would sit on the page) ------------------------- */
@media (max-width: 600px) {
  .teach-bar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; row-gap: var(--s-1); padding: var(--s-2) var(--s-3); }
  .tb-lessons { flex: 1 1 0; }
  .tb-pager { margin-right: auto; }
  .stage-edge { display: none; }
  .teach-stage { padding: var(--s-3) var(--s-2) var(--s-4); }
  .teach.is-full:not(.is-idle) .teach-stage { padding-top: calc(var(--topbar-h) * 2 + var(--s-3)); }
}
@media (max-width: 600px) and (orientation: portrait) {
  .teach-stage { align-items: flex-start; overflow-y: auto; }
  .sheet-wrap { height: auto; width: 100%; }
  .teach-stage .sheet { height: auto; width: 100%; max-width: 100%; }
}
@media (any-pointer: coarse) {
  .tb-back { height: 44px; min-width: 44px; justify-content: center; }
  .tb-lessons .lesson-tile { min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
  .teach-bar .btn-small { --btn-h: 44px; height: 44px; }
}

/* ---- dialogs on a phone: the whole width less a margin, less padding;
   the student form in one column (each parent's name over their email,
   the remove button beside them) -------------------------------------- */
@media (max-width: 720px) {
  .overlay { padding: var(--s-3); }
  .dialog, .student-dialog { padding: var(--s-5) var(--s-4); max-height: calc(100vh - 2 * var(--s-3)); max-height: calc(100dvh - 2 * var(--s-3)); }
  .sform-grid { grid-template-columns: minmax(0, 1fr); }
  .parents { grid-template-columns: minmax(0, 1fr) 44px; grid-auto-flow: row dense; }
  .parents > label.field { grid-column: 1; }
  .parents > .parent-remove { grid-column: 2; grid-row: span 2; }
  .teach-prompts, .teach-panel { width: auto; left: var(--s-3); right: var(--s-3); }
}

/* on a phone (or any short screen) a dialog's buttons sit at the end of the
   form rather than stick to the bottom: stuck, they took a third of a
   sideways phone and covered the fields under them */
@media (max-width: 720px), (max-height: 500px) {
  .dialog :is(.sform-foot, .br-foot) { position: static; margin-bottom: 0; padding-bottom: 0; flex-wrap: wrap; }
}
@media (any-pointer: coarse) {
  .seg button { min-width: 44px; }
  .teach-bar .btn-small { min-width: 44px; }
  .as-quiet summary { min-height: 44px; }
}
