/* Shared auth loading surface used by login and dashboard startup. */

/*
 * Keep the login and dashboard entry points on one geometry contract. Both
 * documents create their own loader during a full navigation, so every visual
 * dimension must come from this file rather than from page-specific styles.
 */
:root {
  --auth-loading-card-width: 360px;
  --auth-loading-card-min-height: 120px;
  --auth-loading-card-padding: 18px 22px;
  --auth-loading-card-gap: 14px;
  --auth-loading-spinner-size: 54px;
  --auth-loading-spinner-border: 4px;
  --auth-loading-spinner-duration: 0.85s;
}

/* Own the box model, including when login.css installs a universal reset.
 * Spinner size is its OUTER diameter, including the border. */
.auth-loading,
.auth-loading *,
.auth-loading *::before,
.auth-loading *::after {
  box-sizing: border-box;
}

.auth-loading[hidden] {
  display: none !important;
}

.auth-loading {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 0;
  padding: 20px;
  background: var(--app-shell-bg, #f4f6f8);
  gap: 0;
  text-align: center;
}

html.login-preparing-active .auth-loading,
html.preauth .auth-loading {
  display: flex;
}

.auth-loading:focus {
  outline: none;
}

.auth-loading__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--auth-loading-card-gap);
  justify-content: center;
  width: min(100%, var(--auth-loading-card-width));
  max-width: calc(100vw - 40px);
  min-height: var(--auth-loading-card-min-height);
  box-sizing: border-box;
  padding: var(--auth-loading-card-padding);
  background: var(--app-surface-bg, #ffffff);
  border: 1px solid var(--app-surface-border, rgba(148, 163, 184, 0.18));
  border-radius: 12px;
  box-shadow: var(--app-surface-shadow, 0 6px 16px rgba(15, 23, 42, 0.05));
  color: var(--app-color-primary, #365945);
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 500;
  text-align: center;
}

.auth-loading__card--error {
  gap: 12px;
}

.auth-loading__spinner {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  width: var(--auth-loading-spinner-size);
  height: var(--auth-loading-spinner-size);
  flex: 0 0 var(--auth-loading-spinner-size);
  border: var(--auth-loading-spinner-border) solid rgba(var(--app-color-primary-rgb, 54, 89, 69), 0.15);
  border-top-color: var(--app-color-primary, #365945);
  border-radius: 50%;
  animation: auth-loading-spin var(--auth-loading-spinner-duration) linear infinite;
  /* A negative delay lets the dashboard continue the login spinner phase
     across the full document navigation instead of visibly restarting it. */
  animation-delay: var(--auth-loading-animation-delay, 0ms);
}

.auth-loading__title {
  margin: 0;
  color: var(--app-color-primary, #365945);
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 500;
}

@keyframes auth-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-loading__spinner {
    animation: none;
    border-right-color: var(--app-color-primary, #365945);
  }
}
