/* =============================================================================
   IEA loader: the company website's preloader (imperialeastafrica.tz, the
   theme's .pxl-loader), shared by every screen of the system. Same circle,
   1px ring, spinning arc (1.2 s), logo and 0.6 s fade as the website.

   Load in <head>, after the page's own stylesheet:
     <link rel="stylesheet" href="assets/loader/loader.css">
     <script src="assets/loader/loader.js"></script>
   Behaviour and the JavaScript API are described in loader.js.
   Every class starts with iea-loader.
   ========================================================================== */

/* Until the loader element exists, a plain cover so nothing flashes: white, or the dark page (below). */
html.iea-loading::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 999998; background: #fff;
}

.iea-loader {
  --iea-loader-size: 120px;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 999999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background-color: #fff;
  transition: opacity .6s cubic-bezier(.645, .045, .355, 1), visibility .6s cubic-bezier(.645, .045, .355, 1);
}
.iea-loader.is-loaded { opacity: 0; visibility: hidden; }
/* Work in progress over the whole screen: the page stays faintly visible behind. */
.iea-loader.is-overlay { background-color: rgba(255, 255, 255, .92); }
/* Work in progress inside one box (a list, a panel, a preview) */
.iea-loader.is-inline {
  --iea-loader-size: 72px;
  position: absolute; z-index: 20; gap: 12px; border-radius: inherit;
  background-color: rgba(255, 255, 255, .88);
}
.iea-loader-host { position: relative; }

.iea-loader-circle {
  position: relative; flex: none; width: var(--iea-loader-size); height: var(--iea-loader-size);
  border-radius: 100%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
}
/* A quarter-width slice of a ring shaded dark-to-clear, turning about the centre */
.iea-loader-line-mask {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--iea-loader-size) / 4); height: var(--iea-loader-size);
  margin-left: calc(var(--iea-loader-size) / -2); margin-top: calc(var(--iea-loader-size) / -2);
  overflow: hidden; transform-origin: calc(var(--iea-loader-size) / 2) calc(var(--iea-loader-size) / 2);
  animation: iea-loader-spin 1.2s infinite linear;
}
.iea-loader-line {
  position: relative; width: var(--iea-loader-size); height: var(--iea-loader-size); border-radius: 50%;
  background-color: transparent; background-image: linear-gradient(to bottom, rgba(0, 0, 0, .44), rgba(0, 0, 0, 0));
}
.iea-loader-line::before {
  content: ""; position: absolute; top: 1px; left: 1px; right: 1px; bottom: 1px; z-index: 1;
  background-color: #fff; border-radius: inherit;
}
.iea-loader-logo {
  position: absolute; top: 50%; left: 0; right: 0; z-index: 2; transform: translateY(-50%);
  display: flex; justify-content: center;
}
.iea-loader-logo img { display: block; height: calc(var(--iea-loader-size) * .375); width: auto; }

.iea-loader-label {
  margin: 0; max-width: 280px; text-align: center;
  font: 500 13px/1.4 "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif; color: #45516A;
}
.iea-loader-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Dark mode, on every screen that loads this file: the sign-in pages, both frames and the error pages.
   Each sets data-theme on <html> in <head>, before the first paint, from the theme switch's saved choice
   (localStorage "pm-theme") or else the system setting, so the cover above, the loader that shows while
   the next page is fetched (after Log in, say) and the one that opens it are all dark from the start.
   The colours are the frames' dark page and card (pm.css --bg and --surface; md-dark.css --page and
   --card hold the same values), written out because the two frames name them differently. */
html[data-theme="dark"].iea-loading::before { background: #0a1222; }
html[data-theme="dark"] .iea-loader { background-color: #0a1222; }
html[data-theme="dark"] .iea-loader.is-overlay { background-color: rgba(10, 18, 34, .92); }
html[data-theme="dark"] .iea-loader.is-inline { background-color: rgba(18, 29, 49, .88); }
html[data-theme="dark"] .iea-loader-circle { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
html[data-theme="dark"] .iea-loader-line { background-image: linear-gradient(to bottom, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0)); }
html[data-theme="dark"] .iea-loader-line::before { background-color: #0a1222; }
html[data-theme="dark"] .iea-loader.is-inline .iea-loader-line::before { background-color: #121d31; }
/* The mark is navy on nothing, which the dark page swallows: it turns white, like the logo. */
html[data-theme="dark"] .iea-loader-logo img { filter: brightness(0) invert(1); }
html[data-theme="dark"] .iea-loader-label { color: #b7c2d4; }

@keyframes iea-loader-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
/* Slower for people who ask for less motion (md.css stops it altogether). */
@media (prefers-reduced-motion: reduce) {
  .iea-loader-line-mask { animation-duration: 3s; }
}
@media print {
  html.iea-loading::before, .iea-loader { display: none !important; }
}
