/*
 * EEIS loading experience
 * Loaded after the shared rebrand so legacy loader rules cannot leak through.
 * This file is presentation-only: screen IDs, spinner classes, and loader
 * visibility are still controlled by the existing application code.
 */

@keyframes eeis-loader-spin {
  to { transform: rotate(360deg); }
}

@keyframes eeis-loader-spin-reverse {
  to { transform: rotate(-360deg); }
}

@keyframes eeis-loader-pulse {
  0%, 100% { opacity: .38; transform: scale(.76); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes eeis-loader-progress {
  0% { transform: translateX(-125%) scaleX(.55); }
  50% { transform: translateX(38%) scaleX(1); }
  100% { transform: translateX(225%) scaleX(.55); }
}

/* App startup ------------------------------------------------------------ */
#screen-splash {
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    max(26px, env(safe-area-inset-top, 0px))
    max(22px, env(safe-area-inset-right, 0px))
    max(34px, env(safe-area-inset-bottom, 0px))
    max(22px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  color: var(--ink, #344f67);
  background:
    radial-gradient(1000px 600px at 15% 15%, rgba(255, 107, 87, .16), transparent 60%),
    radial-gradient(900px 700px at 85% 85%, rgba(22, 50, 79, .18), transparent 60%),
    radial-gradient(600px 500px at 50% 50%, rgba(255, 255, 255, .9), transparent 80%),
    linear-gradient(145deg, #f0f4f9 0%, #e5edf5 55%, #dae5f0 100%);
}

#screen-splash::before,
#screen-splash::after {
  content: '';
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
}

#screen-splash::before {
  width: min(65vw, 780px);
  height: min(65vw, 780px);
  top: -30%;
  right: -20%;
  background: radial-gradient(circle, rgba(255, 255, 255, .7), rgba(255, 255, 255, 0));
  filter: blur(40px);
}

#screen-splash::after {
  width: min(50vw, 600px);
  height: min(50vw, 600px);
  bottom: -25%;
  left: -18%;
  background: radial-gradient(circle, rgba(215, 228, 240, .6), rgba(215, 228, 240, 0));
  filter: blur(50px);
}

#screen-splash > .splash-center,
#screen-splash > .splash-brand {
  position: relative;
  z-index: 1;
}

.splash-orb {
  display: block;
  position: absolute;
  z-index: 0;
  border: 0;
  border-radius: 50%;
  opacity: .7;
  filter: blur(30px);
  pointer-events: none;
}

.splash-orb-1 {
  width: 140px;
  height: 140px;
  top: 15%;
  left: 10%;
  background: rgba(255, 107, 87, .25);
}

.splash-orb-2 {
  width: 180px;
  height: 180px;
  top: 60%;
  right: 10%;
  background: rgba(22, 50, 79, .20);
}

.splash-orb-3 {
  width: 100px;
  height: 100px;
  bottom: 15%;
  left: 20%;
  background: rgba(255, 255, 255, .8);
}

.splash-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 440px);
  min-width: 0;
  padding: clamp(32px, 6vw, 46px) clamp(24px, 5.5vw, 44px);
  gap: 22px;
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 36px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 28px 64px rgba(22, 50, 79, .15), inset 0 1px 0 rgba(255, 255, 255, .9);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  transition: transform .2s ease;
}

.splash-eyebrow {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 107, 87, .08);
  border: 1px solid rgba(255, 107, 87, .15);
  color: var(--coral, #ff6b57);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
}

.splash-eyebrow-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral, #ff6b57);
  box-shadow: 0 0 0 4px rgba(255, 107, 87, .2);
}

.splash-ring-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
}

.splash-ring {
  position: absolute;
  border-radius: 50%;
}

.splash-ring-1 {
  inset: 0;
  border: 1px solid rgba(22, 50, 79, .12);
  background: radial-gradient(circle at center, rgba(255, 255, 255, .7) 0 55%, transparent 56%);
}

.splash-ring-2 {
  inset: 6px;
  border: 2.5px solid transparent;
  border-top-color: var(--coral, #ff6b57);
  border-right-color: var(--navy, #16324f);
  border-bottom-color: rgba(255, 107, 87, .3);
  opacity: 1;
  animation: eeis-loader-spin 2.2s cubic-bezier(.5, 0, .5, 1) infinite;
}

.splash-logo-wrap {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 106px;
  height: 106px;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 30px;
  background: linear-gradient(145deg, #ffffff, #f0f5fa);
  box-shadow: 0 16px 32px rgba(22, 50, 79, .16), inset 0 1px 0 rgba(255, 255, 255, .9);
}

.splash-logo-wrap::before { display: none; }

.splash-logo-img {
  width: 82px;
  height: 82px;
  border-radius: 20px;
  object-fit: contain;
}

.splash-texts {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 6px;
  text-align: center;
}

.splash-company {
  color: var(--navy-dark, #0f243a);
  font-size: clamp(26px, 6.5vw, 32px);
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1.1;
}

.splash-tagline {
  max-width: 320px;
  margin-inline: auto;
  color: var(--ink-soft, #5b7185);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
}

.app-version-label {
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(22, 50, 79, .06);
  color: var(--ink-muted, #7e94a7);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.splash-status {
  width: min(100%, 290px);
  display: grid;
  gap: 10px;
  margin-top: 4px;
  color: var(--ink-soft, #5b7185);
  font-size: 11.5px;
  font-weight: 700;
}

.splash-progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 50, 79, .08);
}

.splash-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral, #ff6b57), #ffa396 60%, var(--navy, #16324f));
  animation: eeis-loader-progress 1.5s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(255, 107, 87, .4);
}

.splash-status-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.splash-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.splash-dot {
  width: 6px;
  height: 6px;
  margin: 0;
  border-radius: 50%;
  background: var(--coral, #ff6b57);
  animation: eeis-loader-pulse 1.1s ease-in-out infinite;
}

.splash-dot:first-child { background: var(--coral, #ff6b57); }
.splash-dot:nth-child(2) { animation-delay: .15s; }
.splash-dot:nth-child(3) { animation-delay: .30s; }

.splash-brand {
  position: absolute;
  right: 0;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  left: 0;
  color: var(--ink-muted, #7e94a7);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.splash-brand span {
  margin-inline-end: 4px;
  color: var(--navy, #16324f);
  font-weight: 700;
}
  font-weight: 600;
}

/* Offline safe-screen ----------------------------------------------------- */
@keyframes eeis-offline-pulse {
  0%, 100% { opacity: .38; transform: scale(.76); }
  50% { opacity: 1; transform: scale(1); }
}

.offline-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  padding:
    max(26px, env(safe-area-inset-top, 0px))
    max(22px, env(safe-area-inset-right, 0px))
    max(34px, env(safe-area-inset-bottom, 0px))
    max(22px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  color: var(--ink, #344f67);
  background:
    radial-gradient(circle at 0% 0%, rgba(255,255,255,.94) 0 18%, transparent 44%),
    radial-gradient(circle at 100% 100%, rgba(202,221,237,.7) 0 14%, transparent 42%),
    linear-gradient(135deg, #eef4fa 0%, #e4eef7 52%, #dce8f3 100%);
}

.offline-overlay.hidden { display: none; }

.offline-orb {
  display: block;
  position: absolute;
  z-index: 0;
  border-radius: 50%;
}

.offline-orb-1 { width: 26px; height: 26px; top: 19%; left: 14%; background: rgba(255,107,87,.58); }
.offline-orb-2 { width: 14px; height: 14px; top: 31%; right: 18%; background: rgba(66,100,130,.48); }
.offline-orb-3 { width: 20px; height: 20px; bottom: 20%; right: 25%; background: rgba(255,255,255,.72); border: 1px solid rgba(66,100,130,.08); }

.offline-center {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(28px, 5.2vw, 42px) clamp(22px, 5vw, 40px);
  gap: 16px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.88);
  border-radius: 32px;
  background: rgba(255,255,255,.84);
  box-shadow: 0 24px 56px rgba(52,79,103,.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.offline-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--blue-gray, #718ba3);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1;
  text-transform: uppercase;
}

.offline-eyebrow-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--clr-danger, #ef4444);
  box-shadow: 0 0 0 5px rgba(239,68,68,.14);
}

.offline-ring-wrap {
  position: relative;
  width: 116px;
  height: 116px;
}

.offline-ring-1 {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(239,68,68,.28);
}

.offline-icon-wrap {
  position: absolute;
  inset: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: var(--clr-danger, #ef4444);
  box-shadow: 0 13px 26px rgba(52,79,103,.16);
}

.offline-icon-wrap svg { width: 40px; height: 40px; }

.offline-texts { display: flex; flex-direction: column; gap: 6px; }

.offline-title {
  color: var(--navy-dark, #35536f);
  font-size: clamp(20px, 5vw, 24px);
  font-weight: 800;
  letter-spacing: .02em;
}

.offline-tagline {
  max-width: 300px;
  margin-inline: auto;
  color: var(--ink-soft, #718293);
  font-size: 13px;
  line-height: 1.6;
}

.offline-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft, #718293);
  font-size: 12px;
  font-weight: 700;
}

.offline-dots { display: inline-flex; align-items: center; gap: 4px; }

.offline-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--clr-danger, #ef4444);
  animation: eeis-offline-pulse 1.1s ease-in-out infinite;
}

.offline-dot:nth-child(2) { animation-delay: .14s; }
.offline-dot:nth-child(3) { animation-delay: .28s; }

.offline-retry-btn {
  margin-top: 4px;
}

.offline-brand {
  position: absolute;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  left: 0;
  z-index: 1;
  color: var(--ink-muted, #9aa9b6);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-align: center;
}

.offline-brand span {
  margin-inline-end: 4px;
  color: var(--blue-gray, #718ba3);
  font-weight: 600;
}

/* Global API loader ------------------------------------------------------ */
.global-loader-overlay {
  z-index: 10020;
  align-items: center;
  justify-content: center;
  padding:
    max(22px, env(safe-area-inset-top, 0px))
    max(20px, env(safe-area-inset-right, 0px))
    max(22px, env(safe-area-inset-bottom, 0px))
    max(20px, env(safe-area-inset-left, 0px));
  background: rgba(233,241,248,.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.global-loader-overlay.show { display: flex; }

.global-loader-box {
  width: min(100%, 280px);
  padding: 26px 26px 24px;
  gap: 14px;
  border: 1px solid rgba(255,255,255,.94);
  border-radius: 24px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 22px 52px rgba(52,79,103,.18);
  text-align: center;
}

.global-loader-mark {
  position: relative;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
}

.global-loader-orbit {
  position: absolute;
  border: 1px solid rgba(66,100,130,.16);
  border-radius: 50%;
}

.global-loader-orbit--one {
  inset: 0;
  border-top-color: var(--coral, #ff6b57);
  animation: eeis-loader-spin 1.35s linear infinite;
}

.global-loader-orbit--two {
  inset: 7px;
  border-bottom-color: var(--navy, #426482);
  animation: eeis-loader-spin-reverse 1.05s linear infinite;
}

.global-loader-spinner {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--coral, #ff6b57);
  box-shadow: 0 0 0 6px rgba(255,107,87,.14);
  animation: eeis-loader-pulse 1.15s ease-in-out infinite;
}

.global-loader-copy {
  display: grid;
  gap: 3px;
}

.global-loader-copy strong {
  color: var(--navy-dark, #35536f);
  font-size: 14px;
  font-weight: 800;
}

.global-loader-message {
  color: var(--ink-soft, #718293);
  font-size: 12px;
  font-weight: 600;
}

/* Page and detail loading states ---------------------------------------- */
.pg-loading,
.loading-state {
  width: min(100%, 520px);
  min-height: 148px;
  margin-inline: auto;
  padding: 24px;
  border: 1px solid rgba(228,235,241,.92);
  border-radius: 20px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 10px 26px rgba(52,79,103,.055);
  color: var(--ink-soft, #718293);
  text-align: center;
}

.pg-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.loading-state {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pg-loading > span,
.loading-state > p {
  max-width: 34ch;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.spinner {
  position: relative;
  width: 34px;
  height: 34px;
  margin: 0;
  flex: 0 0 34px;
  border: 3px solid #dbe7f0;
  border-top-color: var(--coral, #ff6b57);
  border-right-color: rgba(255,107,87,.45);
  border-radius: 50%;
  animation: eeis-loader-spin .82s linear infinite;
}

.spinner::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid transparent;
  border-bottom-color: var(--navy, #426482);
  border-radius: 50%;
  animation: eeis-loader-spin-reverse 1.15s linear infinite;
}

@media (max-width: 480px) {
  #screen-splash {
    padding-inline: max(16px, env(safe-area-inset-left, 0px));
  }

  .splash-center {
    width: 100%;
    padding: 27px 20px;
    border-radius: 26px;
  }

  .splash-ring-wrap { width: 126px; height: 126px; }
  .splash-logo-wrap { width: 94px; height: 94px; border-radius: 27px; }
  .splash-logo-img { width: 74px; height: 74px; border-radius: 18px; }
  .splash-status { width: 100%; }

  .global-loader-box {
    width: min(100%, 290px);
    padding: 24px 20px 22px;
  }

  .pg-loading,
  .loading-state {
    min-height: 132px;
    padding: 20px 16px;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-ring-2,
  .splash-progress-bar,
  .splash-dot,
  .global-loader-orbit,
  .global-loader-spinner,
  .spinner,
  .spinner::after {
    animation-duration: 1ms;
    animation-iteration-count: 1;
  }
}

@media (prefers-contrast: more) {
  .splash-center,
  .global-loader-box,
  .pg-loading,
  .loading-state { border-color: var(--navy, #426482); }
}
