/* CareerPrep Hub — Animation & visual-effects library
   Lightweight, dependency-free, GPU-accelerated.
   Honors prefers-reduced-motion at the bottom. */

/* ─────────────────────────────────────────────
   Scroll reveal (driven by IntersectionObserver in animations.js)
   ───────────────────────────────────────────── */
[data-reveal] {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}
[data-reveal="left"]  { transform: translateX(-40px); }
[data-reveal="right"] { transform: translateX(40px); }
[data-reveal="zoom"]  { transform: scale(0.9); }
[data-reveal="fade"]  { transform: none; }
[data-reveal].is-visible {
    opacity: 1;
    transform: translate(0, 0) scale(1);
}
/* Stagger children */
[data-reveal-stagger] > * {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal-stagger].is-visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* ─────────────────────────────────────────────
   Scroll progress bar (top of page)
   ───────────────────────────────────────────── */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    z-index: 60;
    background: linear-gradient(90deg, #6366f1, #22d3ee, #a855f7);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.7);
    transition: width 0.1s linear;
}

/* ─────────────────────────────────────────────
   Page loader
   ───────────────────────────────────────────── */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b1020;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
}
.loader-logo-3d,
.login-logo-3d {
    filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.35));
}
.logo-img--3d,
.logo-link svg {
    filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
}
.logo-link:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.6);
    outline-offset: 4px;
    border-radius: 0.75rem;
}

/* ─────────────────────────────────────────────
   Aurora / animated gradient background
   ───────────────────────────────────────────── */
.aurora-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.aurora-bg::before,
.aurora-bg::after {
    content: "";
    position: absolute;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
    animation: aurora-float 18s ease-in-out infinite;
}
.aurora-bg::before {
    background: radial-gradient(circle, #6366f1, transparent 70%);
    top: -20%;
    left: -10%;
}
.aurora-bg::after {
    background: radial-gradient(circle, #22d3ee, transparent 70%);
    bottom: -20%;
    right: -10%;
    animation-delay: -9s;
}
@keyframes aurora-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(8%, 12%) scale(1.15); }
    66%      { transform: translate(-8%, -6%) scale(0.9); }
}

/* ─────────────────────────────────────────────
   Animated gradient text
   ───────────────────────────────────────────── */
.gradient-text {
    background: linear-gradient(90deg, #818cf8, #22d3ee, #c084fc, #818cf8);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient-pan 6s linear infinite;
}
@keyframes gradient-pan {
    to { background-position: 300% 0; }
}

/* ─────────────────────────────────────────────
   Glow / shimmer / float
   ───────────────────────────────────────────── */
.glow-ring {
    position: relative;
}
.glow-ring::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(99,102,241,0.6), rgba(34,211,238,0.6), transparent);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}
.glow-ring:hover::after { opacity: 1; }

.float-slow { animation: float-y 6s ease-in-out infinite; }
.float-med  { animation: float-y 4.5s ease-in-out infinite; }
@keyframes float-y {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

.shimmer {
    background: linear-gradient(110deg, rgba(255,255,255,0.04) 8%, rgba(255,255,255,0.12) 18%, rgba(255,255,255,0.04) 33%);
    background-size: 200% 100%;
    animation: shimmer-move 1.4s linear infinite;
}
@keyframes shimmer-move {
    to { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────
   3D tilt (JS adds CSS vars --rx / --ry)
   ───────────────────────────────────────────── */
.tilt {
    transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
    transition: transform 0.2s ease-out;
    transform-style: preserve-3d;
}
.tilt-inner { transform: translateZ(40px); }

/* ─────────────────────────────────────────────
   Magnetic / ripple buttons
   ───────────────────────────────────────────── */
.ripple { position: relative; overflow: hidden; }
.ripple span.ripple-dot {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(255, 255, 255, 0.4);
    animation: ripple-anim 0.6s ease-out;
    pointer-events: none;
}
@keyframes ripple-anim {
    to { transform: scale(3.2); opacity: 0; }
}

/* ─────────────────────────────────────────────
   Count-up stat highlight
   ───────────────────────────────────────────── */
.stat-number {
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, #fff, #c7d2fe);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ─────────────────────────────────────────────
   Marquee (trusted-by / logos strip)
   ───────────────────────────────────────────── */
.marquee {
    display: flex;
    overflow: hidden;
    mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.marquee__track {
    display: flex;
    gap: 3rem;
    flex-shrink: 0;
    min-width: 100%;
    animation: marquee-scroll 28s linear infinite;
}
.marquee:hover .marquee__track { animation-play-state: paused; }
@keyframes marquee-scroll {
    to { transform: translateX(-100%); }
}

/* ─────────────────────────────────────────────
   Card spotlight (cursor-follow glow)
   ───────────────────────────────────────────── */
.spotlight {
    position: relative;
    overflow: hidden;
}
.spotlight::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        420px circle at var(--mx, 50%) var(--my, 50%),
        rgba(99, 102, 241, 0.16),
        transparent 60%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.spotlight:hover::before { opacity: 1; }

/* ─────────────────────────────────────────────
   Back-to-top button
   ───────────────────────────────────────────── */
.back-to-top {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 50;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.45);
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    border: none;
    cursor: pointer;
}
.back-to-top.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.back-to-top:hover { transform: translateY(-3px) scale(1.05); }

/* ─────────────────────────────────────────────
   Confetti (quiz results)
   ───────────────────────────────────────────── */
.confetti-piece {
    position: fixed;
    top: -12px;
    width: 9px;
    height: 14px;
    z-index: 80;
    opacity: 0.9;
    animation: confetti-fall linear forwards;
    pointer-events: none;
}
@keyframes confetti-fall {
    to { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ─────────────────────────────────────────────
   Progress ring base
   ───────────────────────────────────────────── */
.ring-track { stroke: rgba(255, 255, 255, 0.08); }
.ring-value {
    stroke-linecap: round;
    transition: stroke-dashoffset 1.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─────────────────────────────────────────────
   Heatmap (streak calendar)
   ───────────────────────────────────────────── */
.heat-cell {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    transition: transform 0.15s ease;
}
.heat-cell:hover { transform: scale(1.3); }
.heat-1 { background: rgba(99, 102, 241, 0.35); }
.heat-2 { background: rgba(99, 102, 241, 0.55); }
.heat-3 { background: rgba(99, 102, 241, 0.78); }
.heat-4 { background: rgba(34, 211, 238, 0.9); }

/* ─────────────────────────────────────────────
   Entrance keyframes (utility)
   ───────────────────────────────────────────── */
@keyframes pop-in {
    0%   { opacity: 0; transform: scale(0.85); }
    60%  { transform: scale(1.04); }
    100% { opacity: 1; transform: scale(1); }
}
.animate-pop { animation: pop-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
    50%      { box-shadow: 0 0 0 14px rgba(99, 102, 241, 0); }
}
.glow-pulse { animation: glow-pulse 2.4s ease-out infinite; }

/* ─────────────────────────────────────────────
   Command palette (Cmd+K)
   ───────────────────────────────────────────── */
.command-palette-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.command-palette-panel {
    position: fixed;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 71;
    width: min(640px, calc(100vw - 2rem));
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(17, 24, 39, 0.98);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: pop-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.cmd-result:hover,
.cmd-result.cmd-active {
    background: rgba(99, 102, 241, 0.15);
}
.cmd-kbd {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    font-size: 11px;
    font-family: ui-monospace, monospace;
    color: rgba(148, 163, 184, 0.9);
}

/* ─────────────────────────────────────────────
   Level / XP badges (quiz)
   ───────────────────────────────────────────── */
.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
}
.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.xp-pop {
    animation: xp-float 1.2s ease-out forwards;
    pointer-events: none;
}
@keyframes xp-float {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(1.2); }
}

/* ─────────────────────────────────────────────
   Listing page hero
   ───────────────────────────────────────────── */
.listing-hero {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.listing-hero .aurora-bg { opacity: 0.35; }

@media (prefers-reduced-motion: reduce) {
    [data-reveal],
    [data-reveal-stagger] > * {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    .float-slow, .float-med, .gradient-text, .aurora-bg::before,
    .aurora-bg::after, .shimmer, .marquee__track, .glow-pulse {
        animation: none !important;
    }
}
