/* Rushd — loading state for the app frames.

   Wrap an iframe in <div class="rushd-frame"> and load /js/rushd-frame.js. The script sets
   data-rushd-frame on the wrapper:
     loading  the iframe is transparent and a shimmer fills its box
     loaded   the iframe's load event fired: the iframe fades in, the shimmer fades out
     error    no load in time, or an error event: a still panel with a Retry button
   Without the script the attribute is never set and the iframe shows as it always did.
   prefers-reduced-motion: reduce turns the sweep into a still panel and drops the fades.

   The iframe keeps its own fixed height. The wrapper takes its size from it, so the shimmer
   covers exactly the space the content will fill and nothing moves when it arrives.

   Looks: the default is for frames on a white section. Add .rushd-frame--dark for a navy
   frame. Add .rushd-frame--rounded for the site's 16px card corners, when the iframe has
   rounded corners or its edges do not show (a white frame on a white section).

   To change the shimmer colour, edit --rushd-frame-bg (the panel) and --rushd-frame-shine (the
   band that sweeps across it) below, or set them on one wrapper with an inline style. The
   timeout is in /js/rushd-frame.js. */
.rushd-frame{
  --rushd-frame-bg:#F3F4F6;                     /* panel under the shimmer (--bg-chip) */
  --rushd-frame-shine:rgba(255,255,255,.85);    /* the band that sweeps across it */
  --rushd-frame-fg:#4A5468;                     /* "Couldn't load content." */
  --rushd-frame-button-fg:#16304E;              /* Retry (--navy-1) */
  --rushd-frame-button-border:#D1D5DB;          /* (--border-3) */
  --rushd-frame-button-hover:#B0883E;           /* (--gold-deep) */
  --rushd-frame-radius:0;
  --rushd-frame-fade:300ms;
  position:relative;
}
.rushd-frame--dark{
  --rushd-frame-bg:#16304E;                     /* top of the embed hero (--navy-1), not mid-gradient --navy-2 */
  --rushd-frame-shine:rgba(235,230,218,.07);    /* a faint cream sweep (--cream) */
  --rushd-frame-fg:#EBE6DA;
  --rushd-frame-button-fg:#FCFAF4;              /* as the header's Sign in */
  --rushd-frame-button-border:rgba(216,180,99,.55);
  --rushd-frame-button-hover:#D8B463;
}
.rushd-frame--rounded{
  --rushd-frame-radius:16px;                    /* --radius-2xl */
}

.rushd-frame[data-rushd-frame]>iframe{
  transition:opacity var(--rushd-frame-fade) ease;
}
/* Hidden, not removed: the frame keeps loading and keeps its size. No clicks reach a page
   the visitor cannot see. */
.rushd-frame[data-rushd-frame="loading"]>iframe,
.rushd-frame[data-rushd-frame="error"]>iframe{
  opacity:0;
  pointer-events:none;
}

/* The shimmer: the same background-position sweep as the design-components placeholders. */
.rushd-frame[data-rushd-frame]::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius:var(--rushd-frame-radius);
  background-color:var(--rushd-frame-bg);
  background-image:linear-gradient(100deg,transparent 40%,var(--rushd-frame-shine) 50%,transparent 60%);
  background-size:300% 100%;
  background-repeat:no-repeat;
  animation:rushd-frame-shimmer 1.6s ease-in-out infinite;
  pointer-events:none;
  transition:opacity var(--rushd-frame-fade) ease;
}
.rushd-frame[data-rushd-frame="loaded"]::before{
  opacity:0;
  visibility:hidden;
  animation-play-state:paused;
  transition:opacity var(--rushd-frame-fade) ease,visibility 0s linear var(--rushd-frame-fade);
}
/* Set by the script while the iframe is off screen or not displayed. */
.rushd-frame[data-rushd-frame-offscreen]::before{
  animation-play-state:paused;
}
/* On error the sweep stops. The panel stays, so the header over a navy frame stays readable. */
.rushd-frame[data-rushd-frame="error"]::before{
  animation:none;
  background-image:none;
}
@keyframes rushd-frame-shimmer{
  from{background-position:100% 0}
  to{background-position:0 0}
}

/* The message rushd-frame.js adds on error. The script sets its top and height to the part of the
   frame on screen at that moment, so it stays put if the app resizes the frame while it shows. */
.rushd-frame__error{
  position:absolute;
  top:0;
  left:0;
  right:0;
  height:100%;
  max-height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:12px;
  padding:24px;
  text-align:center;
  color:var(--rushd-frame-fg);
  font-size:14px;
  line-height:1.5;
}
.rushd-frame__error p{
  margin:0;
}
.rushd-frame__retry{
  display:inline-flex;
  align-items:center;
  height:36px;
  padding:0 16px;
  border:1px solid var(--rushd-frame-button-border);
  border-radius:10px;
  background:transparent;
  color:var(--rushd-frame-button-fg);
  font:inherit;
  font-weight:600;
  cursor:pointer;
  transition:border-color .15s ease;
}
.rushd-frame__retry:hover{
  border-color:var(--rushd-frame-button-hover);
}
.rushd-frame__retry:focus-visible{
  outline:2px solid var(--rushd-frame-button-hover);
  outline-offset:2px;
}

@media (prefers-reduced-motion: reduce){
  .rushd-frame[data-rushd-frame]::before{
    animation:none;
    background-image:none;
  }
  .rushd-frame[data-rushd-frame]>iframe,
  .rushd-frame[data-rushd-frame]::before,
  .rushd-frame__retry{
    transition:none;
  }
}
