/* Working states at two scales: `.proc` inline in a status line (data-kind changes only hue
   and wording) and `.session-boot` full page. Own file because components.css was only loaded
   by classic_tasks.html. Three dots, not a spinner; the exception is THE SAVE INDICATOR. */

.proc{
  display:inline-flex; align-items:center; gap:7px;
  font-size:var(--a-fs-12); color:var(--text-dim);
  /* Non-zero min-height so showing and clearing the indicator cannot reflow the panel
     it sits in — a status area that changes height on every AI call makes the whole
     pane twitch. */
  min-height:1em;
}
.proc-dots{ display:inline-flex; align-items:center; gap:3px; flex:0 0 auto; }
.proc-dots i{
  width:5px; height:5px; border-radius:50%;
  background:var(--proc-accent, var(--accent));
  opacity:.35;
  animation:proc-pulse var(--dur-dots) ease-in-out infinite;
}
/* Staggered, not synchronised: three dots pulsing together is a throb, three in
   sequence is motion travelling left to right, which reads as progress. */
.proc-dots i:nth-child(2){ animation-delay:var(--dur-dots-step); }
/* Twice the step, expressed as a calc rather than a second number to keep in step. */
.proc-dots i:nth-child(3){ animation-delay:calc(var(--dur-dots-step) * 2); }

@keyframes proc-pulse{
  0%, 80%, 100%{ opacity:.28; transform:scale(.82); }
  40%          { opacity:1;   transform:scale(1);   }
}

.proc-msg{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Kind = hue only. Every kind uses tokens that already exist and already flip with the
   theme, so none of this needs a light-mode rule of its own. */
.proc[data-kind="ai"]      { --proc-accent:var(--purple); }
.proc[data-kind="analyze"] { --proc-accent:var(--purple); }
.proc[data-kind="paste"]   { --proc-accent:var(--accent); }
.proc[data-kind="format"]  { --proc-accent:var(--accent); }
.proc[data-kind="save"]    { --proc-accent:var(--accent); }  /* the save ring — see below */
.proc[data-kind="load"]    { --proc-accent:var(--accent); }
.proc[data-kind="search"]  { --proc-accent:var(--accent); }

/* Under reduced motion the dots stop and settle at full opacity rather than disappearing:
   a user who asked for less animation still needs to see that something is in progress. */
@media (prefers-reduced-motion: reduce){
  .proc-dots i{ animation:none; opacity:.85; transform:none; }
}

/* THE SAVE INDICATOR: saveIndicator() in JS/components/processing.js. Spinner + pulsing text:
   accent ring with "Saving..." breathing; saved is a fading success check; error is a
   persistent danger mark. Every saving surface draws it in its own slot (sys_design-system.md
   §20f). Icons are CSS; colour is set on the indicator because `.proc` sets --text-dim. */
/* THE SLOT, for a surface that has no status line of its own to host the indicator (the comment
   editor's action row): the canonical host class, so no surface invents one. */
.save-slot{ display:inline-flex; align-items:center; min-width:0; min-height:1.5em; font-size:var(--a-fs-12); }
.save-ind{ --save-ind-size:12px; max-width:100%; }
/* Never wider than its host, and a sentence wraps. `.proc` keeps one line, so in a block host
   (a `.cfg-status` in a dialog) an error grew to full sentence width and scrolled the dialog
   sideways at 400px. Capped at the host, the words wrap. */
.save-ind .proc-msg{ white-space:normal; min-width:0; overflow-wrap:anywhere; }
/* One-line slots keep one line: frame/preview header, canonical inline slot, note editor header
   slot and tab-row readout (`.save-status`) must not change height on failure, so the message
   ellipses (see _docs/tests/save-indicator-wraps.test.js). */
.save-slot .save-ind .proc-msg,
.a-preview-save .save-ind .proc-msg,
.a-save .save-ind .proc-msg,
.save-status .save-ind .proc-msg{ white-space:nowrap; overflow-wrap:normal; text-overflow:ellipsis; }
.save-ind-icon{
  position:relative; flex:0 0 auto; box-sizing:border-box;
  width:var(--save-ind-size); height:var(--save-ind-size); border-radius:50%;
}
.save-ind[data-save="saving"] .save-ind-icon{
  border:2px solid var(--border);
  border-top-color:var(--accent);
  animation:save-ind-spin var(--dur-spin) linear infinite;
}
.save-ind[data-save="saving"] .proc-msg{
  animation:save-ind-pulse var(--dur-dots) ease-in-out infinite alternate;
}
.save-ind[data-save="saved"]{ color:var(--green-text); }
/* The check: an L of two borders, turned. */
.save-ind[data-save="saved"] .save-ind-icon::after{
  content:''; position:absolute; left:50%; top:45%;
  width:4px; height:7px; box-sizing:border-box;
  border-right:2px solid currentColor; border-bottom:2px solid currentColor;
  transform:translate(-50%, -50%) rotate(45deg);
}
.save-ind[data-save="error"]{ color:var(--red-text); }
/* The warning mark: a ring with "!" — never colour alone (§18), the words carry it too. */
.save-ind[data-save="error"] .save-ind-icon{
  --save-ind-size:14px;
  border:1.5px solid currentColor;
  display:inline-flex; align-items:center; justify-content:center;
}
.save-ind[data-save="error"] .save-ind-icon::after{
  /* 11px: the type floor (§18) holds for a glyph too — the ring grows to 14px to hold it. */
  content:'!'; font-size:var(--a-fs-11); font-weight:700; line-height:var(--a-lh-ctl);
}
/* WARN — saved, with a caveat the reader must see (a limit the database capped). A triangle, not
   the error's ring, so the two are told apart by shape as well as colour (§18); it never fades. */
.save-ind[data-save="warn"]{ color:var(--warn-text); }
.save-ind[data-save="warn"] .save-ind-icon{
  --save-ind-size:16px; border-radius:0;
  background:currentColor; clip-path:polygon(50% 0, 100% 100%, 0 100%);
  display:inline-flex; align-items:flex-end; justify-content:center;
}
.save-ind[data-save="warn"] .save-ind-icon::after{
  content:'!'; font-size:var(--a-fs-11); font-weight:700; line-height:var(--a-lh-ctl); color:var(--panel);
  padding-bottom:1px;
}
.save-ind.is-fading{ opacity:0; transition:opacity var(--dur-exit) ease-out; }

@keyframes save-ind-spin{ to{ transform:rotate(360deg); } }
@keyframes save-ind-pulse{ from{ opacity:1; } to{ opacity:.5; } }

/* Under reduced motion the ring stops — still drawn, as a static arc, so "in progress" is still
   on screen — and the words stop breathing. The saved/error icons and colours are unchanged, so
   every state change is as obvious as it was; the fade collapses to a frame. */
@media (prefers-reduced-motion: reduce){
  .save-ind[data-save="saving"] .save-ind-icon{ animation:none !important; }
  .save-ind[data-save="saving"] .proc-msg{ animation:none !important; opacity:1; }
  .save-ind.is-fading{ transition-duration:1ms !important; }
}

/* ---------- THE BLOCK LOADER ----------
   The `.proc` statement filling a region that is fetching what it exists to
   show. Reuses `.proc-dots` (one motion means "working"); only layout is new. It fills its own
   content area only, no overlay or blocking. min-height reserves space so the panel does not
   jump when the list arrives. Tokens only. */
.loading-block{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:11px; padding:34px 20px; min-height:160px; text-align:center;
}
/* Larger than the inline dots, because this one is being looked AT rather than glanced at
   beside a field. Same animation, same stagger, same reduced-motion answer. */
.loading-block .proc-dots{ gap:5px; }
.loading-block .proc-dots i{ width:7px; height:7px; }
/* SUBORDINATE TO NOTHING HERE — it is the only text in the region — but still quiet: it is
   an interim state, not a headline. Wrapped at a comfortable measure so a longer line breaks
   in the middle of the panel rather than stretching to its edges. */
.loading-block-msg{
  max-width:min(36ch, 84vw);
  font-size:var(--a-fs-12); font-weight:400; line-height:var(--a-lh-ui); color:var(--text-dim);
}
/* Stable screen-reader announcement while the visible line is rotating decoration. Declared
   here as well as in CSS/components.css on purpose: mobile.html loads this sheet but not that
   one. Keep the two identical. */
.sr-only-loading{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* Session boot, before the app knows who you are. Default-visible (no JS needed) so it cannot
   lose a race and flash the login screen at a signed-in reader. Background is hardcoded to
   match the auth gate because variables have not resolved yet. The light rule also matches
   `:root.theme-light`: the pre-paint script stamps only <html>, applyTheme() reaches <body> later. */
.session-boot{
  position:fixed; inset:0; z-index:var(--z-boot);
  display:flex; align-items:center; justify-content:center;
  background:#0a1628;
  /* THE BRAND'S OWN RUN OF COLOUR — blue at one corner, green at the other, the same
     relationship the mark carries. It was a gold/blue pair, which belonged to the palette this
     product had before it had a name of its own. */
  background-image:
    radial-gradient(ellipse 900px 600px at 82% 12%, rgba(46,141,247,.20), transparent 60%),
    radial-gradient(ellipse 1100px 700px at 12% 82%, rgba(16,185,129,.16), transparent 60%);
}
:root.theme-light .session-boot, body.theme-light .session-boot{
  background:#e7ebf2;
  background-image:
    radial-gradient(ellipse 900px 600px at 82% 12%, rgba(46,141,247,.14), transparent 60%),
    radial-gradient(ellipse 1100px 700px at 12% 82%, rgba(16,185,129,.12), transparent 60%);
}

/* Team custom colour at boot, avoiding a flash of stock navy. Pre-paint scripts stamp
   `data-theme-custom="1"` and the validated derived tokens (JS/core/theme-custom.js). Uses `--bg`
   (see alt-reveal-and-boot-curtain.test.js) and `background-color`, never the shorthand, so the
   atmospheric washes survive. Both selectors are (0,3,0): stay below them. */
:root[data-theme-custom="1"] .session-boot{ background-color:var(--bg); }

/* No card, no border, no logo. This should read as the app opening rather than a screen
   of its own — anything more substantial makes a 200ms check feel like a page. */
.session-boot .proc{ font-size:var(--a-fs-13); }

/* The overlay stacks now: the status line, then the quip beneath it. Column rather than a
   wrapper element so the existing .proc markup is untouched — it is still centred, it simply
   has something below it. */
.session-boot{ flex-direction:column; gap:10px; }

/* SUBORDINATE, and deliberately so. Smaller, dimmer, and never wider than a comfortable
   line: the primary answer to "what is happening" is the line above, and a joke that
   competes with it stops being an Easter egg and becomes the interface. */
.proc-quip{
  max-width:min(34ch, 82vw);
  text-align:center;
  font-size:var(--a-fs-12);
  line-height:var(--a-lh-ui);
  color:var(--text-faint);
  opacity:0;
  /* min-height reserves the line before there is text in it, so the status above does not
     shift downward when the quip arrives a frame later. */
  min-height:1.45em;
}
.proc-quip.is-in{
  opacity:1;
  transition:opacity var(--dur-quip) ease-out;
}
/* Both selectors, as on `.session-boot`: <html> is what the pre-paint script reaches. The light
   ramp is already redefined by CSS/tokens.css; this states the quip follows the theme at boot. */
:root.theme-light .proc-quip, body.theme-light .proc-quip{ color:var(--text-faint); }

@media (prefers-reduced-motion: reduce){
  /* The text still changes — that is content, not motion — but it arrives rather than
     fades. Nothing here animates. */
  .proc-quip.is-in{ transition:none; }
}

/* A page switch, decided at parse time (nav persist G1; sessionBootSwitchHint in JS/core/session-boot.js): the curtain
   starts below the carried bar height and shows nothing yet, so the first frame is never the curtain over the bar. The
   hint ends when the pre-painted bar is uncovered (`a-top-prepainted`, alt-page-top.css) or refused. */
:root.a-boot-switch .session-boot{ top:var(--a-prepaint-top, 0px); }
:root.a-boot-switch .session-boot > *{ visibility:hidden; }
/* And nothing of the page paints either until the bar is drawn: with no contentful paint, the browser keeps showing the
   previous page (paint holding), so the first new frame is the bar above the curtain rather than an empty strip. */
:root.a-boot-switch body > :not(#altTop):not(.session-boot){ visibility:hidden; }

/* Hidden by the state machine, not by a timer. */
.session-boot[hidden]{ display:none; }


/* The mark on the boot curtain. Size is fixed on the <img> (width/height) to reserve the box.
   Decorative, aria-hidden on the wrapper: `.session-boot` is already a live region, and a
   second announcement is the doubled-name defect sys_branding.md warns about. */
.boot-brand{
  display:flex; flex-direction:column; align-items:center; gap:10px;
  margin-bottom:6px;
}
.boot-brand img{
  display:block; width:82px; height:82px;
  /* A soft brand-coloured halo rather than a box: the mark has transparent edges and sits on a
     near-black ground, and a drop-shadow in its own colour is what keeps it from looking pasted
     on. Two shadows because one wide blur alone reads as fog. */
  filter:drop-shadow(0 0 22px rgba(56,189,248,.40)) drop-shadow(0 0 58px rgba(16,185,129,.26));
}
.boot-brand b{
  font-family:var(--app-brand-font, 'Space Grotesk', system-ui, sans-serif);
  font-size:22px; font-weight:700; letter-spacing:.20em; text-indent:.20em;
  color:#f4f6fb;
}
:root.theme-light .boot-brand b, body.theme-light .boot-brand b{ color:#16233a; }
:root.theme-light .boot-brand img, body.theme-light .boot-brand img{
  filter:drop-shadow(0 2px 10px rgba(46,141,247,.22));
}

/* IT BREATHES, ONCE, SLOWLY — and only if the reader has not asked it not to. The curtain can
   be up for a second or for three; a mark that is completely still reads as a frozen page, and
   anything faster than this reads as a spinner competing with the dots underneath it. */
@keyframes bootBrandIn{
  from{ opacity:0; transform:translateY(6px) scale(.97); }
  to  { opacity:1; transform:none; }
}
/* The duration is a token, not a number — `--dur-surface`, the same class of
   motion as a panel opening, so the product's sense of pace changes in one place. */
.boot-brand{ animation:bootBrandIn var(--dur-surface) var(--ease-out, cubic-bezier(.22,.61,.36,1)) both; }
@media (prefers-reduced-motion:reduce){
  .boot-brand{ animation:none; }
  .boot-brand img{ filter:none; }
}
