/* The shell. Colours all come from the --ui-* block in theme.css, so this file
   follows whatever palette is chosen.

   Ported from Chess Bender's shell.css, 2026-10-01. What went is the menu
   drawer (the hamburger): Chess Bender needed it for the screens that did not
   fit on the bar — Lessons, How To, About and Admin — and Language Bender has
   five tabs, all of which fit. The Admin tab is on the bar for an
   administrator instead. What went with it: the backend status dot (the
   server here is the thing that served this page). */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
}

/* The `font:` shorthand sits on `body`, not on `html, body` together: on the
   root it would pin rem to 14px here while it is 16px inside every iframe, and
   throw away the reader's own browser text size in the one document that
   cannot be made bigger. */
body {
  display: flex;
  flex-direction: column;
  font: 1rem/1.5 var(--ui-font);   /* 16px at the default root size (14px before 2026-10-13) */
}

/* ── top bar ────────────────────────────────────────────────────────────── */

.shell-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  height: 4rem;
  flex: 0 0 auto;
  min-width: 0;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-line);
  /* Its menus (Test as a student) open downwards over the link bar and the tab
     pages. In the Glass theme every bar is its own layer, so the bar itself
     must sit above them, or a later bar paints over the open menu (José,
     2026-10-20). Below the sign-in card (50), which covers everything. */
  position: relative;
  z-index: 40;
}

/* ── the mark ───────────────────────────────────────────────────────────────
   A speech bubble in a purple cloud. There are two of every file — see
   test/shell/make-icons.mjs — because the bubble is near-black and the default
   theme is dark, so a dark theme gets the one with the bubble in white. The
   swap is in theme.css (--logo-mark) rather than in the markup: a stylesheet
   already knows which theme is on, and doing it in script would flash the
   wrong one on every page load.

   A <span> with a background rather than an <img>, deliberately: a
   background-image has no wrong fallback — it either draws or it does not. */
.shell-mark {
  width: 2.375rem;
  height: 2.375rem;
  flex: 0 0 auto;
  background: var(--logo-mark) center / contain no-repeat;
}

.shell-brand {
  font: 800 1.125rem/1 var(--ui-display, var(--ui-font));
  letter-spacing: 0.01em;
  color: var(--ui-text);
  white-space: nowrap;
}

.shell-wordmark {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 0 0 auto;
}

/* Bigger, and above the wordmark: on the sign-in screen this is the only thing
   on the page that says whose app it is. */
.signin-mark {
  width: 6rem;
  height: 6rem;
  background: var(--logo-mark) center / contain no-repeat;
}

.grow { flex: 1; }

/* ── why every :hover in this app is wrapped ───────────────────────────────
   A touch browser has no pointer to take away, so it fakes one: it applies
   :hover on tap and leaves it applied until you touch something else — the
   "why is that button still highlighted" bug. `@media (hover: hover)` says
   "only where a real pointer can hover", which is the fix, and it changes
   nothing at all on a mouse.

   Two rules when you add a hover rule:

   1. Do not put :hover and :focus-visible in the same selector list and wrap
      the pair. The guard would take the keyboard's focus ring away too.
   2. A guard is not a fix for a rule that REVEALS something. If the only way
      to see a control is to hover it, give it a second rule under
      `@media (hover: none)`. */

/* ── tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0.375rem;
  height: 100%;
  align-items: center;
  /* The strip takes the leftover width and is its own horizontal scroller, so
     nothing can be pushed past the right-hand edge of the window. */
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

/* A tab is a pill with its icon; the one you are on is filled with the accent. */
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  white-space: nowrap;
  background: none;
  border: none;
  border-radius: 999px;
  color: color-mix(in srgb, var(--ui-text) 78%, var(--ui-dim));
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.5625rem 1rem;
  cursor: pointer;
  transition: background var(--anim-fade), color var(--anim-fade);
}
.tabicon {
  width: 1.25rem; height: 1.25rem; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

@media (hover: hover) { .tab:hover:not(.is-active) { color: var(--ui-text); background: var(--ui-btn); } }
.tab:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
/* `display: inline-flex` above would beat the browser's own [hidden] rule. A
   switched-off tab (shell.mjs `hidden`, Pro for now) must actually vanish. */
.tab[hidden] { display: none; }

.tab.is-active {
  color: var(--ui-accent-text);
  background: var(--ui-accent-fill, var(--ui-accent));
  font-weight: 700;
}

/* The Study tab's "due now" count. Hidden entirely at zero rather than shown as
   a 0 — a badge that is always there stops being a signal. */
.duebadge {
  min-width: 1.5rem;
  padding: 0 0.4375rem;
  border-radius: 999px;
  background: var(--due-now);
  color: #ffffff;
  font: 800 max(0.8125rem, var(--text-min))/1.375rem var(--ui-num, var(--ui-font));
  text-align: center;
}
.tab.is-active .duebadge { background: #ffffff; color: var(--ui-accent-fill, var(--ui-accent)); }

/* Something new on the Announcements tab: a dot, not a number — there is only
   ever one announcement. In the accent, because news is not an alarm. */
.newdot {
  width: 0.5rem;
  height: 0.5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ui-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ui-accent) 30%, transparent);
}

/* ── header tools ───────────────────────────────────────────────────────── */

.tools {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}

/* ── panes ──────────────────────────────────────────────────────────────── */

.panes {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}

.pane {
  position: absolute;
  inset: 0;
  /* Hidden rather than unmounted: switching tabs must not reload a study
     session half way through. */
  visibility: hidden;
  opacity: 0;
}

.pane.is-active {
  visibility: visible;
  opacity: 1;
}

.pane iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: var(--ui-bg);
}

/* Under Glass the frames are see-through too, or the picture would stop at the
   bar. Each frame paints its own copy of the picture behind its own panels
   (theme.css, the Glass section). */
:root[data-theme="glass"] .pane iframe { background: transparent; }

/* ── narrowing down ──────────────────────────────────────────────────────── */

/* The wordmark goes, the mark stays: it says the same thing in a fifth of the
   room. */
@media (max-width: 1500px) {
  .shell-wordmark .shell-brand { display: none; }
  .tab { padding: 0.5rem 0.75rem; gap: 0.4375rem; }
  .tabs { gap: 0.25rem; }
  /* The switch beside it already says which view this is. */
  .viewswitch-tag { display: none; }
}

/* The strip takes a row of its own here, full width, and scrolls sideways in
   it. Sharing the row does not work at a phone's width: the account controls
   on the right take what they need and the strip is squeezed to nothing —
   found in Chess Bender's Browser pane at 375px. */
@media (max-width: 760px) {
  .shell-bar {
    gap: 0.625rem 0.75rem;
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.375rem;
    padding-bottom: 0.25rem;
  }
  .shell-bar > .tabs {
    order: 3;
    flex: 1 0 100%;
    height: 3rem;
  }
  .tab { padding: 0.5rem 0.875rem; }
  .shell-bar > .tools { margin-left: auto; }
}

/* ── every tab in sight (tabfit.js; José, 2026-10-19) ─────────────────────
   tabfit.js measures and picks one of these, roomiest first, so the strip
   never has to scroll a tab out of view. */
.shell-bar.tabs-tight > .tabs { gap: 0.125rem; }
.shell-bar.tabs-tight .tab { padding: 0.5rem 0.625rem; gap: 0.375rem; font-size: 0.9375rem; }

/* A row of their own, under the mark and the tools (as on a phone above). */
.shell-bar.tabs-row {
  gap: 0.375rem 0.75rem;
  flex-wrap: wrap;
  height: auto;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}
.shell-bar.tabs-row > .tabs { order: 3; flex: 1 0 100%; height: auto; min-height: 3rem; }
.shell-bar.tabs-row > .tools { margin-left: auto; }

/* A phone: each tab its icon over its name, sharing the row; if even that is
   too wide, a second line rather than a tab out of sight. */
.shell-bar.tabs-stack { padding-left: 0.5rem; padding-right: 0.5rem; }
.shell-bar.tabs-stack > .tabs { flex-wrap: wrap; gap: 0.125rem; overflow: visible; }
.shell-bar.tabs-stack .tab {
  position: relative;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  gap: 0.125rem;
  min-width: 3.25rem;
  padding: 0.375rem 0.25rem 0.3125rem;
  border-radius: 0.875rem;
  font-size: max(0.75rem, var(--text-min));
  line-height: 1.15;
}
.shell-bar.tabs-stack .tabicon { width: 1.375rem; height: 1.375rem; }
.shell-bar.tabs-stack .tab .duebadge,
.shell-bar.tabs-stack .tab .newdot { position: absolute; top: 0.1875rem; left: calc(50% + 0.5rem); }
.shell-bar.tabs-stack .tab .duebadge { min-width: 1.25rem; padding: 0 0.3125rem; font-size: 0.6875rem; line-height: 1.125rem; }

/* Below this the username goes and Sign out stands alone, with the picture.
   Sign out is the one control that must survive, because an account you
   cannot get out of is a trap on a shared classroom computer. */
@media (max-width: 520px) {
  .accountwho { display: none; }
}

/* ── the sign-in screen ──────────────────────────────────────────────────── */

/* Off by default in the stylesheet, on only by class. The one card that ever
   covers this app must not be able to do it by accident. */
.signin { display: none; }

.signin.on {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  padding: 1rem;
  background: var(--ui-bg);
  z-index: 50;
}

.signin-card {
  display: grid;
  justify-items: center;
  gap: 0.875rem;
  padding: 2.25rem 2.5rem;
  max-width: 32rem;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-lg, var(--ui-radius));
  box-shadow: var(--card-shadow);
  background: var(--ui-panel);
  text-align: center;
}

.signin-card p { margin: 0; color: var(--ui-dim); font-size: 1rem; }

/* The card is the first thing anybody sees, so it says what they would be
   signing in to, not merely "Sign in to continue." */
.signin-title {
  margin: 0;
  font: 800 1.75rem/1.2 var(--ui-display, var(--ui-font));
  color: var(--ui-text);
  max-width: 22ch;
}
.signin-sell { max-width: 40ch; line-height: 1.6; }

.signin-note { font-size: 0.875rem; max-width: 36ch; }

/* Username and password. */
.signin-form {
  display: grid;
  gap: 0.375rem;
  width: min(20rem, 100%);
  text-align: left;
}
.signin-switch { display: flex; gap: 0.375rem; justify-content: center; margin-bottom: 0.375rem; }
.signin-switch .btn.is-on { background: var(--ui-accent); color: var(--ui-accent-text); border-color: var(--ui-accent); }
.signin-label { font-size: 0.875rem; font-weight: 700; color: var(--ui-dim); margin-top: 0.375rem; }
.signin-form input {
  font: inherit;
  font-size: 1.0625rem;
  padding: 0.6875rem 0.875rem;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-bg);
  color: var(--ui-text);
}
.signin-form input:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.signin-go { margin-top: 0.5rem; justify-self: stretch; }
.signin-form .signin-note { max-width: none; }
.signin-remember { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; color: var(--ui-text); margin-top: 0.375rem; cursor: pointer; }
.signin-remember input { width: 1rem; height: 1rem; }
/* What the server said: a red box right above the button, not grey text below the fold. */
.signin-card .signin-note.bad {
  color: var(--learn-wrong);
  background: color-mix(in srgb, var(--learn-wrong) 12%, var(--ui-panel));
  border: 1px solid color-mix(in srgb, var(--learn-wrong) 45%, transparent);
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  margin: 0.5rem 0 0;
  font-weight: 600;
  font-size: 0.9375rem;
}
.signin-card .signin-note.bad[hidden] { display: none; }
/* What is wrong with the username, under its box, while it is typed. */
.signin-fieldnote { margin: 0.125rem 0 0; font-size: 0.875rem; font-weight: 600; color: var(--learn-shown); }
.signin-fieldnote[hidden] { display: none; }

/* When the sign-in screen is up, the chrome behind it is not merely covered —
   it is gone, so nothing behind can take focus or be tabbed into. */
body.signed-out .panes,
body.signed-out .tabs,
body.signed-out .tools,
body.signed-out .linkbar,
body.signed-out .testbar { display: none; }

/* ── the program ↔ website bar (linkbar.js) ─────────────────────────────── */

/* Tinted by what it says: green up to date, amber "press Update", red
   offline. The tone is linkbar.js's (data-tone on the bar and its dot). */
.linkbar {
  --tone: var(--ui-dim);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.875rem;
  flex: 0 0 auto;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--ui-line);
  background: color-mix(in srgb, var(--tone) 10%, var(--ui-panel));
  font-size: 0.9375rem;
}
.linkbar[data-tone="on"] { --tone: var(--status-up, #2e9d5b); }
.linkbar[data-tone="off"] { --tone: var(--status-down, #c0392b); }
.linkbar[data-tone="warn"] { --tone: var(--ui-gold, #e0a030); }
.linkbar[hidden] { display: none; }
.linkdot {
  width: 0.625rem; height: 0.625rem; flex: none;
  border-radius: 50%;
  background: var(--ui-dim);
}
.linkdot[data-tone="on"] { background: var(--status-up, #2e9d5b); box-shadow: 0 0 0 4px color-mix(in srgb, var(--status-up, #2e9d5b) 25%, transparent); }
.linkdot[data-tone="off"] { background: var(--status-down, #c0392b); box-shadow: 0 0 0 4px color-mix(in srgb, var(--status-down, #c0392b) 25%, transparent); }
.linkdot[data-tone="warn"] { background: var(--ui-gold, #e0a030); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-gold, #e0a030) 25%, transparent); }
.linkwho { font-weight: 700; color: var(--ui-dim); align-self: center; }
/* Update, when it is asked for: gold and raised, the one thing to press. */
.linkbar .btn.primary { background: var(--ui-gold); color: var(--ui-gold-text); box-shadow: 0 3px 0 color-mix(in srgb, var(--ui-gold) 60%, #000); }
.linktext { flex: 1 1 18rem; min-width: 0; }
.linkactions { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.linkactions:empty { display: none; }

/* A phone (José, 2026-10-26: "Some of my students don't like studying from
   their computer"): the tabs and this bar never scroll away, and on a phone
   they took a third of the screen. The student's name and Sign out are in
   Settings, so the bar leaves them out there and is a line or two of
   smaller text. What needs pressing — a new version, Download — stays. */
@media (max-width: 600px) {
  .linkbar { padding: 0.375rem 1rem; gap: 0.25rem 0.625rem; font-size: 0.8125rem; line-height: 1.35; }
  .linkbar .linkaccount { display: none; }
  .linktext { flex-basis: 0; }
}

/* iPhone and iPad in Safari: "put it on your Home Screen" (shell.js). */
.hometip {
  display: flex; align-items: center; gap: 0.5rem 0.75rem; flex: 0 0 auto;
  padding: 0.375rem 1rem;
  border-bottom: 1px solid var(--ui-line);
  background: color-mix(in srgb, var(--ui-accent) 14%, var(--ui-panel));
  font-size: 0.8125rem; line-height: 1.35;
}
.hometip[hidden] { display: none; }
.hometiptext { flex: 1 1 0; min-width: 0; }
body.signed-out .hometip { display: none; }

/* ── "Test as a student" ───────────────────────────────────────────────────
   The teacher's picker on the bar, and the gold strip under it while a test
   is on (linkbar.js). Gold because it is the one state of this app that is
   not what it seems: the library on screen is somebody else's. */
.testbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  flex: 0 0 auto;
  padding: 0.625rem 1.25rem;
  background: var(--ui-gold);
  color: var(--ui-gold-text);
  font-size: 1rem;
}
.testbar[hidden] { display: none; }
.testicon { width: 1.5rem; height: 1.5rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.testtext { flex: 1 1 22rem; min-width: 0; }
.testtext b { font-weight: 800; }
.testbar .testend { background: var(--ui-gold-text); color: var(--ui-gold); border-color: transparent; font-weight: 800; }
/* "Review with the student" (2026-10-29): the box on the strip. */
.testreview { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 800; cursor: pointer; white-space: nowrap; }
.testreview input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--ui-gold-text); }

/* While reviewing with the student, sharing the screen (linkbar.js): the app
   as the student sees their own — nothing of the teacher's, nothing that says
   "test". Only the plain "End the review" stays. */
html.is-reviewing .testbar,
html.is-reviewing .linkbar,
html.is-reviewing [data-view-switch],
html.is-reviewing [data-account-switch] { display: none !important; }
.reviewend {
  position: relative;
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.875rem;
  border: 1px solid var(--ui-line);
  background: var(--ui-btn);
  color: var(--ui-text);
  font: inherit; font-size: 0.9375rem; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.reviewend svg { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.reviewend:disabled { opacity: 0.6; cursor: default; }
/* Answers that cannot reach the student's library yet: a small dot, the reason in the tooltip. */
.reviewend.is-waiting::after {
  content: ''; position: absolute; top: 0.25rem; right: 0.25rem;
  width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ui-gold);
}
@media (hover: hover) { .reviewend:hover:not(:disabled) { background: var(--ui-btn-hover); } }

.testswitch { position: relative; display: inline-flex; }
.testswitch[hidden] { display: none; }
.testpick {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.875rem;
  border: 1px solid var(--ui-line);
  background: var(--ui-btn);
  color: var(--ui-text);
  font: inherit; font-size: 0.9375rem; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.testpick svg { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.testpick .caret { width: 0.875rem; height: 0.875rem; }
.testpick.is-on { border: 2px solid var(--ui-gold); background: color-mix(in srgb, var(--ui-gold) 14%, var(--ui-panel)); color: color-mix(in srgb, var(--ui-gold) 60%, var(--ui-text)); }
/* On a phone the strip under the bar says who; the picker keeps its eye. */
@media (max-width: 560px) {
  .testpick > span { display: none; }
  .tools { flex-wrap: wrap; justify-content: flex-end; }
}
@media (hover: hover) { .testpick:hover { background: var(--ui-btn-hover); } }
.testmenu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 60;
  width: min(20rem, calc(100vw - 2rem));
  max-height: min(28rem, calc(100vh - 6rem)); overflow: auto;
  display: grid; gap: 0.25rem;
  padding: 0.5rem;
  border-radius: 1.125rem;
  background: var(--ui-panel);
  border: 1px solid var(--ui-line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.testmenu[hidden] { display: none; }
.testmenu .testhead { padding: 0.5rem 0.625rem 0.25rem; color: var(--ui-dim); font-size: 0.8125rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.testmenu .testnote { padding: 0.25rem 0.625rem 0.5rem; color: var(--ui-dim); font-size: 0.875rem; margin: 0; }
.testopt {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; padding: 0.5rem 0.625rem;
  border: 0; border-radius: 0.75rem;
  background: transparent; color: var(--ui-text);
  font: inherit; text-align: left; cursor: pointer;
}
@media (hover: hover) { .testopt:hover { background: var(--ui-btn); } }
.testopt[aria-current="true"] { background: var(--ui-accent-soft); }
.testopt .who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.testopt .who b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.testopt .who small { color: var(--ui-dim); font-size: 0.875rem; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 2.125rem; height: 2.125rem; border-radius: 50%;
  font-weight: 800; font-size: 0.9375rem;
  background: var(--av, var(--ui-accent-fill)); color: var(--av-ink, #ffffff);
}

.linkdialog {
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-panel);
  color: var(--ui-text);
  padding: 1.5rem;
  width: min(24rem, calc(100vw - 2rem));
}
.linkdialog::backdrop { background: rgb(0 0 0 / 0.45); }
.linktitle { margin: 0 0 0.25rem; font: 700 1.0625rem/1.3 var(--ui-font); }
.linkdialogrow { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; }
