/* =========================================================
   Maths with Dino — Mathematical Preloader Styles
   Aesthetic: Blueprint blackboard with glowing math coordinate grid,
   rotating compass dial, floating formulas, & geometry ruler progress.
   ========================================================= */

/* Prevent scroll while loader is active */
body.dino-loading {
  overflow: hidden !important;
}

#dino-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #071726;
  background-image: 
    radial-gradient(circle at 50% 45%, rgba(19, 102, 159, 0.35) 0%, rgba(7, 23, 38, 0.95) 70%, #05121e 100%),
    linear-gradient(rgba(42, 169, 226, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 169, 226, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(42, 169, 226, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 169, 226, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 80px 80px, 80px 80px, 16px 16px, 16px 16px;
  background-position: center center, center center, center center, center center, center center;
  font-family: 'Noto Sans Sinhala', 'Gemunu Libre', system-ui, -apple-system, sans-serif;
  color: #F2FAFF;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.55s cubic-bezier(0.4, 0, 0.2, 1), 
              visibility 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform, filter;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#dino-loader.loader-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  filter: blur(8px);
  pointer-events: none;
}

/* Floating Mathematical Symbols in Background */
.loader-math-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.math-symbol {
  position: absolute;
  font-family: 'Gemunu Libre', 'Times New Roman', serif;
  font-weight: 700;
  color: rgba(42, 169, 226, 0.18);
  text-shadow: 0 0 12px rgba(42, 169, 226, 0.25);
  animation: floatMath 7s ease-in-out infinite alternate;
  user-select: none;
}

.sym-1  { top: 12%; left: 8%;   font-size: 2.8rem; animation-duration: 6s;   color: rgba(255, 201, 51, 0.22); }
.sym-2  { top: 22%; right: 12%; font-size: 3.2rem; animation-duration: 8.5s; animation-delay: -1.5s; }
.sym-3  { bottom: 18%; left: 10%; font-size: 2.6rem; animation-duration: 7s;   animation-delay: -3s; color: rgba(24, 173, 91, 0.22); }
.sym-4  { bottom: 22%; right: 9%; font-size: 3.6rem; animation-duration: 9s;   animation-delay: -2s; color: rgba(255, 201, 51, 0.25); }
.sym-5  { top: 48%; left: 4%;   font-size: 2.2rem; animation-duration: 5.5s; animation-delay: -4s; }
.sym-6  { top: 40%; right: 5%;  font-size: 2.5rem; animation-duration: 6.5s; animation-delay: -2.5s; color: rgba(24, 173, 91, 0.2); }
.sym-7  { top: 8%;  left: 45%;  font-size: 2rem;   animation-duration: 7.5s; animation-delay: -1s; }
.sym-8  { bottom: 8%; left: 48%; font-size: 2.4rem; animation-duration: 8s;   animation-delay: -5s; color: rgba(42, 169, 226, 0.22); }

@keyframes floatMath {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 0.35;
  }
  50% {
    transform: translateY(-18px) rotate(8deg) scale(1.08);
    opacity: 0.75;
  }
  100% {
    transform: translateY(12px) rotate(-6deg) scale(0.95);
    opacity: 0.4;
  }
}

/* Central Container */
.loader-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 440px;
  width: 90%;
  padding: 24px;
}

/* ==================== Centerpiece: The Maths Dial ==================== */
.dial-stage {
  position: relative;
  width: 190px;
  height: 190px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Outer Radial Pulse Glow */
.dial-glow {
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(42, 169, 226, 0.25) 0%, rgba(255, 201, 51, 0.12) 50%, transparent 72%);
  animation: pulseGlow 3s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes pulseGlow {
  0% { transform: scale(0.92); opacity: 0.5; }
  100% { transform: scale(1.18); opacity: 0.9; }
}

/* SVG Compass & Geometry Dial */
.dial-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Protractor Degrees Ring (Rotating slowly clockwise) */
.dial-ring-outer {
  transform-origin: center;
  animation: rotateClockwise 24s linear infinite;
}

/* Inner Geometric Guides (Rotating counter-clockwise) */
.dial-ring-inner {
  transform-origin: center;
  animation: rotateCounter 16s linear infinite;
}

@keyframes rotateClockwise {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotateCounter {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

/* Radar / Dial Sweep (Maths ඩයල්) */
.dial-sweep {
  transform-origin: center;
  animation: sweepRadar 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes sweepRadar {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Sine Wave path pulsating inside dial */
.dial-sine-wave {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: drawSineWave 2.8s linear infinite;
}

@keyframes drawSineWave {
  0% { stroke-dashoffset: 200; }
  50% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -200; }
}

/* Center Core / Pure Math Sigma Symbol */
.dial-core {
  position: relative;
  z-index: 3;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1978b5 0%, #0c3d61 65%, #072237 100%);
  border: 2px solid rgba(255, 201, 51, 0.85);
  box-shadow: 0 0 22px rgba(19, 102, 159, 0.75), 
              0 0 35px rgba(255, 201, 51, 0.3),
              inset 0 0 14px rgba(42, 169, 226, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: floatCore 4s ease-in-out infinite;
}

@keyframes floatCore {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.03); }
}

.dial-core-symbol {
  font-family: 'Gemunu Libre', 'Times New Roman', serif;
  font-size: 2.6rem;
  font-weight: 700;
  color: #FFC933;
  line-height: 1;
  text-shadow: 0 0 16px rgba(255, 201, 51, 0.75), 0 2px 5px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
  user-select: none;
}

/* ==================== Branding Typography ==================== */
.loader-brand {
  margin-bottom: 14px;
}

.loader-title {
  font-family: 'Gemunu Libre', 'Noto Sans Sinhala', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
  color: #FFFFFF;
  text-shadow: 0 2px 10px rgba(19, 102, 159, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.loader-title em {
  font-style: normal;
  color: #FFC933;
  text-shadow: 0 0 14px rgba(255, 201, 51, 0.6);
}

.loader-tagline-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(16, 128, 74, 0.25);
  border: 1px solid rgba(24, 173, 91, 0.5);
  color: #92f1b9;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.loader-tagline-badge .badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFC933;
  box-shadow: 0 0 8px #FFC933;
  animation: blinkDot 1.4s ease-in-out infinite;
}

@keyframes blinkDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ==================== Mathematical Formula Ticker ==================== */
.loader-formula-box {
  width: 100%;
  height: 38px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: rgba(13, 49, 80, 0.45);
  border: 1px solid rgba(42, 169, 226, 0.28);
  border-radius: 10px;
  padding: 0 14px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
}

.loader-formula {
  position: absolute;
  font-family: 'Gemunu Libre', 'Noto Sans Sinhala', monospace, sans-serif;
  font-size: 1.05rem;
  color: #EAF6FD;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.loader-formula.active {
  opacity: 1;
  transform: translateY(0);
}

.loader-formula .math-eq {
  color: #FFC933;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.loader-formula .math-lbl {
  color: #9EC9E2;
  font-size: 0.88rem;
  font-family: 'Noto Sans Sinhala', sans-serif;
}

/* ==================== Geometry Ruler Progress Bar ==================== */
.loader-ruler-wrap {
  width: 100%;
}

.ruler-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.88rem;
  margin-bottom: 7px;
  padding: 0 2px;
}

.ruler-status {
  color: #A9D3E8;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ruler-percent {
  font-family: 'Gemunu Libre', monospace, sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFC933;
  letter-spacing: 0.02em;
  text-shadow: 0 0 10px rgba(255, 201, 51, 0.4);
}

/* Ruler container with tick marks */
.ruler-track {
  position: relative;
  width: 100%;
  height: 20px;
  background: #092035;
  border-radius: 6px;
  border: 1px solid rgba(42, 169, 226, 0.35);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 1px 3px rgba(42, 169, 226, 0.15);
  padding: 3px;
  overflow: hidden;
}

/* Ruler millimeter & centimeter graduation marks overlay */
.ruler-ticks {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 3;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.35) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
  background-size: 10% 8px, 2% 4px;
  background-repeat: repeat-x;
  background-position: left top, left top;
}

/* Filled Progress Ribbon */
.ruler-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, #10804A 0%, #1675B0 50%, #FFC933 100%);
  box-shadow: 0 0 12px rgba(255, 201, 51, 0.6);
  position: relative;
  transition: width 0.22s ease-out;
  overflow: hidden;
}

/* Moving shimmer on progress bar */
.ruler-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
  animation: rulerShimmer 1.8s infinite;
  transform: translateX(-100%);
}

@keyframes rulerShimmer {
  100% { transform: translateX(100%); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .dial-stage {
    width: 160px;
    height: 160px;
    margin-bottom: 18px;
  }
  .dial-core {
    width: 68px;
    height: 68px;
  }
  .dial-core-symbol {
    font-size: 2.2rem;
  }
  .loader-title {
    font-size: 1.7rem;
  }
  .loader-tagline-badge {
    font-size: 0.8rem;
    padding: 3px 11px;
  }
  .loader-formula {
    font-size: 0.95rem;
  }
  .loader-formula .math-lbl {
    font-size: 0.8rem;
  }
  .math-symbol {
    opacity: 0.3 !important;
  }
}

/* Accessibility: Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .dial-ring-outer,
  .dial-ring-inner,
  .dial-sweep,
  .dial-sine-wave,
  .dial-glow,
  .dial-core,
  .math-symbol,
  .ruler-fill::after {
    animation: none !important;
  }
  .dial-ring-outer { transform: none !important; }
  .dial-ring-inner { transform: none !important; }
  .dial-sweep { display: none !important; }
  .ruler-fill { transition: width 0.1s linear !important; }
}
