/* ==========================================================================
   USMLE-Rx - Loading Screen
   Design: "Study Cards" - Floating flash cards & study tiles
   Representing the tools students use: tests, decks, notes, and videos
   ========================================================================== */

/* Core Container */
.application-loading {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(
    145deg,
    #011730 0%,
    #042d5a 30%,
    #055aa6 70%,
    #0968b8 100%
  );
  font-family: 'Roboto Flex', sans-serif;
  z-index: 10000;
  overflow: hidden;
  box-sizing: border-box;
}

/* ==========================================================================
   Atmospheric Background
   ========================================================================== */

.loading-atmosphere {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Subtle grid pattern for depth */
.loading-grid-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* Ambient gradient orbs for depth */
.loading-atmosphere::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  top: -200px;
  right: -150px;
  background: radial-gradient(circle, rgba(242, 106, 36, 0.12) 0%, transparent 60%);
  border-radius: 50%;
}

.loading-atmosphere::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  bottom: -150px;
  left: -100px;
  background: radial-gradient(circle, rgba(5, 90, 166, 0.2) 0%, transparent 60%);
  border-radius: 50%;
}

/* ==========================================================================
   Content Container
   ========================================================================== */

.loading-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Logo
   ========================================================================== */

.loading-logo {
  height: 56px;
  margin-bottom: 32px;
  animation: logo-shimmer 3s ease-in-out infinite;
}

@keyframes logo-shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* ==========================================================================
   Card Assembly - Floating Study Cards
   ========================================================================== */

.card-assembly {
  position: relative;
  width: 160px;
  height: 130px;
  margin-bottom: 36px;
}

/* ==========================================================================
   Card Base Styles
   ========================================================================== */

.card {
  position: absolute;
  border-radius: 8px;
  will-change: transform;
}

/* ==========================================================================
   Individual Cards - Positioned & Styled
   Study cards are taller / more square than bricks,
   with pronounced rounded corners
   ========================================================================== */

/* Card 1 - Large Orange (Hero, center-left) — Test card */
.card-1 {
  width: 44px;
  height: 34px;
  left: 42px;
  top: 30px;
  background: linear-gradient(135deg, #f26a24 0%, #e85a14 100%);
  box-shadow:
    0 6px 20px rgba(242, 106, 36, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: rotate(-3deg);
  animation: float-gentle 4s ease-in-out infinite;
}

/* Card 2 - Medium Blue (right) — Deck card */
.card-2 {
  width: 38px;
  height: 48px;
  left: 96px;
  top: 22px;
  background: linear-gradient(135deg, #0968b8 0%, #055aa6 100%);
  box-shadow:
    0 5px 16px rgba(5, 90, 166, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transform: rotate(5deg);
  animation: float-gentle 4.5s ease-in-out infinite 0.5s;
}

/* Card 3 - Small Orange (top accent) — Note card */
.card-3 {
  width: 30px;
  height: 24px;
  left: 85px;
  top: 2px;
  background: linear-gradient(135deg, #ff8243 0%, #f26a24 100%);
  box-shadow:
    0 4px 12px rgba(242, 106, 36, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: rotate(8deg);
  animation: float-gentle 5s ease-in-out infinite 0.7s;
}

/* Card 4 - Medium Orange (left) — Flash card */
.card-4 {
  width: 36px;
  height: 44px;
  left: 8px;
  top: 18px;
  background: linear-gradient(135deg, #f57c3d 0%, #e55d10 100%);
  box-shadow:
    0 5px 16px rgba(242, 106, 36, 0.4),
    0 2px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: rotate(-6deg);
  animation: float-gentle 3.8s ease-in-out infinite 0.3s;
}

/* Card 5 - Large Blue (bottom-center) — Video card */
.card-5 {
  width: 50px;
  height: 32px;
  left: 50px;
  top: 80px;
  background: linear-gradient(135deg, #0c7fd4 0%, #0968b8 100%);
  box-shadow:
    0 5px 14px rgba(5, 90, 166, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: rotate(3deg);
  animation: float-gentle 4.2s ease-in-out infinite 0.9s;
}

/* Card 6 - Small Blue (bottom-right accent) — Quiz card */
.card-6 {
  width: 28px;
  height: 36px;
  left: 112px;
  top: 78px;
  background: linear-gradient(135deg, #055aa6 0%, #042d5a 100%);
  box-shadow:
    0 4px 10px rgba(5, 90, 166, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: rotate(-10deg);
  animation: float-gentle 4.8s ease-in-out infinite 0.2s;
}

/* Gentle floating animation */
@keyframes float-gentle {
  0%, 100% { transform: translateY(0) rotate(var(--base-rotation, 0deg)); }
  50% { transform: translateY(-4px) rotate(var(--base-rotation, 0deg)); }
}

/* Apply base rotations via custom properties */
.card-1 { --base-rotation: -3deg; }
.card-2 { --base-rotation: 5deg; }
.card-3 { --base-rotation: 8deg; }
.card-4 { --base-rotation: -6deg; }
.card-5 { --base-rotation: 3deg; }
.card-6 { --base-rotation: -10deg; }

/* ==========================================================================
   Glow Effect - Ambient Pulse
   ========================================================================== */

.card-glow {
  position: absolute;
  width: 120px;
  height: 80px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    ellipse at center,
    rgba(242, 106, 36, 0.3) 0%,
    rgba(5, 90, 166, 0.12) 50%,
    transparent 70%
  );
  filter: blur(12px);
  animation: glow-breathe 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glow-breathe {
  0%, 100% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* ==========================================================================
   Progress Indicator
   ========================================================================== */

.loading-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.progress-track {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(242, 106, 36, 0.4) 20%,
    #f26a24 50%,
    rgba(242, 106, 36, 0.4) 80%,
    transparent 100%
  );
  background-size: 200% 100%;
  border-radius: 2px;
  animation: progress-slide 1.5s ease-in-out infinite;
}

@keyframes progress-slide {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.loading-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media screen and (max-width: 480px) {
  .loading-logo {
    height: 44px;
    margin-bottom: 24px;
  }

  .card-assembly {
    transform: scale(0.8);
    margin-bottom: 24px;
  }

  .progress-track {
    width: 160px;
  }

  .loading-text {
    font-size: 12px;
  }
}

/* ==========================================================================
   Accessibility: Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .loading-logo,
  .card,
  .card-glow,
  .progress-fill {
    animation: none !important;
  }

  .card-glow {
    opacity: 0.7;
  }

  .progress-fill {
    background: linear-gradient(90deg, transparent, #f26a24, transparent);
    background-size: 100% 100%;
  }
}
