/* shared page chrome - bg animation, nav, footer, fade-in. linked last so it
   wins any cascade ties with a page's own inline styles */

.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.bg-animation .nebula {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.22) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(124, 58, 237, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 15% 30%, rgba(6, 182, 212, 0.23) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 70%, rgba(14, 165, 233, 0.2) 0%, transparent 45%);
    animation: nebulaDrift 90s ease-in-out infinite;
}

@keyframes nebulaDrift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(1%, -0.5%) rotate(0.3deg); }
    50% { transform: translate(0.5%, 0.5%) rotate(-0.2deg); }
    75% { transform: translate(-0.5%, -0.3%) rotate(0.1deg); }
}

/* two starfield layers, distant + brighter */
.bg-animation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(1px 1px at 20px 30px, rgba(99, 102, 241, 0.7), transparent),
        radial-gradient(1px 1px at 40px 70px, rgba(99, 102, 241, 0.6), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(168, 85, 247, 0.65), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(139, 92, 246, 0.6), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(6, 182, 212, 0.7), transparent);
    background-repeat: repeat;
    background-size: 200px 150px;
}

.bg-animation::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(1.5px 1.5px at 25% 15%, rgba(248, 250, 252, 0.9), transparent),
        radial-gradient(1px 1px at 75% 35%, rgba(167, 139, 250, 0.75), transparent),
        radial-gradient(1.5px 1.5px at 45% 65%, rgba(103, 232, 249, 0.8), transparent),
        radial-gradient(1px 1px at 85% 85%, rgba(248, 250, 252, 0.85), transparent),
        radial-gradient(1px 1px at 15% 90%, rgba(6, 182, 212, 0.75), transparent);
    background-repeat: repeat;
    background-size: 350px 350px;
}

.bg-animation .twinkle-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.95), transparent),
        radial-gradient(1px 1px at 30% 60%, rgba(255, 255, 255, 0.85), transparent),
        radial-gradient(1px 1px at 55% 35%, rgba(255, 255, 255, 0.9), transparent),
        radial-gradient(1px 1px at 70% 80%, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(1px 1px at 90% 15%, rgba(255, 255, 255, 0.85), transparent);
    background-size: 100% 100%;
    animation: twinkle 8s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.bg-parallax {
    position: absolute;
    inset: -24px;
}

.bg-animation .aurora {
    position: absolute;
    inset: -25%;
    background:
        radial-gradient(ellipse 55% 40% at 22% 28%, rgba(139, 92, 246, 0.22), transparent 60%),
        radial-gradient(ellipse 50% 45% at 78% 68%, rgba(6, 182, 212, 0.18), transparent 60%),
        radial-gradient(ellipse 55% 35% at 62% 18%, rgba(99, 102, 241, 0.20), transparent 55%),
        radial-gradient(ellipse 45% 40% at 40% 85%, rgba(14, 165, 233, 0.15), transparent 55%);
    filter: blur(45px);
    opacity: 0.8;
}

.shooting-stars {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.shooting-star {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 8px 1px rgba(255, 255, 255, 0.85);
    opacity: 0;
    animation: shoot var(--dur, 1.4s) linear forwards;
}

/* tail rotated by --rot so it lies along the actual flight path */
.shooting-star::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    width: 150px;
    height: 2px;
    transform: translateY(-50%);
    background: linear-gradient(to left, rgba(255, 255, 255, 0.85), transparent);
}

@keyframes shoot {
    0%   { opacity: 0; transform: translate(0, 0) rotate(var(--rot, 135deg)); }
    10%  { opacity: 1; }
    70%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx, -40vw), var(--dy, 40vw)) rotate(var(--rot, 135deg)); }
}

.bg-animation .galaxy {
    position: absolute;
    width: 700px;
    height: 700px;
    top: 5%;
    right: -10%;
    opacity: 0.6;
    animation: galaxyRotate 240s linear infinite;
}

.galaxy-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    background:
        radial-gradient(circle at 45% 45%,
            rgba(255, 255, 255, 0.95) 0%,
            rgba(255, 245, 230, 0.85) 5%,
            rgba(255, 220, 180, 0.7) 10%,
            rgba(200, 160, 255, 0.6) 18%,
            rgba(167, 139, 250, 0.5) 25%,
            rgba(139, 92, 246, 0.3) 35%,
            rgba(99, 102, 241, 0.15) 50%,
            transparent 70%);
    border-radius: 50%;
    filter: blur(3px);
    box-shadow:
        0 0 40px rgba(255, 255, 255, 0.4),
        0 0 80px rgba(167, 139, 250, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
}

.galaxy-arm {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
}

.galaxy-arm::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 80% 25% at 50% 50%,
            rgba(139, 92, 246, 0.4) 20%,
            rgba(139, 92, 246, 0.3) 30%,
            rgba(99, 102, 241, 0.25) 45%,
            rgba(99, 102, 241, 0.15) 60%,
            transparent 80%),
        radial-gradient(ellipse 70% 20% at 50% 50%,
            rgba(167, 139, 250, 0.35) 25%,
            rgba(139, 92, 246, 0.25) 40%,
            rgba(99, 102, 241, 0.15) 55%,
            transparent 75%);
    border-radius: 50%;
    filter: blur(20px);
    transform: rotate(30deg);
}

.galaxy-arm::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 75% 22% at 50% 50%,
            rgba(99, 102, 241, 0.35) 25%,
            rgba(99, 102, 241, 0.25) 40%,
            rgba(139, 92, 246, 0.18) 55%,
            transparent 75%),
        radial-gradient(ellipse 65% 18% at 50% 50%,
            rgba(124, 58, 237, 0.3) 30%,
            rgba(99, 102, 241, 0.2) 50%,
            transparent 70%);
    border-radius: 50%;
    filter: blur(18px);
    transform: rotate(-60deg);
}

.galaxy-dust {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    height: 95%;
    background:
        radial-gradient(ellipse at 70% 30%, rgba(6, 182, 212, 0.25) 0%, transparent 35%),
        radial-gradient(ellipse at 30% 70%, rgba(167, 139, 250, 0.22) 0%, transparent 30%),
        radial-gradient(ellipse at 60% 60%, rgba(255, 255, 255, 0.15) 0%, transparent 25%),
        radial-gradient(ellipse at 40% 40%, rgba(99, 102, 241, 0.18) 0%, transparent 28%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    border-radius: 50%;
    filter: blur(12px);
    animation: dustShimmer 30s ease-in-out infinite alternate;
}

@keyframes dustShimmer {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

@keyframes galaxyRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.bg-animation .galaxy-small {
    position: absolute;
    width: 350px;
    height: 350px;
    bottom: 10%;
    left: 2%;
    opacity: 0.5;
    animation: galaxyRotate 180s linear infinite reverse;
}

.galaxy-small .galaxy-core {
    width: 50px;
    height: 50px;
    background:
        radial-gradient(circle,
            rgba(255, 255, 255, 0.9) 0%,
            rgba(255, 235, 200, 0.75) 8%,
            rgba(200, 160, 255, 0.5) 20%,
            rgba(139, 92, 246, 0.3) 35%,
            transparent 60%);
    filter: blur(2px);
}

.galaxy-small .galaxy-arm::before,
.galaxy-small .galaxy-arm::after {
    filter: blur(12px);
}

.galaxy-small .galaxy-dust {
    filter: blur(8px);
    background:
        radial-gradient(ellipse at 65% 35%, rgba(6, 182, 212, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 35% 65%, rgba(167, 139, 250, 0.18) 0%, transparent 35%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.1) 0%, transparent 45%);
}

.asteroid-field {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0.4;
}

.asteroid {
    position: absolute;
    border-radius: 40% 60% 50% 70% / 60% 40% 70% 50%;
    background:
        radial-gradient(ellipse at 30% 25%,
            rgba(100, 116, 139, 0.8) 0%,
            rgba(71, 85, 105, 0.6) 40%,
            rgba(51, 65, 85, 0.4) 100%);
    box-shadow:
        inset -2px -2px 4px rgba(0, 0, 0, 0.3),
        inset 1px 1px 2px rgba(148, 163, 184, 0.2);
    opacity: 0.6;
}

.asteroid:nth-child(1) { width: 18px; height: 15px; top: 15%; left: 8%; animation: asteroidDrift1 180s linear infinite; }
.asteroid:nth-child(2) { width: 12px; height: 10px; top: 35%; left: 25%; animation: asteroidDrift2 220s linear infinite; animation-delay: -40s; }
.asteroid:nth-child(3) { width: 22px; height: 18px; top: 55%; left: 70%; animation: asteroidDrift3 200s linear infinite; animation-delay: -80s; }
.asteroid:nth-child(4) { width: 10px; height: 8px; top: 75%; left: 15%; animation: asteroidDrift1 240s linear infinite; animation-delay: -120s; }
.asteroid:nth-child(5) { width: 16px; height: 14px; top: 25%; left: 85%; animation: asteroidDrift2 190s linear infinite; animation-delay: -60s; }
.asteroid:nth-child(6) { width: 14px; height: 12px; top: 65%; left: 45%; animation: asteroidDrift3 210s linear infinite; animation-delay: -100s; }
.asteroid:nth-child(7) { width: 20px; height: 16px; top: 10%; left: 55%; animation: asteroidDrift1 195s linear infinite; animation-delay: -140s; }
.asteroid:nth-child(8) { width: 11px; height: 9px; top: 85%; left: 80%; animation: asteroidDrift2 235s linear infinite; animation-delay: -70s; }

@keyframes asteroidDrift1 {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 0.6; }
    25% { opacity: 0.5; }
    50% { transform: translate(-30px, 40px) rotate(180deg); opacity: 0.7; }
    75% { opacity: 0.4; }
    100% { transform: translate(0, 0) rotate(360deg); opacity: 0.6; }
}

@keyframes asteroidDrift2 {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 0.5; }
    33% { opacity: 0.7; }
    66% { transform: translate(40px, -30px) rotate(-180deg); opacity: 0.4; }
    100% { transform: translate(0, 0) rotate(-360deg); opacity: 0.5; }
}

@keyframes asteroidDrift3 {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 0.6; }
    40% { opacity: 0.5; transform: translate(-20px, -35px) rotate(144deg) scale(0.95); }
    80% { opacity: 0.7; transform: translate(25px, 30px) rotate(288deg) scale(1.05); }
    100% { transform: translate(0, 0) rotate(360deg) scale(1); opacity: 0.6; }
}

header {
    padding: 2rem 0;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #8b5cf6;
    text-decoration: none;
    font-family: monospace;
}

.logo::before {
    content: "$ ";
    color: #6366f1;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
    color: #8b5cf6;
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
}

footer {
    text-align: center;
    padding: 3rem 0;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    margin-top: 4rem;
    color: #64748b;
    position: relative;
    overflow: hidden;
}

.footer-content {
    position: relative;
    z-index: 2;
}

.footer-text {
    position: relative;
    display: inline-block;
}

.footer-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #8b5cf6;
    border-radius: 50%;
    opacity: 0;
    animation: floatUp 4s ease-in-out infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 0.5s; }
.particle:nth-child(3) { left: 30%; animation-delay: 1s; }
.particle:nth-child(4) { left: 50%; animation-delay: 1.5s; }
.particle:nth-child(5) { left: 70%; animation-delay: 2s; }
.particle:nth-child(6) { left: 80%; animation-delay: 2.5s; }
.particle:nth-child(7) { left: 90%; animation-delay: 3s; }

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0);
    }
    20% {
        opacity: 1;
        transform: translateY(30px) scale(1);
    }
    80% {
        opacity: 1;
        transform: translateY(-30px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0);
    }
}

.heart-emoji {
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
    color: #ef4444;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.2); }
    28% { transform: scale(1); }
    42% { transform: scale(1.2); }
    70% { transform: scale(1); }
}

.coffee-emoji {
    display: inline-block;
    animation: steam 2s ease-in-out infinite;
    margin-left: 0.2rem;
    position: relative;
}

.coffee-emoji::after {
    content: '💨';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6em;
    opacity: 0;
    animation: steamRise 3s ease-in-out infinite;
}

@keyframes steam {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes steamRise {
    0% { opacity: 0; transform: translateX(-50%) translateY(0); }
    30% { opacity: 0.7; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

.footer-text:hover {
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
    transition: text-shadow 0.3s ease;
}

.fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .nebula,
    .twinkle-stars,
    .galaxy,
    .galaxy-small,
    .asteroid-field,
    .asteroid,
    .aurora,
    .shooting-star,
    .bg-parallax {
        animation: none !important;
    }

    .shooting-stars {
        display: none;
    }

    .bg-parallax {
        transform: none !important;
    }

    .galaxy,
    .galaxy-small {
        opacity: 0.4;
    }

    .twinkle-stars {
        opacity: 0.7;
    }
}

.skip-link {
    position: fixed;
    top: -5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20001;
    background: #8b5cf6;
    color: #fff;
    padding: 1rem 2.25rem;
    border-radius: 0 0 12px 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: none;
}

/* zero-specificity fallback via :where() - project.css's own themed
   a:focus-visible still wins wherever it's loaded */
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25);
}

@media (prefers-contrast: more) {
    body {
        color: #f8fafc;
    }

    .card, .cluster-card, .planetary-card, .service-card, .node-card,
    .overview-card, .spec-list, .timeline-item, .rack-slot, .glass-card,
    .book-card, .vinyl-card, .detail-section, .callout, .intro-card,
    .profile-card {
        border-width: 2px !important;
    }

    a {
        text-decoration: underline;
    }
}

/* print: drop the cosmic chrome, and un-clip the gradient headings
   (their text-fill is transparent, prints blank otherwise) */
@media print {
    .bg-animation,
    .cursor-trail,
    .skip-link,
    .nav-links,
    .shooting-stars,
    .asteroid-field,
    .footer-particles,
    .heart-emoji,
    .coffee-emoji {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #111 !important;
    }

    .container {
        max-width: 100% !important;
    }

    a {
        color: #4c1d95 !important;
    }

    .page-title,
    .intro-card h1,
    .modal-title,
    .modal-section h3,
    .hero-title,
    .constellation-section .section-title,
    .error-code,
    .detail-title {
        background: none !important;
        -webkit-text-fill-color: #111 !important;
        color: #111 !important;
        text-shadow: none !important;
        animation: none !important;
    }

    .card, .cluster-card, .planetary-card, .service-card, .node-card,
    .overview-card, .glass-card, .book-card, .vinyl-card, .detail-section,
    .spec-list, .callout, .rack-elevation, .intro-card, .profile-card {
        background: #fff !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        color: #111 !important;
    }

    .card *, .cluster-card *, .planetary-card *, .service-card *,
    .node-card *, .overview-card *, .detail-section *, .intro-card * {
        color: #222 !important;
    }

    footer {
        border-top: 1px solid #ccc !important;
    }
}

/* Ctrl/Cmd+K command palette */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 10, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 1.5rem 1.5rem;
    z-index: 20000;
}

.cmdk-overlay[hidden] {
    display: none;
}

.cmdk-box {
    background: rgba(20, 20, 28, 0.98);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(139, 92, 246, 0.1);
    overflow: hidden;
}

.cmdk-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    padding: 1.1rem 1.4rem;
    color: #f1f5f9;
    font: inherit;
    font-size: 1rem;
}

.cmdk-input:focus {
    outline: none;
}

.cmdk-list {
    max-height: 40vh;
    overflow-y: auto;
    padding: 0.4rem;
}

.cmdk-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.92rem;
}

.cmdk-item.active {
    background: rgba(139, 92, 246, 0.18);
    color: #fff;
}

.cmdk-kicker {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    flex-shrink: 0;
}

.cmdk-item.active .cmdk-kicker {
    color: #a78bfa;
}

.cmdk-empty {
    padding: 1.5rem;
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
}

.cmdk-hint {
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    padding: 0.6rem 1.1rem;
    font-size: 0.72rem;
    color: #64748b;
    text-align: right;
}

@media (max-width: 640px) {
    .cmdk-overlay {
        padding: 6vh 1rem 1rem;
    }
}
