/* ============================================================
   bw-loading.css
   One shared loading component for every Bone Wizardry wait.

   The sign-in screen (rta-site/auth/complete/index.html) owns
   the look: the mascot mark, a serif line, and a thin progress
   light on a dark gradient. This file is that same component,
   published once so a member sees one loading language wherever
   a page is still working.

   Markup contract (any page may use it):

     <div class="bw-load">
       <span class="bw-load__mark" aria-hidden="true"></span>
       <p class="bw-load__title">Loading your QBank</p>
       <span class="bw-load__progress" aria-hidden="true"></span>
     </div>

   Variants:
     .bw-load           panel: inherits the page surface and ink
     .bw-load--screen   full screen: the sign-in gradient and its ink
     .bw-load--compact  a smaller wait for a panel that must not grow

   An optional supporting line may follow the title:

     <p class="bw-load__body">Your saved answers are on the way.</p>

   It mirrors the sign-in screen's status line: one calm sentence under
   the words, never a second headline.

   The ink follows the page (color: inherit), so the same markup
   reads correctly on a light page and on a dark one. The one
   exception is .bw-load--screen, which paints the sign-in
   surface itself.

   A page that already announces its own wait keeps its own live
   region: put role="status" on the element the page already
   updates, and leave the shared block presentational. The shared
   block never carries role="status" itself, so a page cannot end
   up with two live regions announcing the same wait.

   Motion: the progress light sweeps only when motion is welcome.
   It stops for prefers-reduced-motion and for the site's own
   data-bw-animations-effective="reduce" choice, so the wait still
   reads as a wait.
   ============================================================ */

.bw-load{
  --bw-load-accent:#c6b2f5;
  --bw-load-track:color-mix(in srgb,currentColor 14%,transparent);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:20px;
  padding:32px 24px;
  text-align:center;
  color:inherit;
  font:400 1rem/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;
}
.bw-load__mark{
  position:relative;
  display:block;
  width:40px;
  height:40px;
  flex:none;
  color:inherit;
  animation:bw-load-mark .7s cubic-bezier(.2,0,0,1) .06s both;
}
.bw-load__mark::before{
  content:"";
  position:absolute;
  inset:0;
  background:currentColor;
  -webkit-mask:url('/img/logo/bw-logo-white-128.png') center/contain no-repeat;
  mask:url('/img/logo/bw-logo-white-128.png') center/contain no-repeat;
}
/* The hat-tip sparkle of the mark, lit in the accent colour. */
.bw-load__mark::after{
  content:"";
  position:absolute;
  left:calc(89.8% - 7px);
  top:calc(11.7% - 7px);
  width:14px;
  height:14px;
  border-radius:50%;
  background:radial-gradient(circle,var(--bw-load-accent) 0,color-mix(in srgb,var(--bw-load-accent) 35%,transparent) 32%,transparent 70%);
  opacity:0;
  animation:bw-load-twinkle 2.4s ease-in-out .5s infinite;
}
.bw-load__title{
  margin:0;
  font:400 1.625rem/1.2 Newsreader,Georgia,serif;
  letter-spacing:-.012em;
  color:inherit;
  text-wrap:balance;
}
.bw-load__body{
  margin:0;
  max-width:24rem;
  font:400 .9375rem/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;
  color:color-mix(in srgb,currentColor 72%,transparent);
  text-wrap:pretty;
}
.bw-load__progress{
  position:relative;
  display:block;
  width:112px;
  height:2px;
  border-radius:2px;
  overflow:hidden;
  background:var(--bw-load-track);
}
.bw-load__progress::before{
  content:"";
  position:absolute;
  top:0;
  bottom:0;
  left:0;
  width:44%;
  border-radius:inherit;
  background:linear-gradient(90deg,transparent,var(--bw-load-accent),transparent);
  animation:bw-load-sweep 1.5s cubic-bezier(.45,0,.25,1) infinite;
}
/* A compact wait for a panel that must not grow while it waits. */
.bw-load--compact{gap:12px;padding:20px 12px}
.bw-load--compact .bw-load__mark{width:30px;height:30px}
.bw-load--compact .bw-load__title{font-size:1.125rem}
.bw-load--compact .bw-load__progress{width:88px}

/* A wait that has settled on an error. The sign-in screen stops its light
   the same way ([data-bw-auth-state=error] .bwac-progress{display:none}),
   so a message that is no longer a wait must not keep sweeping. */
.bw-load--settled .bw-load__progress{display:none}
.bw-load--settled .bw-load__mark::after{animation:none!important;opacity:.8;transform:scale(.8)}

/* The full-screen wait paints the sign-in surface and its ink. */
.bw-load--screen{
  --bw-load-accent:#c6b2f5;
  --bw-load-track:rgba(245,243,237,.12);
  min-height:100vh;
  min-height:100dvh;
  gap:20px;
  padding:48px 24px;
  color:#f5f3ed;
  background:linear-gradient(180deg,#17121f 0%,#221a2e 52%,#17121f 100%);
}
.bw-load--screen .bw-load__title{color:#f5f3ed}
.bw-study-handoff{position:fixed;inset:0;z-index:2147483001;box-sizing:border-box}
#bw-next-step-loader{display:none}
html[data-bw-next-step-launch] #bw-next-step-loader{display:flex}
html[data-bw-next-step-launch] body > :not(#bw-next-step-loader){visibility:hidden}
.bw-load--screen .bw-load__progress{--bw-load-track:rgba(245,243,237,.12)}

@keyframes bw-load-mark{from{opacity:0;transform:translateY(6px) scale(.92)}to{opacity:1;transform:none}}
@keyframes bw-load-twinkle{0%,100%{opacity:.15;transform:scale(.6)}50%{opacity:1;transform:scale(1)}}
@keyframes bw-load-sweep{from{transform:translateX(-100%)}to{transform:translateX(230%)}}

/* The site's own motion choice (data-bw-animations-effective) and the OS
   preference both stop the sweep. The wait still reads as a wait: the mark
   settles, the light sits still, and the words stay. */
@media (prefers-reduced-motion:reduce){
  .bw-load__mark{animation-name:bw-load-fade!important;opacity:1;transform:none}
  .bw-load__mark::after{animation:none!important;opacity:.8;transform:scale(.8)}
  .bw-load__progress::before{animation:none!important;left:28%;transform:none}
}
[data-bw-animations-effective=reduce] .bw-load__mark,
[data-bw-animations-effective=reduce] .bw-load__mark::after,
[data-bw-animations-effective=reduce] .bw-load__progress::before{animation:none!important}
[data-bw-animations-effective=reduce] .bw-load__mark{opacity:1;transform:none;animation-name:bw-load-fade!important}
[data-bw-animations-effective=reduce] .bw-load__mark::after{opacity:.8;transform:scale(.8)}
[data-bw-animations-effective=reduce] .bw-load__progress::before{left:28%;transform:none}
@keyframes bw-load-fade{from{opacity:0}to{opacity:1}}

/* Pages that carry their own serif face keep it; pages without one fall
   back to the same serif the sign-in screen uses. */
@supports not (font-variation-settings:normal){
  .bw-load__title{font-family:Newsreader,Georgia,serif}
}

/* Original Daily Rounds painted path and wizard (7852c12582ca), restored
   as the shared waiting scene. No data or auth waits are added here. */
.bw-load[hidden]{display:none!important}
.bw-load--journey{
  --bw-wizard-border:color-mix(in srgb,currentColor 17%,transparent);
  --bw-wizard-skeleton:color-mix(in srgb,currentColor 9%,transparent);
  --bw-wizard-skeleton-hi:color-mix(in srgb,currentColor 17%,transparent);
  width:100%;min-width:0;max-width:100%;gap:11px;
  padding:clamp(16px,3vw,30px) 12px;
}
.bw-load--journey .bw-load__mark,.bw-load--journey .bw-load__progress{display:none}
.bw-load--journey .bw-load__title{
  opacity:0;animation:bw-wizard-text-in .45s ease 1.2s both;
  font-size:clamp(1.125rem,3.5vw,1.625rem);
}
.bw-wizard__stage{
  position:relative;display:block;order:-1;
  width:min(100%,460px);height:clamp(150px,33vw,205px);
  overflow:hidden;border-radius:18px;
}
.bw-wizard__skeleton{
  position:absolute;inset:0;display:flex;flex-direction:column;gap:12px;
  padding:14px 12px;opacity:0;visibility:hidden;
  animation:bw-wizard-skeleton-phase 1.2s step-end both;
}
.bw-wizard__ghost-heading,.bw-wizard__ghost-feature,.bw-wizard__ghost-card{
  display:block;border-radius:10px;
  background:linear-gradient(105deg,var(--bw-wizard-skeleton),var(--bw-wizard-skeleton-hi),var(--bw-wizard-skeleton)) 0/250% 100%;
  animation:bw-wizard-shimmer 2.2s linear infinite;
}
.bw-wizard__ghost-heading{height:18px;width:58%}
.bw-wizard__ghost-feature{height:82px;flex:1;width:100%;border-radius:16px}
.bw-wizard__ghost-row{display:grid;grid-template-columns:1fr 1fr;gap:12px;min-height:30px}
.bw-wizard__ghost-card{min-height:30px}
.bw-load--journey[data-bw-loader-layout=qbank] .bw-wizard__ghost-feature,
.bw-load--journey[data-bw-loader-layout=review] .bw-wizard__ghost-feature{height:105px}
.bw-load--journey[data-bw-loader-layout=portal] .bw-wizard__ghost-feature{height:68px}
.bw-load--journey[data-bw-loader-layout=rounds] .bw-wizard__ghost-heading{width:72%}
.bw-wizard__scene{
  position:absolute;inset:0;overflow:hidden;isolation:isolate;
  border:1px solid var(--bw-wizard-border);border-radius:18px;
  background:#352d3d url('/assets/bw-study/rounds-journey-golden-a.webp') center 65%/cover no-repeat;
  opacity:0;animation:bw-wizard-scene-in .5s ease 1.2s forwards;
}
.bw-wizard__scene::after{
  content:"";position:absolute;inset:auto 0 0;height:37%;
  background:linear-gradient(0deg,rgba(10,8,20,.28),transparent);
  pointer-events:none;
}
.bw-wizard__sprite{
  --bw-wizard-width:min(80%,clamp(78px,22vw,117px));
  position:absolute;left:10%;bottom:4%;z-index:1;
  width:var(--bw-wizard-width);height:clamp(82px,23vw,123px);max-width:none;
  background:url('/assets/bw-study/rounds-journey-wizard-a.webp') center/contain no-repeat;
  filter:drop-shadow(0 3px 4px rgba(0,0,0,.35));
  transform-origin:center 95%;
  /* The art faces right. Reverse its facing at each endpoint, never
     interpolate the mirror while the characters are travelling. */
  animation:bw-wizard-walk 7.8s ease-in-out infinite alternate,
    bw-wizard-facing 15.6s steps(1,end) infinite,
    bw-wizard-step .65s ease-in-out infinite alternate;
}
.bw-wizard__copy{
  position:relative;display:block;width:min(100%,340px);
  min-height:1.55em;margin:0;
  font:400 .85rem/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;
  color:color-mix(in srgb,currentColor 75%,transparent);
  opacity:0;animation:bw-wizard-text-in .4s ease 1.3s forwards;
}
.bw-wizard__copy-line{position:absolute;inset:0;opacity:0;animation:bw-wizard-copy 12s linear infinite}
.bw-wizard__copy-line--2{animation-delay:4s}
.bw-wizard__copy-line--3{animation-delay:8s}
@keyframes bw-wizard-skeleton-phase{
  0%,24.9%{opacity:0;visibility:hidden}
  25%,99.9%{opacity:1;visibility:visible}
  100%{opacity:0;visibility:hidden}
}
@keyframes bw-wizard-scene-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
@keyframes bw-wizard-text-in{from{opacity:0}to{opacity:1}}
@keyframes bw-wizard-shimmer{from{background-position:120% 0}to{background-position:-120% 0}}
@keyframes bw-wizard-walk{
  from{left:10%}
  to{left:calc(90% - var(--bw-wizard-width))}
}
@keyframes bw-wizard-facing{
  0%,100%{transform:scaleX(1)}
  50%{transform:scaleX(-1)}
}
@keyframes bw-wizard-step{
  from{translate:0 0}
  to{translate:0 -2px}
}
@keyframes bw-wizard-copy{
  0%,29%{opacity:1}33%,96%{opacity:0}100%{opacity:1}
}
html:is([data-bw-theme=night],[data-bw-theme=lights-out],[data-bw-theme=exam]) .bw-wizard__scene{
  background-image:url('/assets/bw-study/rounds-journey-night-a.webp');
}
html:is([data-bw-theme=lights-out],[data-bw-theme=exam]) .bw-wizard__scene{filter:brightness(.75)}
html[data-bw-theme=paper] .bw-wizard__scene{background-color:#e7dcc6}
.bw-load--settled .bw-wizard__sprite,.bw-load--settled .bw-wizard__copy-line{animation:none!important}
@media (prefers-reduced-motion:reduce){
  .bw-wizard__skeleton{display:none!important}
  .bw-wizard__scene,.bw-wizard__copy,.bw-load--journey .bw-load__title{opacity:1!important;animation:none!important;transform:none!important}
  .bw-wizard__sprite{animation:none!important;left:calc(50% - var(--bw-wizard-width) / 2)!important;transform:none!important}
  .bw-wizard__copy-line{animation:none!important;opacity:0}
  .bw-wizard__copy-line--1{opacity:1}
}
:root[data-bw-animations-effective=reduce] .bw-wizard__skeleton,
:root[data-bw-animations-effective=off] .bw-wizard__skeleton{display:none!important}
:root:is([data-bw-animations-effective=reduce],[data-bw-animations-effective=off]) :is(.bw-wizard__scene,.bw-wizard__copy,.bw-load--journey .bw-load__title){
  opacity:1!important;animation:none!important;transform:none!important
}
:root:is([data-bw-animations-effective=reduce],[data-bw-animations-effective=off]) .bw-wizard__sprite{
  animation:none!important;left:calc(50% - var(--bw-wizard-width) / 2)!important;transform:none!important
}
:root:is([data-bw-animations-effective=reduce],[data-bw-animations-effective=off]) .bw-wizard__copy-line{animation:none!important;opacity:0}
:root:is([data-bw-animations-effective=reduce],[data-bw-animations-effective=off]) .bw-wizard__copy-line--1{opacity:1}
/* Small screens use faithful, size-optimized copies of the original journey
   paintings so the scene is fully loaded before the 1.2-second reveal. */
@media (max-width:640px){
  .bw-wizard__scene{background-image:url('/assets/bw-study/rounds-journey-golden-loader.webp')}
  html:is([data-bw-theme=night],[data-bw-theme=lights-out],[data-bw-theme=exam]) .bw-wizard__scene{
    background-image:url('/assets/bw-study/rounds-journey-night-loader.webp');
  }
}
@media (max-width:420px){
  .bw-load--journey{padding:12px 4px}
  .bw-wizard__stage{height:164px}
  .bw-wizard__sprite{height:93px}
}

/* Card Review's status lives below the deck controls. Keep its active
   loading journey above the fold instead of pushing the illustration away. */
#cc-wizard-catalog-loader.bw-load--journey:not([hidden]),
#cc-wizard-review-loader.bw-load--journey:not([hidden]){
  position:fixed;inset:0;z-index:2147481000;
  box-sizing:border-box;width:100vw;max-width:none;height:100dvh;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:clamp(12px,5vw,24px);
  background:#f8f5ef;color:#26212e;
}
/* The scene covers the header and every action. A load that never settles must
   not keep it there: after 15 seconds on screen it yields, and the page's own
   status line stays visible. */
#cc-wizard-catalog-loader.bw-load--journey:not([hidden]),
#cc-wizard-review-loader.bw-load--journey:not([hidden]){ animation:bw-wizard-yield 0s linear 15s forwards; }
@keyframes bw-wizard-yield { to { display:none; } }
#cc-wizard-catalog-loader.bw-load--journey .bw-load__title,
#cc-wizard-catalog-loader.bw-load--journey .bw-wizard__copy,
#cc-wizard-review-loader.bw-load--journey .bw-load__title,
#cc-wizard-review-loader.bw-load--journey .bw-wizard__copy{color:inherit}
html:is([data-bw-theme=night],[data-bw-theme=lights-out],[data-bw-theme=exam])
  :is(#cc-wizard-catalog-loader.bw-load--journey,#cc-wizard-review-loader.bw-load--journey):not([hidden]){
  background:#18131f;color:#f0eaf7;
}


/* Today and the Study Desk already paint their own real-layout skeleton.
   Let the restored walking wizard arrive after it, without hiding the
   existing hero or shifting the card while account data resolves. */
#bw-home-loading[data-today-boot]:not([data-status="error"]) .bw-load.bw-load--journey{
  position:absolute!important;inset:12vh auto auto 50%!important;
  transform:translateX(-50%);
  width:min(88vw,420px)!important;height:auto!important;
  overflow:visible!important;clip:auto!important;clip-path:none!important;
  white-space:normal!important;z-index:4;
  padding:0;
  opacity:0;animation:bw-wizard-text-in .4s ease 1.2s both;
}
#bw-home-loading[data-today-boot] .bw-load--journey .bw-wizard__stage{
  height:clamp(145px,24vh,190px);
}
#bw-home-loading[data-today-boot][data-boot-theme=paper] .bw-load--journey{color:#2b2a35}
@media (prefers-reduced-motion:reduce){
  #bw-home-loading[data-today-boot]:not([data-status="error"]) .bw-load.bw-load--journey{
    animation:none!important;opacity:1!important
  }
}
:root:is([data-bw-animations-effective=reduce],[data-bw-animations-effective=off])
#bw-home-loading[data-today-boot]:not([data-status="error"]) .bw-load.bw-load--journey{
  animation:none!important;opacity:1!important
}

/* A settled, witnessed cached desk uses the legacy desk's own paired palette.
   Do not inherit workspace text colors before the live frame mounts. */
html:has(#member-home:not([hidden])[data-sync-state="cached"]) #bw-seamless-cover{display:none!important}
#member-home[data-sync-state="cached"]{background:var(--md-bg,#17121f);color:var(--md-ink,#f7f2fb)}
#member-home[data-sync-state="cached"] :is(#md-title,#md-next-title,#md-today-exam-name,.md-hub-name){color:var(--md-ink,#f7f2fb)!important}
#member-home[data-sync-state="cached"] :is(#md-next-copy,#md-freshness,.md-hub-note){color:var(--md-muted,#c1b6ce)!important}
#member-home[data-sync-state="cached"] :is(#md-today,.md-hub-link){background:var(--md-panel,#201929)!important;color:var(--md-ink,#f7f2fb)}
#member-home[data-sync-state="cached"] #md-freshness{display:block!important}
