/* Loading screen (quiz), design 4 "Start beside": features/loading-screen.js + features/loading-cards.js.
   Layout, sizes and motion: mockups/loading-design-4.html (build note in its header). One column, 480px max, centred.
   Motion: the house curve; transform and opacity only, except the button row's columns (one small row, nothing below
   it but the short-set line). Hover only for fine pointers. Reduced motion: fades only, nothing slides or turns. */
#page-loading{--cal-ease:cubic-bezier(0.16,1,0.3,1);}

/* While the screen is up, the Cancel bar (dg-system.css) takes the screen's measure. Cancel stays top-left. */
html[data-theme] body #page-loading.ca-load-on .load-top{max-width:480px;padding:calc(env(safe-area-inset-top,0px) + 20px) max(24px,env(safe-area-inset-right,0px)) 0 max(24px,env(safe-area-inset-left,0px));}
html[data-theme] body #page-loading.ca-load-on .load-topbar{border-bottom:0;margin:0;padding:0;}
html[data-theme] body #page-loading.ca-load-on{min-height:100dvh;padding:0;}   /* the screen sets its own gutters (24px) */
/* Behind the slow and failed notices their own buttons are the way out (Escape too), so the top Cancel steps aside. */
#page-loading:is([data-cal-phase="slow"],[data-cal-phase="failed"],[data-cal-phase="backgrounded"]) #load-cancel{visibility:hidden!important;}   /* keeps its space: nothing jumps */

/* Back / Cancel: 44px, 12px radius, a 1px inset border; the label swaps (crossfade) and the icon fades. */
html[data-theme] body #page-loading.ca-load-on .load-cancel{height:44px;min-height:44px!important;gap:8px;padding:0 16px 0 12px!important;border:0!important;
  border-radius:12px!important;box-shadow:inset 0 0 0 1px var(--border)!important;color:var(--text-mid)!important;font:500 15px/1 Inter,system-ui,sans-serif;
  touch-action:manipulation;-webkit-user-select:none;user-select:none;transition:transform .16s var(--cal-ease);}
html[data-theme] body #page-loading.ca-load-on .load-cancel svg{width:16px;height:16px;}
html[data-theme] body #page-loading.ca-load-on .load-cancel:active{transform:scale(.97);}
#ca-load{box-sizing:border-box;max-width:480px;margin:0 auto;padding:0 max(24px,env(safe-area-inset-right,0px)) calc(32px + env(safe-area-inset-bottom,0px)) max(24px,env(safe-area-inset-left,0px));   /* a phone on its side: clear of the notch */
  
  color:var(--text);touch-action:manipulation;-webkit-tap-highlight-color:transparent;
  --cal-track:var(--dg-rule-soft);--cal-tint:color-mix(in oklab,var(--accent) 30%,var(--cal-track));
  --cal-card:var(--surface);--cal-ink-soft:var(--text-mid);--cal-muted:var(--text-dim);}
html[data-theme="light"] #ca-load{--cal-tint:color-mix(in oklab,var(--accent) 28%,var(--cal-track));--cal-card:color-mix(in oklab,var(--bg) 40%,white);}
#ca-load *,#ca-load *::before,#ca-load *::after{box-sizing:border-box;}

/* The exam and topic, the count (the heading) and the sub-line. */
#ca-load .cal-eyebrow{margin:22px 0 0;font-size:12px;font-weight:800;letter-spacing:.1em;line-height:1.4;text-transform:uppercase;color:var(--accent);
  display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden;}   /* at most 2 lines; screen readers get the whole text */
#ca-load .cal-count{margin:4px 0 2px;font-family:'Fraunces',Georgia,serif;font-size:28px;font-weight:600;letter-spacing:-0.01em;line-height:1.15;
  font-variant-numeric:lining-nums tabular-nums;color:var(--text);}
#ca-load .cal-progress > .cal-count:first-child{margin-top:22px;}
/* The gaps language (27 Nov): the small anvil beside the count while questions are written (features/gaps-morph.js). */
#ca-load .cal-progress{position:relative;}
#ca-load .cal-gm{position:absolute;top:14px;right:-4px;}
#ca-load[data-gm] :is(.cal-eyebrow,.cal-count,.cal-sub){padding-right:84px;}
html[data-theme] body #ca-load .cal-count:focus{outline:none!important;box-shadow:none!important;}   /* the page switch focuses the heading for screen readers (app.js showPage); not a control */
#ca-load .cal-n{display:inline-block;}
/* The working orb (founder pick 5, 23 Nov 2026): turns (2.4s, linear: a steady spin; quicker reads as working, Emil review) and breathes (1.8s, house curve)
   at the end of the eyebrow line, just above the count, so it never makes the count wrap. Fades out (keeping its
   space) once nothing is being written; still under reduced motion. */
#ca-load .cal-eyerow{display:flex;align-items:flex-start;gap:12px;margin-top:22px;}
#ca-load .cal-eyerow .cal-eyebrow{flex:1;min-width:0;margin-top:0;}
#ca-load .cal-orb{flex:0 0 24px;width:24px;height:24px;margin:-4px 0 -4px auto;color:var(--accent);transition:opacity .2s var(--cal-ease);}
#ca-load .cal-orb svg{display:block;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:1.5;stroke-dasharray:1.6 2.4;stroke-linecap:round;overflow:visible;}
#ca-load .cal-orb-s{transform-origin:12px 12px;animation:cal-orb-spin 2.4s linear infinite;}
#ca-load .cal-orb-b{transform-origin:12px 12px;animation:cal-orb-breathe 1.8s var(--cal-ease) infinite alternate;}
#ca-load[data-paused] .cal-orb-s,#ca-load[data-paused] .cal-orb-b{animation-play-state:paused;}
#ca-load:is([data-ready],[data-phase="failed"],[data-phase="cached"],[data-phase="backgrounded"]) .cal-orb{opacity:0;}   /* fades, keeps its space: nothing below moves */
#ca-load:is([data-ready],[data-phase="failed"],[data-phase="cached"],[data-phase="backgrounded"]) :is(.cal-orb-s,.cal-orb-b){animation-play-state:paused;}
@keyframes cal-orb-spin{to{transform:rotate(360deg);}}
@keyframes cal-orb-breathe{from{transform:scale(.94);opacity:.7;}to{transform:scale(1);opacity:1;}}
#ca-load .cal-n.cal-bump{animation:cal-bump .18s var(--cal-ease);}
@keyframes cal-bump{from{opacity:.2;transform:translateY(4px);}}
#ca-load .cal-sub{margin:0 0 12px;font-size:15px;line-height:1.45;color:var(--cal-ink-soft);}
#ca-load .cal-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;}

/* The bar: solid = ready, tint = the slice in flight, rest = the empty track (it collapses on a short set). */
#ca-load .cal-line-track{position:relative;height:6px;border-radius:999px;overflow:hidden;}
#ca-load .cal-line-track > span{position:absolute;inset:0;border-radius:999px;transform-origin:0 50%;}
#ca-load .cal-line-rest{background:var(--cal-track);transition:transform .8s var(--cal-ease);}
#ca-load .cal-line-solid{background:var(--accent);transition:transform .8s var(--cal-ease);}
#ca-load .cal-line-tint{background:var(--cal-tint);border-radius:0;transition:transform .8s var(--cal-ease),opacity .25s var(--cal-ease);}
#ca-load:is([data-settling],[data-phase="short"]) .cal-line-tint{opacity:0;}
#ca-load .cal-status{margin:8px 0 0;min-height:21px;font-size:14px;line-height:1.5;color:var(--cal-muted);font-variant-numeric:tabular-nums;}
#ca-load[data-ready] .cal-status{color:var(--cal-ink-soft);}

/* Crossfades (sub-line, card label, Back): the new words fade in, the old fade out with a 2px blur on top. */
#ca-load .cal-xf,#load-cancel .cal-xf{position:relative;}
.cal-xf > .cal-now{display:inline-block;animation:cal-fade .25s var(--cal-ease);}
.cal-xf > .cal-ghost{position:absolute;left:0;top:0;white-space:nowrap;pointer-events:none;animation:cal-out .25s var(--cal-ease) forwards;}
@keyframes cal-out{to{opacity:0;filter:blur(2px);}}
@keyframes cal-fade{from{opacity:0;}to{opacity:1;}}
@keyframes cal-rise{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:none;}}
#ca-load .cal-swap,#load-cancel svg.cal-swap{animation:cal-fade .25s var(--cal-ease);}

/* The flashcard: a div role="button" (Safari won't turn a <button> in 3D). Side classes are not named .back. */
#ca-load .cal-cards{margin-top:22px;}
#ca-load .cal-cards-label{margin:0 0 8px;font-size:14px;font-weight:600;line-height:1.5;color:var(--cal-ink-soft);}
#ca-load .cal-flip{position:relative;perspective:1100px;}
#ca-load .cal-card{position:relative;display:grid;width:100%;min-height:236px;border-radius:18px;cursor:pointer;text-align:left;
  transform-style:preserve-3d;transition:transform .42s var(--cal-ease);-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;}
#ca-load .cal-card[aria-pressed="true"]{transform:rotateY(180deg);}
#ca-load .cal-card:focus-visible{outline:2px solid var(--accent);outline-offset:3px;}
#ca-load .cal-face{grid-area:1/1;display:flex;flex-direction:column;justify-content:space-between;gap:12px;padding:18px 20px;border-radius:18px;
  background:var(--cal-card);box-shadow:inset 0 0 0 1px var(--border),0 1px 2px color-mix(in oklab,var(--text) 6%,transparent);
  -webkit-backface-visibility:hidden;backface-visibility:hidden;transition:opacity 0s linear 70ms;}
#ca-load .cal-face-answer{transform:rotateY(180deg);opacity:0;}
/* Safari can ignore backface-visibility, so each side also switches at the edge-on moment of the turn (about 70ms in). */
#ca-load .cal-card[aria-pressed="true"] .cal-face-front{opacity:0;}
#ca-load .cal-card[aria-pressed="true"] .cal-face-answer{opacity:1;}
#ca-load .cal-meta{font-size:13px;line-height:1.4;color:var(--cal-muted);}
#ca-load .cal-term{font-family:'Fraunces',Georgia,serif;font-size:30px;font-weight:600;line-height:1.12;font-variant-numeric:lining-nums;color:var(--text);overflow-wrap:anywhere;}
#ca-load .cal-def{font-size:17px;line-height:1.45;color:var(--text);}

/* The row under the card: Next card full width while writing; Start grows in beside it (1fr 1.7fr, a 10px gap). */
#ca-load .cal-row{display:grid;grid-template-columns:1fr 0fr;gap:0;margin-top:12px;
  transition:grid-template-columns .38s var(--cal-ease),gap .38s var(--cal-ease);}
#ca-load[data-start] .cal-row{grid-template-columns:1fr 1.7fr;gap:10px;}
#ca-load .cal-row > *{min-width:0;}
#ca-load .cal-btn{min-height:48px;padding:0 18px;border-radius:12px;border:0;background:none;color:var(--text);
  font:600 16px/1.2 Inter,system-ui,sans-serif;cursor:pointer;touch-action:manipulation;-webkit-user-select:none;user-select:none;
  -webkit-touch-callout:none;transition:transform .16s var(--cal-ease),opacity .16s var(--cal-ease);}
#ca-load .cal-btn-main{background:var(--accent);color:var(--bg);}
#ca-load .cal-next{height:48px;white-space:nowrap;color:var(--accent);box-shadow:inset 0 0 0 1px color-mix(in oklab,var(--accent) 35%,transparent);}
#ca-load .cal-start{height:48px;border-radius:14px;padding:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  opacity:0;visibility:hidden;transition:opacity .25s var(--cal-ease) .12s,visibility 0s linear .12s,transform .16s var(--cal-ease);}
#ca-load[data-start] .cal-start{opacity:1;visibility:visible;}
#ca-load[data-row-moving] .cal-start{pointer-events:none;}   /* taps pass through while the row opens (loading-screen.js guardRow) */
#ca-load .cal-btn:active{transform:scale(.97);}
#ca-load .cal-btn:focus-visible{outline:2px solid var(--accent);outline-offset:3px;}
@media (hover:hover) and (pointer:fine){#ca-load .cal-btn:hover{opacity:.88;}}

/* No Next card (no deck, its switch off, or a deck of one): Start alone in the row, full width once it appears. */
#ca-load:not([data-next]) .cal-row{grid-template-columns:1fr;gap:0;margin-top:22px;transition:none;}
#ca-load:not([data-next]):not([data-start]) .cal-row{display:none;}
#ca-load:not([data-next])[data-start] .cal-start{transition:none;animation:cal-rise .25s var(--cal-ease) both;}

/* Under the row: the start-now line, the short-set message, the notices and their buttons. */
#ca-load .cal-foot:empty{display:none;}
#ca-load .cal-foot{margin-top:12px;}
#ca-load .cal-foot > *{animation:cal-fade .3s var(--cal-ease) .16s both;}
#ca-load .cal-start-line,#ca-load .cal-note{margin:0;font-size:14px;line-height:1.5;color:var(--cal-ink-soft);}
#ca-load .cal-btns{display:flex;flex-wrap:wrap;gap:10px;margin-top:12px;}
#ca-load .cal-btns .cal-btn{flex:1 1 140px;box-shadow:inset 0 0 0 1px var(--border);}
#ca-load .cal-btns .cal-btn-main{box-shadow:none;}
#ca-load[data-phase="slow"] .cal-foot,#ca-load:is([data-phase="failed"],[data-phase="backgrounded"]) .cal-foot{margin-top:22px;}
#ca-load[data-phase="slow"] .cal-note,#ca-load:is([data-phase="failed"],[data-phase="backgrounded"]) .cal-note{font-size:15px;color:var(--text);}

/* Failed and backgrounded: the notice replaces the build view. Cached: the notice and Start, with the cards if any. */
#ca-load:is([data-phase="failed"],[data-phase="backgrounded"]) :is(.cal-progress,.cal-cards,.cal-row){display:none;}
#ca-load[data-phase="cached"] .cal-progress{display:none;}
#ca-load[data-phase="cached"] .cal-cards{margin-top:22px;}

/* The exam simulator (release 1b, design 1 "All four"): the hands-on line under the count, the 4 tips in the card's
   place, and Start exam with its clock note in a slot kept from the first paint, so nothing jumps when they come in
   (opacity and a 6px rise, 250ms, the note 60ms later). No Next card, no flashcards. */
#ca-load .cal-extra{margin:0 0 4px;font-size:14px;line-height:1.45;color:var(--cal-muted);}
#ca-load .cal-tips{margin-top:22px;transition:opacity .25s var(--cal-ease);}
#ca-load .cal-tips[data-pending]{visibility:hidden;opacity:0;}   /* its space is kept until Sim Lab has answered */
#ca-load .cal-tips-label{margin:0 0 8px;font-size:14px;font-weight:600;line-height:1.5;color:var(--cal-ink-soft);}
#ca-load .cal-tips-list{list-style:none;margin:0;padding:2px 18px;border-radius:18px;background:var(--cal-card);
  box-shadow:inset 0 0 0 1px var(--border),0 1px 2px color-mix(in oklab,var(--text) 6%,transparent);}
#ca-load .cal-examtip{display:grid;grid-template-columns:8px minmax(0,1fr);column-gap:16px;padding:14px 0;overflow-wrap:anywhere;}
#ca-load .cal-examtip + .cal-examtip{border-top:1px solid var(--border);}
#ca-load .cal-examtip-dot{width:8px;height:8px;margin-top:7px;border-radius:50%;background:var(--accent);}
#ca-load .cal-examtip p{margin:0;font-size:15px;line-height:1.5;color:var(--cal-ink-soft);}
#ca-load .cal-examtip-lead{display:block;font-weight:600;color:var(--text);}
#ca-load .cal-examtip-body{display:block;}
/* data-timed: the exam and the Diagnostic (release 2b), both with their own countdown: no early start, the clock note's room. */
#ca-load[data-timed]:not([data-next]) .cal-row{display:grid;grid-template-columns:1fr;gap:0;margin-top:16px;transition:none;}
#ca-load[data-timed]:not([data-next]):not([data-start]) .cal-start{opacity:0;visibility:hidden;transform:translateY(6px);animation:none;
  transition:opacity .25s var(--cal-ease),transform .25s var(--cal-ease),visibility 0s linear .25s;}
#ca-load[data-timed]:not([data-next])[data-start] .cal-start{opacity:1;visibility:visible;transform:none;animation:none;
  transition:opacity .25s var(--cal-ease),transform .25s var(--cal-ease),visibility 0s;}
#ca-load[data-timed] .cal-foot,#ca-load[data-timed] .cal-foot:empty{display:block;min-height:42px;margin-top:10px;}   /* the clock note's room (two lines on a phone), kept from the first paint */
/* The status line holds a short exam's line (up to 2 lines on desktop, 3 on a phone), kept from the first paint so the
   tips never move when it settles. */
#ca-load[data-timed] .cal-status{min-height:42px;}
@media (max-width:420px){#ca-load[data-timed] .cal-status{min-height:63px;}}
#ca-load[data-timed][data-phase="short"] .cal-status{color:var(--text);}
#ca-load[data-timed]:is([data-phase="allReady"],[data-phase="short"]) .cal-foot{text-align:center;}
#ca-load[data-timed]:is([data-phase="allReady"],[data-phase="short"]) .cal-note{color:var(--cal-muted);}
#ca-load[data-timed] .cal-foot > *{animation:cal-rise6 .25s var(--cal-ease) .06s both;}
@keyframes cal-rise6{from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:none;}}
#ca-load:is([data-phase="failed"],[data-phase="backgrounded"]) .cal-tips{display:none;}

/* The status-only mode (release 2a, reused by 2c): the eyebrow and the status line as the heading, nothing to count. */
#ca-load[data-status-only] .cal-headline{margin:4px 0 0;font-family:'Fraunces',Georgia,serif;font-size:24px;font-weight:600;letter-spacing:-0.01em;
  line-height:1.25;color:var(--text);text-wrap:balance;}
#ca-load[data-status-only] .cal-progress > .cal-headline:first-child{margin-top:22px;}
html[data-theme] body #ca-load[data-status-only] .cal-headline:focus{outline:none!important;box-shadow:none!important;}
/* Release 2c: a drill waiting a moment for the learner's plan keeps its status line's place, hidden; past the hold it
   fades in (the house curve, opacity only). A quick wait never shows it, so nothing flashes. */
#ca-load[data-status-only][data-fade] .cal-headline{transition:opacity .2s var(--cal-ease);}
#ca-load[data-hold] .cal-headline{opacity:0;}
/* With cards below, the status line keeps room for two lines, so a longer line (the checking stage) never moves them. */
#ca-load[data-status-only][data-next] .cal-headline{min-height:2.5em;}
#ca-load[data-hold] .cal-headline.cal-shimmer::before{animation-play-state:paused;}
/* While it works, the status line shimmers: the dim line plus one bright band sweeping across it (antalik-effects,
   primitives section 10; BRAND.md: the one shimmer source). The app's own text token in each theme; 2s linear sweep,
   the source's number (constant motion is linear). Paused when hidden or off-view; plain and still under reduced motion. */
html[data-theme="dark"] #ca-load{--cal-shimmer-base:color-mix(in srgb,var(--text) 58%,transparent);--cal-shimmer-hi:var(--text);}
html[data-theme="light"] #ca-load{--cal-shimmer-base:color-mix(in srgb,var(--text) 62%,transparent);--cal-shimmer-hi:var(--text);}
#ca-load .cal-headline.cal-shimmer{position:relative;color:var(--cal-shimmer-base,var(--text));}
#ca-load .cal-headline.cal-shimmer::before{content:attr(data-text);position:absolute;inset:0;pointer-events:none;
  background-image:linear-gradient(90deg,transparent 0 40%,var(--cal-shimmer-hi,var(--text)) 50%,transparent 60% 100%);
  background-size:400% 100%;background-repeat:no-repeat;-webkit-background-clip:text;background-clip:text;
  color:transparent;-webkit-text-fill-color:transparent;animation:cal-shimmer 2s linear infinite;}
#ca-load[data-paused] .cal-headline.cal-shimmer::before{animation-play-state:paused;}
@keyframes cal-shimmer{0%{background-position:100% 0;}100%{background-position:0% 0;}}

/* Narrow phones: the status line keeps room for two lines (a top-up line wraps), and Next card's text fits its column. */
@media (max-width:420px){#ca-load .cal-status{min-height:42px;}}
@media (max-width:360px){#ca-load .cal-next{padding:0 6px;}}

/* Short screens (320 x 568, a phone on its side): a shorter card and tighter gaps, so Start stays near. */
@media (max-height:600px){
  #ca-load .cal-eyebrow,#ca-load .cal-eyerow,#ca-load .cal-progress > .cal-count:first-child{margin-top:14px;}
  #ca-load .cal-cards{margin-top:14px;}
  #ca-load .cal-card{min-height:172px;}
  #ca-load .cal-face{padding:14px 16px;gap:8px;}
  #ca-load .cal-term{font-size:24px;}
  #ca-load .cal-def{font-size:15px;line-height:1.4;}
}
/* Reading text follows the iPhone text size, as text-size.css does for the other screens (phone width only;
   features/text-size.js sets data-rt and --rt). Buttons stay fixed; the count and the term grow at half the rate, like headings.
   The card has a minimum height, never a fixed one, so large text grows it and never clips. */
@media (max-width:899px){
  html[data-rt] body #ca-load :is(.cal-eyebrow,.cal-sub,.cal-status,.cal-cards-label,.cal-meta,.cal-def,.cal-start-line,.cal-note,.cal-extra,.cal-tips-label,.cal-examtip p){zoom:var(--rt,1);}
  html[data-rt] body #ca-load :is(.cal-count,.cal-term,.cal-headline){zoom:calc(1 + (var(--rt,1) - 1) / 2);}
}
/* Reduced motion: same states, fades only. The card crossfades its sides (200ms) instead of turning; the bar and the
   count jump; the row switches at once and Start simply appears; text swaps fade with no blur; no press scale. */
@media (prefers-reduced-motion:reduce){
  #ca-load[data-status-only][data-fade] .cal-headline{transition:none;}
  #ca-load .cal-headline.cal-shimmer{color:var(--text);}
  #ca-load .cal-headline.cal-shimmer::before{display:none;animation:none!important;}   /* one static frame: the plain status line */
  #ca-load .cal-line-track > span,#ca-load .cal-row,#ca-load .cal-start,#ca-load .cal-btn,#ca-load .cal-tips,
  html[data-theme] body #page-loading.ca-load-on .load-cancel{transition:none!important;}
  #ca-load .cal-n.cal-bump,#ca-load:not([data-next])[data-start] .cal-start,#ca-load .cal-foot > *{animation:none!important;}
  #ca-load .cal-orb-s,#ca-load .cal-orb-b{animation:none!important;}   /* one still frame */
  #ca-load[data-timed] .cal-start{transform:none!important;}   /* the exam's Start: no rise, it just appears */
  .cal-xf > .cal-ghost{animation:cal-fade .2s linear reverse forwards!important;}
  #ca-load .cal-btn:active,html[data-theme] body #page-loading.ca-load-on .load-cancel:active{transform:none;}
  #ca-load .cal-card,#ca-load .cal-card[aria-pressed="true"]{transform:none;transition:none;}
  #ca-load .cal-face{-webkit-backface-visibility:visible;backface-visibility:visible;transition:opacity .2s var(--cal-ease);}
  #ca-load .cal-face-answer{transform:none;}
  /* A short set's message still fades in (no slide). */
  #ca-load[data-phase="short"] .cal-foot > *{animation:cal-fade .2s linear!important;}
}
