/* ============================================================
   Page Transition & Loading Skeleton
   —————————————————————————————————
   Include BEFORE </head>:
     <link rel="stylesheet" href="/page-transition.css">
     <script src="/page-transition.js" defer></script>
   ============================================================ */

/* ----------------------------------------------------------
   1. Initial hidden state
   Body starts invisible. page-transition.js adds .page-ready
   to trigger the reveal. The 2.5 s JS timeout guarantees
   the page always becomes visible.
   ---------------------------------------------------------- */
body:not(.page-ready) {
  opacity: 0;
}

/* ----------------------------------------------------------
   2. Full-page reveal
   Smooth fade + subtle lift using only opacity & transform.
   ---------------------------------------------------------- */
body.page-ready {
  animation: pageReveal 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pageReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------------------------
   3. Staggered section cascade
   Each <section> gets a small extra delay so the page
   content "waterfalls" in from top to bottom.
   animation-delay is set inline by page-transition.js.
   ---------------------------------------------------------- */
.ptr-section {
  animation: sectionReveal 0.48s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes sectionReveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------------------------
   4. Loading progress bar
   A thin shimmer across the top of the viewport, visible
   only while the page is loading.
   ---------------------------------------------------------- */
.ptr-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 99999;
  background: linear-gradient(
    90deg,
    transparent 0%,
    #1E56B5 30%,
    #4DAEE5 50%,
    #1E56B5 70%,
    transparent 100%
  );
  background-size: 250% 100%;
  animation: barSlide 1.1s cubic-bezier(0.16, 1, 0.3, 1) infinite;
  pointer-events: none;
}

.ptr-bar.ptr-done {
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes barSlide {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ----------------------------------------------------------
   5. Skeleton shimmer utility
   Apply .skeleton to any element for a placeholder shimmer.
   Height/width should be set by the consumer.
   ---------------------------------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #f0f3fa;
  border-radius: 8px;
  color: transparent !important;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(30, 86, 181, 0.06) 40%,
    rgba(77, 174, 229, 0.09) 50%,
    rgba(30, 86, 181, 0.06) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton size variants */
.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: 4px;
}

.skeleton-heading {
  height: 1.8em;
  width: 60%;
  margin-bottom: 0.75em;
  border-radius: 6px;
}

.skeleton-card {
  height: 220px;
  border-radius: 16px;
}

.skeleton-circle {
  border-radius: 50%;
}

/* ----------------------------------------------------------
   6. Noscript fallback
   If JS is disabled, add this to HTML:
   <noscript><style>body{opacity:1!important}</style></noscript>
   ---------------------------------------------------------- */

/* ----------------------------------------------------------
   7. Reduced motion — respect user preference
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  body.page-ready,
  .ptr-section {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .ptr-bar {
    animation: none;
    background: #1E56B5;
  }

  .skeleton::after {
    animation: none;
  }
}
