/* ==========================================================================
   Page Intro Loader Styles
   Hardware-accelerated CSS animations matching Mark Ocampos brand identity.
   Fully fluid and responsive across mobile, tablet, desktop, & landscape.
   Fully compliant with Content Security Policy (style-src 'self').
   ========================================================================== */

/* Keyframe animations */
@keyframes pl-pop {
  0% {
    opacity: 0;
    transform: scale(0.65);
  }
  70% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pl-rise {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pl-fade {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes pl-bar {
  0% {
    width: 0;
  }
  100% {
    width: 100%;
  }
}

/* Fullscreen overlay container: support dynamic viewport units (dvh/dvw) */
#pl {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  width: 100vw;
  width: 100dvw;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

#pl.pl-out {
  pointer-events: none;
}

/* Curtains: top and bottom halves creating the dark slate backdrop (#202c27) */
.pl-ct,
.pl-cb {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 50.5%;
  background: #202c27;
  z-index: 1;
  transition: transform 0.75s cubic-bezier(0.76, 0, 0.24, 1);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.pl-ct {
  top: 0;
  transform: translateY(0);
}

.pl-cb {
  bottom: 0;
  transform: translateY(0);
}

/* Curtains wipe open on exit */
#pl.pl-out .pl-ct {
  transform: translateY(-100%);
}

#pl.pl-out .pl-cb {
  transform: translateY(100%);
}

/* Inner content stack: fluidly centered vertically and horizontally */
.pl-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(12px, 2.5vh, 22px);
  width: 100%;
  max-width: 520px;
  padding: 0 clamp(16px, 5vw, 32px);
  box-sizing: border-box;
  color: #f6f6ef;
  transition: opacity 0.35s ease;
  will-change: opacity;
}

#pl.pl-out .pl-inner {
  opacity: 0;
}

/* Brand block: stacked logo emblem + name + role */
.pl-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.8vh, 16px);
}

/* Logo mark SVG emblem */
.pl-mark {
  color: #d4dfc2;
  width: clamp(58px, 13vw, 84px);
  height: clamp(58px, 13vw, 84px);
  max-width: 84px;
  max-height: 84px;
  flex-shrink: 0;
  display: block;
  opacity: 0;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.35));
}

.pl-mark.on {
  animation: pl-pop 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

/* Wordmark typography: fluid scaling that stays on a single line */
.pl-wordmark {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(1.85rem, 7.5vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: #f6f6ef;
  white-space: nowrap;
  opacity: 0;
}

.pl-wordmark.on {
  animation: pl-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Role / subtitle */
.pl-role {
  font-family: 'Space Mono', monospace;
  font-size: clamp(0.58rem, 1.8vw, 0.68rem);
  letter-spacing: clamp(0.18em, 0.8vw, 0.28em);
  text-transform: uppercase;
  color: #c4d3b8;
  opacity: 0;
  margin-top: 4px;
}

.pl-role.on {
  animation: pl-fade 0.45s ease forwards;
}

/* Progress bar: fluid width proportional to viewport */
.pl-bar-wrap {
  width: clamp(130px, 36vw, 180px);
  height: 2px;
  background: rgba(246, 246, 239, 0.14);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}

.pl-bar {
  height: 100%;
  width: 0;
  background: #62a37e;
  border-radius: 2px;
}

.pl-bar.on {
  animation: pl-bar 1.8s cubic-bezier(0.3, 0, 0.2, 1) forwards;
}

/* Tagline words: fluid size and wrap handling */
.pl-tagline {
  display: flex;
  gap: 0.4em;
  flex-wrap: wrap;
  justify-content: center;
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: clamp(0.85rem, 2.5vw, 1.15rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: rgba(246, 246, 239, 0.5);
}

.pl-word {
  opacity: 0;
}

.pl-word.on {
  animation: pl-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pl-em {
  color: #d4dfc2;
  font-style: italic;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.25em;
  line-height: 0.9;
}

/* Meta label + counter */
.pl-meta {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 12px);
  font-family: 'Space Mono', monospace;
  font-size: clamp(0.56rem, 1.6vw, 0.64rem);
  letter-spacing: clamp(0.16em, 0.6vw, 0.22em);
  text-transform: uppercase;
  color: rgba(246, 246, 239, 0.35);
  opacity: 0;
}

.pl-meta.on {
  animation: pl-fade 0.4s ease forwards;
}

.pl-counter {
  font-variant-numeric: tabular-nums;
  color: #d4dfc2;
  font-weight: 700;
}

/* Ultra-compact landscape screens (e.g. mobile in landscape, height <= 480px) */
@media (max-height: 480px) {
  .pl-inner {
    gap: 7px;
    padding: 0 16px;
  }
  .pl-brand {
    gap: 4px;
  }
  .pl-mark {
    width: 44px;
    height: 44px;
  }
  .pl-wordmark {
    font-size: 1.6rem;
  }
  .pl-role {
    font-size: 0.5rem;
    margin-top: 1px;
    letter-spacing: 0.16em;
  }
  .pl-tagline {
    font-size: 0.8rem;
  }
  .pl-bar-wrap {
    width: 110px;
    margin-top: 1px;
  }
  .pl-meta {
    font-size: 0.5rem;
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  #pl {
    display: none !important;
  }
}
