/* ============================================================
   MONAP TECH v2 — Preloader Styles
   Theme: Dark, Glassmorphic, Spline TickTock-inspired
   ============================================================ */

/* --- Reset & Base --- */
@layer monap-reset {
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
}

:root {
  --bg: #08090d;
  --bg-elevated: #0e1016;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.12);
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.15);
  --cyan-glow: rgba(0, 229, 255, 0.35);
  --gold: #F5D67A;
  --gold-dim: rgba(245, 214, 122, 0.15);
  --text: #e8ecf1;
  --text-muted: rgba(255, 255, 255, 0.35);
  --font: 'Outfit', system-ui, -apple-system, sans-serif;
}

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
  overflow: hidden;
}

/* --- Preloader Container --- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0, 1);
}

.preloader.done {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

/* --- Background Video --- */
.bg-video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translateX(-50%) translateY(-50%);
  object-fit: cover;
  z-index: 0;
  opacity: 0.7; /* Dim the video slightly so text is legible */
  pointer-events: none;
}

/* --- Floating Glassmorphic Background Panels --- */
.bg-panels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.panel {
  position: absolute;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel-1 {
  width: 280px;
  height: 180px;
  top: 8%;
  left: -4%;
  transform: rotate(-12deg);
  animation: panelFloat 12s ease-in-out infinite;
}

.panel-2 {
  width: 200px;
  height: 320px;
  top: 15%;
  right: -2%;
  transform: rotate(8deg);
  animation: panelFloat 15s ease-in-out infinite 2s;
}

.panel-3 {
  width: 340px;
  height: 140px;
  bottom: 18%;
  left: 5%;
  transform: rotate(5deg);
  animation: panelFloat 18s ease-in-out infinite 4s;
}

.panel-4 {
  width: 160px;
  height: 160px;
  top: 35%;
  right: 12%;
  border-radius: 50%;
  animation: panelFloat 10s ease-in-out infinite 1s;
}

.panel-5 {
  width: 120px;
  height: 240px;
  bottom: 30%;
  right: 20%;
  transform: rotate(-6deg);
  animation: panelFloat 14s ease-in-out infinite 3s;
}

@keyframes panelFloat {
  0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); opacity: 0.4; }
  50% { transform: translateY(-20px) rotate(var(--r, 0deg)); opacity: 0.7; }
}

/* --- Grid Overlay --- */
.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 80px 80px;
  pointer-events: none;
  z-index: 2;
  mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, black 20%, transparent 70%);
}

/* --- Loader Content Stack --- */
.loader-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 10;
  height: 100vh; /* take full height for vertical centering */
  pointer-events: none;
}

/* --- MONAP Glass Typography --- */
.monap-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  position: relative;
  z-index: 20;
}

.monap-title .letter {
  font-family: var(--font);
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: transparent;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.1) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  display: inline-block;
  animation: letterReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  filter: drop-shadow(0 0 30px rgba(0, 229, 255, 0.08));
}

/* Glass refraction edge highlights */
.monap-title .letter::before {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.2);
  color: transparent;
  pointer-events: none;
}

/* Chromatic aberration layer */
.monap-title .letter::after {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: transparent;
  -webkit-text-stroke: 0.5px rgba(0, 229, 255, 0.2);
  transform: translate(2px, -1px);
  pointer-events: none;
  mix-blend-mode: screen;
}

.monap-title .letter:nth-child(1) { animation-delay: 0.1s; }
.monap-title .letter:nth-child(2) { animation-delay: 0.18s; }
.monap-title .letter:nth-child(3) { animation-delay: 0.26s; }
.monap-title .letter:nth-child(4) { animation-delay: 0.34s; }
.monap-title .letter:nth-child(5) { animation-delay: 0.42s; }

@keyframes letterReveal {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.8);
    filter: blur(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* --- Enter Button (Highly Refractive 3D Glass) --- */
.enter-btn {
  position: fixed;
  bottom: 40px;
  right: 40px;
  z-index: 10000;
  
  /* Thick refractive glass base */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(20px) brightness(1.1) contrast(1.2) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) brightness(1.1) contrast(1.2) saturate(1.5);
  
  /* Crystalline edges */
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-left: 1px solid rgba(255, 255, 255, 0.4);
  
  color: #ffffff;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 16px 36px;
  border-radius: 50px;
  cursor: pointer;
  
  /* Deep shadows for thickness and bright inner glow for refraction */
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.4), 
    inset 0 2px 5px rgba(255, 255, 255, 0.5),
    inset 0 -5px 15px rgba(255, 255, 255, 0.1),
    inset 0 0 20px rgba(0, 229, 255, 0.15); /* Subtle cyan refraction */
    
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out, box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

/* Shiny overlay */
.enter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  transform: skewX(-20deg);
  animation: shine 4s infinite;
  pointer-events: none;
}

@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}

.enter-btn:active {
  transform: scale(0.9) !important;
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 30px rgba(255, 235, 180, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.4);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .monap-title .letter {
    font-size: 3rem;
  }
  .panel-2, .panel-4, .panel-5 {
    display: none;
  }
}

@media (max-width: 480px) {
  .monap-title .letter {
    font-size: 2.4rem;
    gap: 2px;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .panel,
  .monap-title .letter {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
/* --- Loading Indicator (Bottom Left) --- */
.loading-indicator {
  position: absolute;
  bottom: 40px;
  left: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 50;
  transition: opacity 0.5s ease;
}

#loadingCounter {
  font-family: 'Instrument Serif', serif; /* or Kanit, whatever fits best. Let's stick to Kanit since it's cleaner */
  font-family: 'Kanit', sans-serif;
  font-weight: 300;
  font-size: 3rem;
  letter-spacing: 0.05em;
  color: #FFFFFF;
  margin: 0;
  padding: 0;
}
