/* ==========================================================================
   DAKSH CHAUHAN PORTFOLIO — CEREMONIAL EDITORIAL SITE LOADER
   Theme: Kononenko Architectural White (#FFFFFF Canvas, #111111 Ink)
   Signature Motif: Google Font 'Babylonica' Centerline Calligraphy Inscription
   Specular Sheen: Platinum-Pearl (Anti-Puncture for #FFFFFF Canvas)
   Governed by: PORTFOLIO_AUTHORITATIVE_LOCK.md
   ========================================================================== */

:root {
  --loader-canvas: #F4F4EC;
  --loader-ink: #141412;
  --loader-ink-graphite: #2D2C28;
  --loader-ink-silver: #706F69;
  --loader-ink-pearl: #D5D3CA;
  --loader-z-index: 99999;
}

@font-face {
  font-family: 'Babylonica';
  src: url('fonts/Babylonica-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

/* 1. Viewport Lock & Scrollbar Compensation */
html.site-loading,
body.site-loading {
  overflow: hidden !important;
  touch-action: none !important;
}

body.site-loading {
  padding-right: 0px !important;
}

/* 2. Fullscreen Scrim Curtain (Blank White Plane) */
.site-loader {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  z-index: var(--loader-z-index);
  background-color: var(--loader-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  user-select: none;
  touch-action: none;
  contain: strict;
  will-change: opacity, transform;
}

/* 3. Optical Centering Stage */
.loader-sig-stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transform-origin: 50% 50%;
  transform: rotate(-7deg) translateY(-4px);
  user-select: none;
  will-change: transform, opacity;
}

/* 4. Unified SVG Stage (Refined Intimate Scale) */
.loader-svg {
  width: clamp(180px, 18vw, 260px);
  height: auto;
  overflow: visible;
  display: block;
}

.pen-stroke {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
  will-change: stroke-dashoffset;
  transform: translateZ(0);
}

/* 5. Calligraphic Stroke Sequences (Deliberate Velvet Penmanship) */
/* Stroke 1: Capital 'D' (Clipped cleanly to x<=134) */
#p-d {
  stroke-dasharray: 470;
  stroke-dashoffset: 470;
  animation: writePenStroke 1.35s cubic-bezier(0.22, 1, 0.36, 1) forwards 0.30s;
}

/* Stroke 2: Cursive 'aksh' (Silky 720px continuous flow across a, k, s, h) */
#p-aksh {
  stroke-dasharray: 720;
  stroke-dashoffset: 720;
  animation: writePenStroke 2.10s cubic-bezier(0.22, 1, 0.36, 1) forwards 1.60s;
}

/* Stroke 3: Terminal Full Stop '.' */
#p-dot {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  animation: writePenStroke 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards 3.75s;
}

@keyframes writePenStroke {
  to {
    stroke-dashoffset: 0;
  }
}

/* 6. Signature Typography Surface (Rich Dark Solid Calligraphic Ink) */
.loader-svg text.sig-text {
  font-family: 'Babylonica', cursive;
  font-size: 112px;
  font-weight: 400;
  fill: var(--loader-ink);
  stroke: var(--loader-ink);
  stroke-width: 1.8px;
  paint-order: stroke fill;
  user-select: none;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: fill 0.35s ease, stroke 0.35s ease;
}

/* Unmasked vector poise: once inscription completes, remove mask filter for 100% solid opacity */
.site-loader.loader-poised #sig-group {
  mask: none !important;
  -webkit-mask: none !important;
}

/* 7. Specular Sheen State (Traverses Left-to-Right & Loops) */
.site-loader.loader-shimmering .loader-svg text.sig-text {
  fill: url(#sheen-gradient) !important;
  stroke: url(#sheen-gradient) !important;
}

/* 8. Exit State (Atmospheric Editorial Curtain Lift) */
.site-loader.loader-exiting {
  opacity: 0;
  pointer-events: none !important;
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-loader.loader-exiting .loader-sig-stage {
  transform: rotate(-7deg) translateY(-18px) scale(0.88);
  opacity: 0;
  transition:
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.45s ease-in;
}

/* 9. Hidden / Unmounted State */
.site-loader.loader-hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ==========================================================================
   ACCESSIBILITY: PREFERS-REDUCED-MOTION (WCAG 2.2 AAA)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  #p-d,
  #p-aksh,
  #p-dot {
    stroke-dashoffset: 0 !important;
    animation: none !important;
  }
  .loader-svg text.sig-text {
    fill: var(--loader-ink) !important;
    stroke: var(--loader-ink) !important;
  }
  .site-loader.loader-exiting {
    transition: opacity 0.25s linear !important;
  }
  .site-loader.loader-exiting .loader-sig-stage {
    transform: rotate(-7deg) translateY(-4px) !important;
    transition: opacity 0.2s linear !important;
  }
}
