/* =============================================================================
   The signed-out screen — "Broadsheet".

   Composed like the front page of a serious paper: a masthead with the real
   wordmark over a thick-and-thin rule, one oversized Literata headline set
   flush left, a ruled margin column (the standfirst, then the sign-in form,
   set as a typeset block), a stack of real Songon index cards dropped onto
   the headline's last line, then three numbered sections, each with one
   anchor: the register's five marks on ledger lines, the «Нийтлэх» hinge
   between teacher and parent, and the brand line.

   Scope: every rule below matches only on the signed-out screen
   (body[data-screen="loginView"], #loginView, or .bs-/.deck-/.fc- classes that
   exist only there). The one exception is the brand lockup in the top bar —
   the real wordmark with «портал» on its baseline — which the app shows too.
   portal.css, reset.css and variables.css are untouched.

   Motion follows research/motion.md (Emil Kowalski): transform and opacity
   only, every duration under 300ms, custom curves, nothing moves under
   prefers-reduced-motion, hover only on fine pointers. The deck is the only
   thing that animates; the headline, form and language switch never do.
   ============================================================================= */

:root {
  /* Curves — Emil Kowalski's, verbatim. Durations all < 300ms. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);       /* enter, exit, direct response */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);   /* already on screen, moving */
  --dur-press: 160ms;
  --dur-fade: 150ms;
  --dur-exit: 200ms;
  --dur-move: 240ms;
  --dur-flip: 260ms;
  --stagger: 50ms;
  --press-scale: 0.97;
  --press-scale-lg: 0.98;
  --enter-scale: 0.95;
  --enter-shift: 8px;
  --flip-perspective: 1200px;

  /* Warm paper, near-black ink; indigo is ink, never a fill. */
  --bs-paper: #f5f1e8;
  --bs-field-bg: #fbf9f4;
  --bs-ink: #1b1813;
  --bs-ink-2: #46413a;
  --bs-ink-3: #6a635a;
  --bs-hair: #d6cdbd;            /* decorative hairlines */
  --bs-field: #8b8274;           /* field borders: 3.4:1 on paper */
  --bs-indigo: #4549cf;          /* 6.0:1 on paper */
  --bs-error: #a8281c;
  --bs-on-ink: #f5f1e8;
  --bs-card: #fffdf8;
  --bs-card-edge: #ddd4c4;
  --bs-card-line: rgba(69, 73, 207, 0.14);
  --bs-card-head: rgba(69, 73, 207, 0.62);
  --bs-shadow: 0 1px 1px rgba(40, 30, 15, 0.05), 0 14px 28px -18px rgba(40, 30, 15, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bs-paper: #14120f;
    --bs-field-bg: #1b1814;
    --bs-ink: #efe8db;
    --bs-ink-2: #cfc6b6;
    --bs-ink-3: #a59c8d;          /* 6.9:1 on dark paper */
    --bs-hair: #39342d;
    --bs-field: #81786b;          /* 4.3:1 */
    --bs-indigo: #8a8ff2;         /* ~7:1 */
    --bs-error: #ff9d8f;
    --bs-on-ink: #14120f;
    --bs-card: #1f1c18;
    --bs-card-edge: #3a342c;
    --bs-card-line: rgba(138, 143, 242, 0.15);
    --bs-card-head: rgba(138, 143, 242, 0.7);
    --bs-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 16px 30px -18px rgba(0, 0, 0, 0.9);
  }
}

/* --- the brand lockup (app top bar and signed-out masthead) ----------------
   The real wordmark replaces the old icon + typed name. «портал» sits on the
   wordmark's baseline: the SVG has no baseline of its own, so flexbox lines
   the label's baseline up with the SVG's bottom edge, and the label is lifted
   by the distance from that edge to the letters' baseline — 35.74% of the
   height (glyph y 0 in a viewBox running from -1066 to 593). This holds for
   any font the label is set in. */

.brand { --mark-h: 1.75rem; align-items: baseline; }
.brand .wordmark { height: var(--mark-h); width: auto; flex-shrink: 0; }
.brand-sub { transform: translateY(calc(var(--mark-h) * -0.3574)); }
.bs-lang { display: none; }

/* =============================================================================
   The page, signed out
   ============================================================================= */

body[data-screen="loginView"] {
  --pad: clamp(16px, 4.6vw, 64px);
  word-spacing: 0.04em;
  --max: 1440px;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bs-paper);
  color: var(--bs-ink);
  font-family: var(--sans);
  font-feature-settings: normal;
  font-variant-numeric: lining-nums proportional-nums;
}
/* In-page jumps are instant here: nothing on this screen moves for long. */
:root:has(> body[data-screen="loginView"]) { scroll-behavior: auto; }

body[data-screen="loginView"] ::selection { background: var(--bs-indigo); color: var(--bs-on-ink); }
body[data-screen="loginView"] .wrap { max-width: none; padding: 0; }

body[data-screen="loginView"] :focus-visible {
  outline: 2px solid var(--bs-indigo);
  outline-offset: 3px;
  box-shadow: none;
}

/* --- masthead --------------------------------------------------------------- */

body[data-screen="loginView"] .topbar {
  position: relative;
  max-width: var(--max);
  margin-inline: auto;
  padding: 14px var(--pad) 14px;
  background: none;
  border: 0;
}
/* the thick-and-thin rule under a nameplate */
body[data-screen="loginView"] .topbar::after {
  content: "";
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 0;
  height: 6px;
  border-top: 3px solid var(--bs-ink);
  border-bottom: 1px solid var(--bs-ink);
}
body[data-screen="loginView"] .brand {
  --mark-h: clamp(1.75rem, 1.2rem + 1.6vw, 2.375rem);
  gap: 12px;
  color: var(--bs-ink);
}
body[data-screen="loginView"] .brand-sub {
  display: inline;
  font: 700 0.6875rem/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bs-ink-3);
}

body[data-screen="loginView"] .bs-lang { display: flex; align-items: center; margin-right: -10px; }
.bs-lang-btn {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  font: 700 0.8125rem/1 var(--sans);
  letter-spacing: 0.1em;
  color: var(--bs-ink-3);
  transition: transform var(--dur-press) var(--ease-out);
}
.bs-lang-btn + .bs-lang-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15px;
  bottom: 15px;
  width: 1px;
  background: var(--bs-hair);
}
.bs-lang-btn[aria-pressed="true"] { color: var(--bs-ink); }
.bs-lang-btn[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 9px;
  border-top: 2px solid var(--bs-indigo);   /* a border survives forced colours */
}
.bs-lang-btn:active { transform: scale(var(--press-scale)); }

/* --- shared type ---------------------------------------------------------- */

.bs a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--bs-field);
  transition: none;               /* reset.css fades link colour; nothing fades here */
}

/* =============================================================================
   Hero — mobile first: kicker, headline, standfirst, sign in, then the deck
   ============================================================================= */

.bs-hero {
  --h1: clamp(4rem, 18.5vw, 7.25rem);
  max-width: var(--max);
  margin-inline: auto;
  padding: 0 var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "kicker" "title" "lead" "login" "deck";
}

/* The margin column only exists from 960px up; below that its two children
   take their own places in the hero's grid. */
.bs-side { display: contents; }

.bs-kicker {
  grid-area: kicker;
  position: relative;     /* above the headline's forced-colours backplate */
  z-index: 1;
  margin: 16px 0 8px;
  font: 700 0.6875rem/1rem var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bs-ink-2);
}

.bs-title {
  grid-area: title;
  margin: 0;
  font-family: var(--serif);
  font-size: var(--h1);
  font-weight: 560;
  font-optical-sizing: auto;
  line-height: 0.9;
  letter-spacing: -0.035em;
  text-wrap: wrap;
  overflow-wrap: break-word;
  color: var(--bs-ink);
}
.bs-title:lang(mn) { line-height: 1.03; }   /* «р» of line 1 meets the italic «д» of line 2 */
.bs-title-a, .bs-title-b { display: block; }
.bs-title-b {
  font-style: italic;
  font-weight: 480;
  letter-spacing: -0.03em;
  color: var(--bs-indigo);
}

.bs-lead {
  grid-area: lead;
  max-width: 34rem;
  margin: calc(var(--h1) * 0.18) 0 0;
  font: 400 1rem/1.5 var(--serif);
  color: var(--bs-ink-2);
  text-wrap: pretty;
}
/* English sets the headline at 0.9: the italic «y» hangs further below */
.bs-lead:lang(en) { margin-top: calc(var(--h1) * 0.28); }

/* --- the sign-in block ------------------------------------------------------ */

.bs-login {
  grid-area: login;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 3px solid var(--bs-ink);
  min-width: 0;
}
.bs-login-title {
  font: 600 1.75rem/1.1 var(--serif);
  letter-spacing: -0.02em;
}
.bs-login-lead {
  margin-top: 4px;
  font: 400 0.9375rem/1.45 var(--serif);
  color: var(--bs-ink-2);
}

/* Field labels in sentence case: the one task parents come for gets text
   they can read at a glance, not tracked capitals. */
#loginView label {
  display: block;
  margin: 14px 0 6px;
  font: 650 0.875rem/1.25 var(--sans);
  letter-spacing: 0.005em;
  color: var(--bs-ink);
}
#loginView input:not([type=checkbox]) {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--bs-field);
  border-radius: 2px;
  background: var(--bs-field-bg);
  color: var(--bs-ink);
  font: 500 1.0625rem/1.2 var(--sans);   /* >= 16px: no zoom on iOS focus */
}
#loginView input:not([type=checkbox]):focus-visible { border-color: var(--bs-ink); }

.bs-pw { position: relative; }
#loginView .bs-pw input { padding-right: 104px; }
.bs-pw-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;            /* 44px tall inside the 48px field */
  min-width: 44px;
  padding: 0 12px;
  border-left: 1px solid var(--bs-hair);
  font: 650 0.8125rem/1 var(--sans);
  color: var(--bs-ink-2);
  transition: transform var(--dur-press) var(--ease-out);
}
.bs-pw-toggle:active { transform: scale(var(--press-scale)); }
/* Edge draws its own reveal eye; the Show button already does that job. */
#loginPassword::-ms-reveal,
#loginPassword::-ms-clear { display: none; }

.bs-caps, .bs-warn {
  margin-top: 8px;
  font: 600 0.8125rem/1.4 var(--sans);
  color: var(--bs-ink-2);
}
.bs-warn { font-size: 0.875rem; color: var(--bs-ink); }
/* Both stay in the page while empty (live regions), taking no space. */
.bs-caps:empty, .bs-warn:empty { margin: 0; }

#loginError {
  min-height: 0;
  margin: 14px 0 0;
  padding-left: 12px;
  border-left: 3px solid var(--bs-error);
  font: 600 0.9375rem/1.4 var(--sans);
  color: var(--bs-error);
}
#loginError:empty { margin: 0; padding: 0; border: 0; }

/* The page's one filled button. */
.bs-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 2px;
  background: var(--bs-ink);
  color: var(--bs-on-ink);
  font: 700 1.0625rem/1 var(--sans);
  letter-spacing: 0.01em;
  border: 2px solid transparent;   /* shows as the button's box in forced colours */
  transition: transform var(--dur-press) var(--ease-out);
}
.bs-submit .lucide { width: 22px; height: 22px; }
.bs-submit:active:not(:disabled) { transform: scale(var(--press-scale)); }
.bs-submit:disabled { cursor: progress; opacity: 0.72; }
#loginView .bs-submit:focus-visible { outline-offset: 3px; }

/* Secondary: how to get an account (a disclosure, works without JS). */
.bs-help { margin-top: 8px; border-top: 1px solid var(--bs-hair); border-bottom: 1px solid var(--bs-hair); }
.bs-help-toggle {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  font: 700 0.9375rem/1.3 var(--sans);
  color: var(--bs-ink);
}
.bs-help-toggle::-webkit-details-marker { display: none; }
.bs-help-toggle span {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  text-decoration-color: var(--bs-field);
}
.bs-help-toggle .lucide { width: 20px; height: 20px; color: var(--bs-indigo); transition: transform var(--dur-press) var(--ease-out); }
.bs-help[open] > .bs-help-toggle .lucide { transform: rotate(45deg); }
.bs-help-body { padding: 2px 0 18px; font: 400 0.9375rem/1.5 var(--serif); color: var(--bs-ink-2); }
.bs-help-intro { color: var(--bs-ink); }
.bs-help-list dt {
  margin-top: 14px;
  font: 700 0.875rem/1.3 var(--sans);
  color: var(--bs-ink);
}
.bs-help-list dd { margin-top: 4px; }
.bs-help-list dd p + p { margin-top: 6px; }
.bs-quiet { color: var(--bs-ink-3); }
.bs-fine { margin-top: 10px; font: 500 0.8125rem/1.45 var(--sans); color: var(--bs-ink-3); }
.bs-help-list + .bs-fine { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--bs-hair); }
.bs-copy {
  min-height: 44px;
  margin-top: 4px;
  padding: 0 12px 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--bs-field);
  border-radius: 2px;
  font: 700 0.8125rem/1 var(--sans);
  color: var(--bs-ink);
  transition: transform var(--dur-press) var(--ease-out);
}
.bs-copy .lucide { width: 16px; height: 16px; }
.bs-copy:active { transform: scale(var(--press-scale)); }

.bs-appnote {
  margin-top: 12px;
  font: 500 0.8125rem/1.45 var(--sans);
  color: var(--bs-ink-3);
}

/* --- the deck's caption block ------------------------------------------------ */

.bs-deck-head {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 3px solid var(--bs-ink);
}
.bs-deck-title { font: 600 1.625rem/1.1 var(--serif); letter-spacing: -0.02em; }
.bs-deck-intro { margin-top: 8px; font: 400 1rem/1.5 var(--serif); color: var(--bs-ink-2); max-width: 32rem; }
.bs-deck-note { margin-top: 10px; font: 500 0.8125rem/1.45 var(--sans); color: var(--bs-ink-3); max-width: 32rem; }

/* =============================================================================
   The deck (motion.md §3, adapted: blank card stock, ruled index-card fronts)
   ============================================================================= */

.deck { grid-area: deck; align-self: start; min-width: 0; }

.deck-stage {
  --q-size: 1.25rem;     /* the question */
  --rule: 31px;          /* ruled-line pitch = the question's line height */
  container-type: inline-size;   /* the cards respond to their own width */
  display: grid;          /* every card in one cell: height = the tallest face */
  margin-top: 22px;
  padding: 0 28px 26px 0; /* room for the cards that peek out behind */
  touch-action: pan-y;
  touch-action: pan-y pinch-zoom;
}

.deck-card {
  grid-area: 1 / 1;
  min-width: 0;
  transform-origin: 50% 100%;
  transition-property: transform, opacity, visibility;
  transition-duration: var(--dur-move);
  transition-timing-function: var(--ease-in-out);
}
.deck-card[data-pos="0"] { z-index: 4; }
.deck-card[data-pos="1"] { z-index: 3; transform: translate(14px, 12px) rotate(-2deg); }
.deck-card[data-pos="2"] { z-index: 2; transform: translate(28px, 22px) rotate(-4deg); }
.deck-card[data-pos="far"] {
  z-index: 1;
  transform: translate(28px, 22px) rotate(-4deg);
  opacity: 0;
  visibility: hidden;
  transition-duration: var(--dur-exit);
  transition-timing-function: var(--ease-out);
}
.deck-card[data-pos="-1"] {          /* the card you just left, thrown off to the left */
  z-index: 5;
  transform: translate(-28%, 6px) rotate(-7deg);
  opacity: 0;
  visibility: hidden;
  transition-duration: var(--dur-exit);
  transition-timing-function: var(--ease-out);
}
.deck-stage[data-dir="prev"] .deck-card[data-pos="0"] { transition-timing-function: var(--ease-out); }

/* the flip: perspective on the parent, preserve-3d on the rotating element,
   faces as its direct children; nothing on .fc-inner may flatten it. */
.fc-scene {
  height: 100%;
  perspective: var(--flip-perspective);
  transition: transform var(--dur-press) var(--ease-out);
}
.deck-card[data-pos="0"] .fc-scene { cursor: pointer; }
.deck-card[data-pos="0"] .fc-scene:active { transform: scale(var(--press-scale-lg)); }

.fc-inner {
  height: 100%;
  display: grid;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform var(--dur-flip) var(--ease-out);
}
.deck-card[data-face="a"] .fc-inner { transform: rotateY(-180deg); }

.fc-face {
  grid-area: 1 / 1;
  min-width: 0;
  min-height: 16rem;                 /* min, never fixed: text spacing and zoom reflow */
  display: flex;
  flex-direction: column;
  padding: 14px 18px 12px;
  background-color: var(--bs-card);
  border: 1px solid var(--bs-card-edge);
  border-radius: 3px;
  box-shadow: var(--bs-shadow);
  color: var(--bs-ink);
  font-variant-numeric: lining-nums;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: rotateY(0deg);          /* Firefox bug 1201471 */
  transition: visibility var(--dur-flip) linear;
}
.fc-back { transform: rotateY(180deg); visibility: hidden; }
.deck-card[data-face="a"] .fc-back { visibility: visible; }
.deck-card[data-face="a"] .fc-front { visibility: hidden; }

/* Only the top card shows its words: the cards behind are blank, ruled
   card stock, so a moving card never double-exposes text. */
.fc-fade { transition: opacity var(--dur-fade) var(--ease-out); }
.deck-card:not([data-pos="0"]) .fc-fade { opacity: 0; }

/* card header: course and number, level and Question / Answer, over an
   inked rule — a numbered index card */
.fc-head { padding-bottom: 8px; border-bottom: 2px solid var(--bs-card-head); }
.fc-head-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.fc-subject {
  font: 800 0.6875rem/1.4 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bs-indigo);
}
.fc-num {
  flex-shrink: 0;
  font: italic 500 0.875rem/1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--bs-ink-3);
  white-space: nowrap;
}
.fc-meta {
  margin-top: 3px;
  word-spacing: 0.14em;
  font: 500 0.8125rem/1.4 var(--sans);
  color: var(--bs-ink-3);
}
.fc-side {
  flex-shrink: 0;
  font: 800 0.6875rem/1.4 var(--sans);
  word-spacing: 0.04em;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bs-ink-2);
}

/* The front: ruled like an index card; text sits on the lines. Each line
   box is one --rule tall, so a baseline falls at --rule/2 + 0.4345 × size
   (Literata: ascent 1.177, descent 0.308); the rules are drawn 2px under
   the baseline of the question's size, and larger or smaller lines are
   nudged so their baselines land on a rule too. */
.fc-front .fc-body {
  --pad-top: 8px;
  flex: 1;
  padding-top: var(--pad-top);
  background-image: repeating-linear-gradient(to bottom,
    transparent 0, transparent calc(var(--rule) - 1px),
    var(--bs-card-line) calc(var(--rule) - 1px), var(--bs-card-line) var(--rule));
  background-position: 0 calc(var(--pad-top) + 3px - var(--rule) / 2 + 0.4345 * var(--q-size));
}
.fc-front .fc-body > * { position: relative; top: calc((var(--q-size) - 1em) * 0.4345); }
.fc-text, .fc-options, .fc-sentence, .fc-verse {
  font-family: var(--serif);
  font-size: var(--q-size);
  line-height: var(--rule);
  text-wrap: pretty;
  overflow-wrap: break-word;
}
.fc-text { font-weight: 450; }
.fc-options, .fc-sentence { font-weight: 600; }
.fc-sentence { font-size: calc(var(--q-size) * 1.08); }
/* A verse line never breaks: on a narrow card the verse shrinks to fit the
   longest line (about 11.3em with the indent, inside 50px of padding) instead. */
.fc-verse {
  font-style: italic;
  font-size: min(calc(var(--q-size) * 1.16), calc((100cqi - 50px) / 11.4));
  color: var(--bs-ink);
}
.fc-verse-line { display: block; white-space: nowrap; }
.fc-verse-line + .fc-verse-line { padding-left: 1.2em; }
.fc-fig {
  display: flex;
  align-items: baseline;
  gap: 0.35em;
  font: 500 calc(var(--q-size) * 2) / calc(var(--rule) * 2) var(--serif);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.fc-front .fc-body > .fc-fig { top: calc(var(--rule) / 2 + (var(--q-size) - 1em) * 0.4345); }
.fc-fig-sep { color: var(--bs-ink-3); font-weight: 300; }
.fc-pair { gap: 0.55em; }
.fc-pair-item { display: inline-flex; align-items: baseline; gap: 0.18em; }
.fc-pair-label {
  font: italic 400 calc(var(--q-size) * 0.8)/1 var(--serif);
  letter-spacing: 0;
  color: var(--bs-indigo);
}
.fc-legend { font: italic 400 var(--q-size)/var(--rule) var(--serif); color: var(--bs-ink-3); }
.fc-aside { font: 500 0.8125rem/var(--rule) var(--sans); color: var(--bs-ink-3); }
.fc-front .fc-body > .fc-aside { top: calc(var(--q-size) * 0.4345 - 0.38em); }   /* Manrope: baseline 0.38em under the middle */
.fc-gap {
  display: inline-block;
  width: 2.4em;
  height: 0.9em;
  margin: 0 0.1em;
  vertical-align: -0.05em;
  border-bottom: 2px solid var(--bs-indigo);
}
.fc-hint {
  padding-top: 8px;
  text-align: right;
  font: 700 0.6875rem/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bs-ink-3);
}

/* the back: plain stock — question in small print, the answer, the lesson */
.fc-recap { margin-top: 10px; font: 500 0.8125rem/1.45 var(--sans); word-spacing: 0.1em; color: var(--bs-ink-3); }
/* On a narrow card the answer side would run far longer than the question
   side (every card in the stack takes the tallest face's height, so short
   questions would sit over rows of blank rules). There the recap is kept
   for screen readers only; whoever turned the card has just read it. */
@container (max-width: 26rem) {
  .fc-recap {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
.fc-ans {
  margin-top: 10px;
  font: 650 calc(var(--q-size) * 1.12)/1.2 var(--serif);
  letter-spacing: -0.01em;
}
.fc-why { margin-top: 4px; font: 400 0.9375rem/1.45 var(--serif); color: var(--bs-ink-2); text-wrap: pretty; }
.fc-teach { margin-top: auto; padding-top: 12px; }
.fc-teach-label {
  padding-top: 8px;
  border-top: 1px solid var(--bs-card-edge);
  font: 800 0.6875rem/1.4 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bs-indigo);
}
.fc-teach-text { margin-top: 3px; font: 500 0.8125rem/1.45 var(--sans); word-spacing: 0.08em; color: var(--bs-ink-2); }

.fc-gaps { margin-top: 10px; display: flex; align-items: center; }
.fc-gaps-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bs-ink); flex-shrink: 0; }
.fc-gaps-gap { width: 22px; height: 0; border-top: 2px solid var(--bs-indigo); margin: 0 3px; }

/* --- deck controls: prev · flip · next ---------------------------------------- */

.deck-controls { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; margin-top: 4px; }
.deck-btn, .deck-flip {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--bs-field);
  border-radius: 2px;
  background: transparent;
  color: var(--bs-ink);
  font: 700 0.875rem/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out);
}
/* One width for both labels, so Next never moves when the card turns; on
   the narrowest phones the label wraps inside the button instead. */
.deck-flip {
  width: 100%;
  min-width: 0;
  padding: 0 14px;
  border-color: var(--bs-ink);
  white-space: normal;
  text-align: center;
  line-height: 1.15;
}
.deck-flip .lucide { color: var(--bs-indigo); }
.deck-btn .lucide, .deck-flip .lucide { width: 18px; height: 18px; }
.deck-btn:active, .deck-flip:active { transform: scale(var(--press-scale)); }

.deck-flip-wrap { position: relative; display: inline-flex; flex: 0 1 13rem; min-width: 0; }
.fc-hook { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.fc-hook[hidden] { display: none; }
.fc-hook:focus { outline: none; }
.fc-hook:focus-visible + .deck-flip { outline: 2px solid var(--bs-indigo); outline-offset: 3px; }

/* keyboard shortcuts never animate (arrow keys set data-instant) */
.deck[data-instant] .deck-card,
.deck[data-instant] .fc-inner,
.deck[data-instant] .fc-face,
.deck[data-instant] .fc-fade { transition-duration: 0s !important; transition-delay: 0s !important; }

/* first visit only: the top three cards are dealt (hero.js sets data-intro once) */
@starting-style {
  .deck[data-intro] .deck-card { opacity: 0; transform: translateY(var(--enter-shift)) scale(var(--enter-scale)); }
}
.deck[data-intro] .deck-card { transition-timing-function: var(--ease-out); }
.deck[data-intro] .deck-card[data-pos="1"] { transition-delay: var(--stagger); }
.deck[data-intro] .deck-card[data-pos="2"] { transition-delay: calc(2 * var(--stagger)); }

/* =============================================================================
   Sections 01 / 02 / 03 — one anchor each
   ============================================================================= */

.bs-more { max-width: var(--max); margin: 72px auto 0; padding: 0 var(--pad); }

.bs-sec {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "run" "anchor" "text" "points";
  padding: 16px 0 64px;
  border-top: 3px solid var(--bs-ink);
}
.bs-run {
  grid-area: run;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bs-ink);
  font: 700 0.6875rem/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bs-ink-2);
}
.bs-run-num {
  font: 600 1.0625rem/1 var(--serif);
  letter-spacing: 0;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--bs-ink);
}

.bs-sec-text { grid-area: text; min-width: 0; }
.bs-sec-title {
  margin-top: 28px;
  font: 560 clamp(1.875rem, 1.25rem + 2.4vw, 3.25rem)/1.04 var(--serif);
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.bs-sec-body {
  margin-top: 16px;
  max-width: 36rem;
  font: 400 clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem)/1.55 var(--serif);
  color: var(--bs-ink-2);
}
.bs-couplet span { display: block; }      /* one sentence per line */
.bs-points { grid-area: points; margin-top: 24px; min-width: 0; }
.bs-points li {
  padding: 12px 0;
  border-top: 1px solid var(--bs-hair);
  font: 400 1rem/1.45 var(--serif);
  color: var(--bs-ink);
}
.bs-points li:last-child { border-bottom: 1px solid var(--bs-hair); }
.bs-points-run b {
  display: block;
  margin-bottom: 3px;
  font: 800 0.6875rem/1.3 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bs-ink);
}
.bs-points-run span { display: block; color: var(--bs-ink-2); }

.bs-anchor { grid-area: anchor; min-width: 0; margin-top: 28px; }
.bs-anchor-cap {
  max-width: 22em;
  margin-top: 18px;
  font: 400 clamp(1rem, 0.95rem + 0.3vw, 1.25rem)/1.4 var(--serif);
  color: var(--bs-ink-2);
}

/* 01 — the five attendance marks, written into a register: one ruled line
   each. In English the gloss follows its word on the same baseline. */
.bs-marks {
  font: 450 clamp(2.625rem, 1.2rem + 5.2vw, 5.75rem)/1 var(--serif);
  letter-spacing: -0.03em;
  color: var(--bs-ink);
}
.bs-mark {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.3em;
  padding: 0.12em 0 0.1em;
  border-bottom: 1px solid var(--bs-hair);
}
.bs-mark-g {
  font: italic 400 max(1.0625rem, 0.24em)/1.2 var(--serif);
  letter-spacing: 0;
  color: var(--bs-indigo);
}

/* 02 — the hinge: Teacher —— «Нийтлэх» —— Parent. Upright on phones, lying
   down from 700px, where it spans the section. */
.bs-anchor-hinge {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
}
.bs-hinge { display: contents; }
.bs-hinge-end { font: 500 1.375rem/1.2 var(--serif); letter-spacing: -0.01em; color: var(--bs-ink); }
.bs-hinge-line { width: 0; height: 26px; margin: 8px 0 10px 0.55em; border-left: 1px solid var(--bs-ink); }
.bs-hinge-word { display: flex; flex-direction: column; }
.bs-word-w {
  font: 380 clamp(3.5rem, 15vw, 5.5rem)/0.86 var(--serif);
  letter-spacing: -0.045em;
  color: var(--bs-ink);
}
.bs-word-g {
  margin-top: 12px;
  font: 700 0.75rem/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bs-indigo);
}
.bs-anchor-hinge .bs-anchor-cap { margin-top: 22px; }

/* 03 — the brand line is the section's title and its anchor; its second
   word turns italic, the same gesture as the headline's «нүдээр.» */
.bs-sec-3 { grid-template-areas: "run" "tagline" "text" "points"; }
.bs-tagline { grid-area: tagline; margin-top: 24px; font-family: var(--serif); }
.bs-tagline-a {
  display: block;
  font-size: clamp(3rem, 0.6rem + 12.5vw, 11.5rem);
  font-weight: 560;
  line-height: 0.88;
  letter-spacing: -0.045em;
  overflow-wrap: break-word;
}
.bs-tagline-i { font-style: italic; font-weight: 480; letter-spacing: -0.035em; }
.bs-tagline-b {
  display: block;
  margin-top: clamp(22px, 0.2rem + 2.6vw, 44px);
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.5rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--bs-ink-2);
}

/* --- footer ------------------------------------------------------------------ */

.bs-foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px var(--pad) 40px;
  display: grid;
  gap: 6px;
  font: 500 0.875rem/1.5 var(--sans);
  color: var(--bs-ink-2);
}
.bs-foot::before {
  content: "";
  height: 6px;
  margin-bottom: 18px;
  border-top: 3px solid var(--bs-ink);
  border-bottom: 1px solid var(--bs-ink);
}
.bs-foot-mark { color: var(--bs-ink); margin-bottom: 8px; }
.bs-foot-mark .wordmark { height: 1.75rem; width: auto; }
.bs-foot-about { font: 400 1rem/1.5 var(--serif); color: var(--bs-ink); }
.bs-foot-copy { color: var(--bs-ink-3); }
.bs-foot-back { margin-top: 10px; }
.bs-foot-back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  color: var(--bs-ink);
}

/* toast on paper */
body[data-screen="loginView"] .toast {
  border-radius: 2px;
  background: var(--bs-ink);
  color: var(--bs-on-ink);
  font: 600 0.875rem/1.4 var(--sans);
  box-shadow: none;
}

/* The schools globe, before 01: the claim, the list of schools as text, and
   the globe (globe.js draws it; it is decoration, the list is the content).
   Its callouts are set like the runs: the names in Literata over a rule, the
   pupil count in Manrope capitals under it. */
.bs-sec-globe { grid-template-areas: "run" "text" "anchor" "list"; }
.bs-run-meta {
  margin-left: auto;
  letter-spacing: 0.1em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--bs-ink);
}
.bs-anchor-globe { margin-top: 20px; }
.globe-stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  aspect-ratio: 1;
  overflow: clip;
  user-select: none;
  -webkit-user-select: none;
}
.globe-canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.globe-stage[data-dragging] .globe-canvas { cursor: grabbing; }
.globe-labels { position: absolute; inset: 0; pointer-events: none; }
/* A paper knock-out under each callout, as on a printed map, so the dots
   never run through the names. The rule is the count's top border. */
.globe-label {
  position: absolute;
  top: 0;
  left: 0;
  max-width: min(15em, 62%);
  display: flex;
  flex-direction: column;
  padding: 3px 6px 4px;
  background: var(--bs-paper);
  visibility: hidden;
  will-change: transform;
}
.globe-label-names { display: flex; flex-direction: column; padding-bottom: 5px; }
.globe-label-name { font: 600 0.9375rem/1.2 var(--serif); letter-spacing: -0.01em; color: var(--bs-ink); }
.globe-label-more { font: 400 0.8125rem/1.3 var(--serif); color: var(--bs-ink-2); }
.globe-label-count,
.globe-row-count {
  font: 700 0.625rem/1.2 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--bs-ink-2);
}
.globe-label-count { padding-top: 5px; border-top: 1px solid var(--bs-ink); white-space: nowrap; }
.globe-list { grid-area: list; min-width: 0; margin-top: 24px; }
.globe-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--bs-hair);
}
.globe-row:last-child { border-bottom: 1px solid var(--bs-hair); }
.globe-row-name { min-width: 0; font: 400 1rem/1.4 var(--serif); color: var(--bs-ink); transition: color 0.2s ease; }
/* the school pointed at, which the globe has turned to */
.globe-row[data-on] .globe-row-name { color: var(--bs-indigo); }
.globe-row-count { flex-shrink: 0; font-size: 0.6875rem; }

/* =============================================================================
   Wider screens
   ============================================================================= */

/* small tablets and up: form beside the standfirst and the deck */
@media (min-width: 700px) {
  .bs-hero {
    --h1: clamp(7rem, 17vw, 10rem);
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 21rem);
    column-gap: 40px;
    grid-template-areas:
      "kicker kicker"
      "title  title"
      "lead   login"
      "deck   login";
    grid-template-rows: auto auto auto 1fr;
  }
  .bs-kicker { margin: 20px 0 12px; }
  .bs-lead { margin-top: calc(var(--h1) * 0.27); font-size: 1.1875rem; }
  .bs-lead:lang(en) { margin-top: calc(var(--h1) * 0.32); }
  .bs-login {
    align-self: start;
    margin-top: calc(var(--h1) * 0.3 + 4px);
    padding: 14px 0 0 28px;
    border-top: 0;
    border-left: 1px solid var(--bs-ink);
  }
  .bs-login-title { padding-bottom: 10px; border-bottom: 3px solid var(--bs-ink); }
  .bs-login-lead { margin-top: 10px; }
  .bs-deck-head { margin-top: 36px; }
  .deck-stage { --q-size: 1.3125rem; --rule: 32px; }
  .fc-face { padding: 16px 20px 12px; }

  .bs-sec {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 32px;
    grid-template-areas: none;
    padding-bottom: 96px;
  }
  .bs-run { grid-column: 1 / -1; grid-row: 1; }
  .bs-anchor { margin-top: 36px; }

  /* 01: the register at left, the claim at right */
  .bs-sec-1 .bs-anchor { grid-column: 1 / span 7; grid-row: 2 / span 2; }
  .bs-sec-1 .bs-sec-text { grid-column: 8 / -1; grid-row: 2; }
  .bs-sec-1 .bs-points { grid-column: 8 / -1; grid-row: 3; align-self: start; }

  /* 02: the hinge spans the section; the claim and the four modules below */
  .bs-anchor-hinge {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: auto minmax(24px, 0.8fr) auto minmax(24px, 1.2fr) auto;
    column-gap: clamp(14px, 1.8vw, 26px);
    align-items: baseline;
    justify-items: stretch;
  }
  .bs-hinge-line {
    width: auto;
    height: 0;
    margin: 0;
    border-left: 0;
    border-top: 1px solid var(--bs-ink);
    transform: translateY(-0.4em);     /* at the end words' x-height */
    font: 500 1.375rem/1 var(--serif);
  }
  .bs-anchor-hinge .bs-anchor-cap { grid-column: 3 / -1; grid-row: 2; }
  .bs-anchor-hinge .bs-word-w { font-size: clamp(4.25rem, 9.4vw, 9.5rem); }
  .bs-sec-2 .bs-sec-text { grid-column: 1 / span 6; grid-row: 3; }
  .bs-sec-2 .bs-points { grid-column: 7 / -1; grid-row: 3; align-self: start; margin-top: 36px; }

  /* the globe: the claim and the schools at left, the globe at right — the
     mirror of 01 below it */
  .bs-sec-globe { grid-template-rows: auto auto 1fr; }   /* the globe's height goes to the last row */
  .bs-sec-globe .bs-sec-text { grid-column: 1 / span 5; grid-row: 2; }
  .bs-sec-globe .globe-list { grid-column: 1 / span 5; grid-row: 3; align-self: start; }
  .bs-sec-globe .bs-anchor-globe { grid-column: 6 / -1; grid-row: 2 / span 2; margin-top: 28px; }

  /* 03: the line across, the platform at left, its programmes at right */
  .bs-sec-3 .bs-tagline { grid-column: 1 / -1; grid-row: 2; }
  .bs-sec-3 .bs-sec-text { grid-column: 1 / span 6; grid-row: 3; }
  .bs-sec-3 .bs-points { grid-column: 7 / -1; grid-row: 3; align-self: start; }

  .bs-foot {
    grid-template-columns: auto 1fr auto;
    column-gap: 40px;
    align-items: start;
  }
  .bs-foot::before { grid-column: 1 / -1; }
  .bs-foot-mark { grid-row: 2 / span 3; }
  .bs-foot-about, .bs-foot-line { grid-column: 2; }
  .bs-foot-back { grid-column: 3; grid-row: 2; margin-top: 0; }
}

/* wide tablets and laptops: the margin column. A hairline runs down from the
   kicker; the standfirst fills its top, beside the headline's first line,
   and the form starts level with the headline's second line. */
@media (min-width: 960px) {
  .bs-hero {
    --h1: clamp(8rem, 13.4vw, 10rem);
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 20rem);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "kicker side"
      "title  side"
      "deck   side"
      ".      side";
  }
  .bs-side {
    --line2: calc(1rem + 12px + var(--h1) * 1.06);   /* kicker + line 1 (EN) */
    grid-area: side;
    align-self: start;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-top: 20px;
    padding-left: 28px;
    border-left: 1px solid var(--bs-ink);
  }
  .bs-side:lang(mn) { --line2: calc(1rem + 12px + var(--h1) * 1.2); }
  .bs-side .bs-lead {
    min-height: var(--line2);
    margin: 0;
    padding-bottom: 28px;
    font-size: 1.125rem;
    line-height: 1.45;
  }
  .bs-login { margin-top: 0; padding: 0; border-left: 0; }
  .bs-deck-head { margin-top: calc(var(--h1) * 0.24); }
  .deck-stage { --q-size: 1.4375rem; --rule: 34px; }
  .fc-face { min-height: 17rem; padding: 18px 22px 14px; }
}

/* desktop: the broadsheet front page.
   [deck | caption + controls] under the headline, the margin column at right.
   The stack is dropped onto the headline's last line; the deck is a subgrid
   so its controls can sit in the caption's column, level with the card's
   foot. */
@media (min-width: 1240px) {
  .bs-hero {
    --h1: clamp(8.5rem, 20vw - 7.25rem, 11.5rem);
    grid-template-columns: minmax(0, 1fr) minmax(19.5rem, 0.62fr) 20rem;
    column-gap: clamp(2rem, 3.4vw, 3.25rem);
    grid-template-rows: auto auto auto 1fr;    /* a tall margin column (help open) grows the last row only */
    grid-template-areas:
      "kicker kicker side"
      "title  title  side"
      "deck   deck   side"
      ".      .      side";
  }
  .bs-kicker { margin: 20px 0 10px; }
  .bs-side { --line2: calc(1rem + 10px + var(--h1) * 1.06); }
  .bs-side:lang(mn) { --line2: calc(1rem + 10px + var(--h1) * 1.2); }
  .bs-side .bs-lead { font-size: 1.1875rem; }
  body[data-screen="loginView"] .topbar { padding-top: 16px; padding-bottom: 14px; }
  /* The deck shares the hero's columns (subgrid) but keeps its own rows:
     the stack at left; the caption sits on the controls, and both on the
     card's foot. */
  .deck {
    display: grid;
    grid-template-columns: subgrid;
    grid-template-rows: 1fr auto;
    position: relative;
    z-index: 1;
  }
  .bs-deck-head {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin-top: calc(var(--h1) * 0.26);
    padding-top: 12px;
    border-top-width: 1px;
  }
  .bs-deck-title { font-size: 1.375rem; }
  .deck-stage {
    --q-size: clamp(1.375rem, 0.35rem + 1.45vw, 1.625rem);
    --rule: calc(var(--q-size) * 1.47);
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: start;
    margin: 0;              /* the top card stays upright: small text stays sharp */
  }
  .deck-controls {
    grid-column: 2;
    grid-row: 2;
    margin: 18px 0 32px;      /* level with the top card's foot, above the stack's */
  }
  .fc-face { min-height: 18rem; padding: 18px 24px 14px; }
}

/* Short phones (an iPhone SE, or any phone with Safari's toolbars showing):
   a smaller headline and tighter gaps, so the Log in button stays in the
   first screen. The line saying which credentials to use stays. */
@media (max-width: 699px) and (max-height: 760px) {
  .bs-hero { --h1: clamp(3.25rem, 15vw, 4rem); }
  .bs-kicker { margin-top: 12px; }
  .bs-lead { line-height: 1.42; }
  .bs-login { margin-top: 12px; }
  #loginView label { margin-top: 10px; }
}

/* =============================================================================
   Hover: fine pointers only, colour only, instant. Nothing depends on it.
   ============================================================================= */

@media (hover: hover) and (pointer: fine) {
  .bs-lang-btn:hover { color: var(--bs-ink); }
  .bs a:hover { text-decoration-color: currentColor; }
  .bs-help-toggle:hover span { text-decoration-color: currentColor; }
  .bs-submit:hover:not(:disabled) { background: var(--bs-ink-2); }
  .deck-btn:hover, .bs-copy:hover { border-color: var(--bs-ink); }
  .deck-flip:hover { background: var(--bs-field-bg); }
  .bs-pw-toggle:hover { color: var(--bs-ink); }
}

/* =============================================================================
   Reduced motion: keep opacity, drop movement. !important beats reset.css's
   blanket `* { transition-duration: 0.01ms !important }` (a class selector
   outranks the universal one when both are important).
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  .deck-card { transition: opacity var(--dur-fade) ease, visibility var(--dur-fade) linear !important; }
  .deck-card[data-pos="-1"] { transform: none; }
  .fc-inner,
  .deck-card[data-face="a"] .fc-inner { transform: none; transition: none !important; }
  .fc-back { transform: none; }
  .fc-face { transition: none !important; }
  .fc-fade { transition: opacity var(--dur-fade) ease !important; }
  .deck-card[data-face="q"] .fc-back .fc-fade,
  .deck-card[data-face="a"] .fc-front .fc-fade { opacity: 0; }
  .deck-card[data-pos="0"] .fc-scene:active,
  .deck-btn:active, .deck-flip:active, .bs-submit:active:not(:disabled),
  .bs-lang-btn:active, .bs-copy:active, .bs-pw-toggle:active { transform: none; }
  .bs-help[open] > .bs-help-toggle .lucide { transform: rotate(45deg); }
  .deck[data-intro] .deck-card { transition-delay: 0s !important; }
}
