/* Premium Visual Overrides */
:root {
    /* Obsidian Fusion Palette */
    --premium-bg: #010413;
    --premium-surface: #0a0f25;
    --premium-surface-glass: rgba(10, 15, 37, 0.75);
    --premium-border: rgba(99, 102, 241, 0.1);
    --premium-border-hover: rgba(139, 92, 246, 0.5);

    --premium-accent-1: #6366f1;
    --premium-accent-2: #a855f7;
    --premium-accent-3: #f472b6;
    --premium-accent-4: #22d3ee;
    --premium-accent-5: #34d399;

    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --text-muted: #64748b;
    --bg-glow: rgba(99, 102, 241, 0.1);
    --bg-pulse-to: #050a24;
    --selection-bg: rgba(99, 102, 241, 0.5);
}

[data-theme="light"] {
    --premium-bg: #f8fafc;
    --premium-surface: #ffffff;
    --premium-surface-glass: rgba(255, 255, 255, 0.8);
    --premium-border: rgba(99, 102, 241, 0.1);
    --premium-border-hover: rgba(99, 102, 241, 0.25);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --bg-pulse-to: #f1f5f9;
}

body .au-home,
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
    background: var(--premium-bg);
    color: var(--text-secondary);
    transition: background-color 0.4s ease, color 0.4s ease;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
    animation: 
        bgPulse 30s ease infinite,
        pageEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    -webkit-font-smoothing: antialiased;
}

@keyframes pageEntrance {
    /* Opacity only. A transform here — even the finished identity transform,
       held on body by fill:forwards — makes body the containing block for the
       fixed body::before/::after overlays, whose 200% height then adds
       ~1800px of phantom scroll past the footer on every page. */
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bgPulse {
    0% { background-color: var(--premium-bg); }
    50% { background-color: var(--bg-pulse-to); }
    100% { background-color: var(--premium-bg); }
}

body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E"),
        radial-gradient(var(--premium-border) 1px, transparent 1px);
    background-size: auto, 40px 40px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 9999;
}

::selection {
    background: var(--selection-bg);
    color: white;
}

h1,
h2,
h3,
h4,
h5,
h6,
.hero-title,
.brand-heading,
.story-section-heading h3 {
    /* No !important: this sheet loads after style.css so it wins by cascade
       order, while page-level class selectors (e.g. .hx-title) can override. */
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    font-weight: 800;
    text-wrap: balance;
}

.hero-title,
[data-theme="dark"] h2 {
    background: none;
    color: var(--text-primary);
    -webkit-text-fill-color: currentColor;
    animation: none;
}

[data-theme="light"] .hero-title,
[data-theme="light"] h2 {
    background: none;
    color: var(--text-primary);
    -webkit-text-fill-color: currentColor;
}

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

.section-kicker {
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--premium-accent-4);
    margin-bottom: 1rem;
    display: inline-block;
    background: none;
    -webkit-text-fill-color: currentColor;
    text-shadow: none;
}

h2 {
    -webkit-text-stroke: 0;
    paint-order: normal;
}

/* Background Gradients */
.au-home main {
    background:
        linear-gradient(115deg, rgba(99, 102, 241, 0.03) 0%, transparent 40%),
        linear-gradient(245deg, rgba(139, 92, 246, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 50% 100%, rgba(34, 211, 238, 0.03) 0%, transparent 40%),
        transparent !important;
    position: relative;
}

.au-home main::before {
    content: "";
    position: absolute;
    inset: 0;
    background: 
        repeating-linear-gradient(135deg, rgba(255,255,255,0.01) 0px, rgba(255,255,255,0.01) 1px, transparent 1px, transparent 100px);
    background-attachment: fixed;
    pointer-events: none;
    z-index: -1;
}

.home-hero {
    background:
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.12), transparent 45%),
        radial-gradient(circle at 20% 80%, rgba(14, 165, 233, 0.12), transparent 45%),
        var(--premium-bg) !important;
    border-bottom: 1px solid var(--premium-border) !important;
    position: relative;
    overflow: hidden;
}

.home-hero::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--bg-glow) 0%, transparent 60%);
    animation: rotateMesh 25s linear infinite;
    z-index: -1;
    pointer-events: none;
    opacity: 0.6;
    filter: blur(40px);
}

@keyframes rotateMesh {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.home-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%236366f1' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* Typography Enhancements */
/* Premium Buttons */

/* Premium Buttons */
.btn-solid {
    position: relative;
    background: linear-gradient(135deg, var(--premium-accent-1), var(--premium-accent-2)) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1) !important;
    border-radius: 999px !important;
    padding: 14px 32px !important;
    font-weight: 600 !important;
    overflow: hidden;
}

.btn-solid::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to bottom right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    pointer-events: none;
}

.btn-solid:hover::after {
    left: 100%;
    top: 100%;
}

.btn-solid:hover {
    transform: translateY(-3px) scale(1.03) !important;
    box-shadow: 0 12px 24px rgba(139, 92, 246, 0.4) !important;
    filter: brightness(1.1);
}

.btn-ghost {
    background: var(--premium-surface-glass) !important;
    border: 1px solid var(--premium-border) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 999px !important;
    padding: 14px 32px !important;
    font-weight: 600 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--premium-border-hover) !important;
    transform: translateY(-2px) !important;
}

/* Glass Cards Elevation */
.hub-hero-card,
.flow-card,
.glass-card,
.story-code-card,
.topic-map-card-link {
    background: var(--premium-surface-glass) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.5) !important;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1) !important;
}

.topic-map-card-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--premium-accent-4), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.topic-map-card-link:hover::before {
    opacity: 1;
}

.hub-hero-card:hover,
.flow-card:hover,
.topic-map-card-link:hover {
    transform: translateY(-10px) rotateX(2deg) rotateY(1deg) !important;
    border-color: var(--premium-accent-1) !important;
    box-shadow: 0 32px 64px -16px rgba(99, 102, 241, 0.3) !important;
}

/* Compact Typography Overrides */
.topic-map-card-link h3 {
    font-size: 1.05rem !important;
    margin: 0.5rem 0 !important;
    font-weight: 700 !important;
}

.topic-map-list li {
    font-size: 0.82rem !important;
    line-height: 1.5 !important;
    color: var(--text-secondary) !important;
}

.topic-map-tag {
    font-size: 0.65rem !important;
    padding: 2px 10px !important;
    height: auto !important;
    min-height: 22px !important;
}

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

/* AdTech Toolbox UI */
.adtech-toolbox-panel {
    position: fixed;
    top: 4.5rem;
    right: 2rem;
    width: 280px;
    max-width: calc(100vw - 4rem);
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    background: var(--premium-surface-glass);
    backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--premium-border-hover);
    border-radius: 1.25rem;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.adtech-toolbox-panel.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.toolbox-header {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--premium-border);
    padding-bottom: 0.6rem;
}

.toolbox-header h4 {
    margin: 0;
    font-size: 0.95rem;
    background: none;
    color: var(--text-primary);
    -webkit-text-fill-color: currentColor;
    font-weight: 700;
}

.toolbox-row {
    margin-bottom: 0.85rem;
}

.toolbox-row label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.toolbox-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.toolbox-input {
    width: 100%;
    background: var(--premium-bg);
    border: 1px solid var(--premium-border);
    border-radius: 0.6rem;
    padding: 0.5rem 0.7rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    transition: all 0.2s ease;
}

.toolbox-input:focus {
    outline: none;
    border-color: var(--premium-accent-1);
    background: var(--premium-surface);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.toolbox-result {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-top: 0.75rem;
    text-align: center;
}

.toolbox-result-val {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--premium-accent-4);
}

/* Animations */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

.delay-1 { animation-delay: 1s; }
.delay-2 { animation-delay: 2s; }

/* Pills & Badges */
.hub-topic-pill {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(8px) !important;
}

.hub-topic-pill:hover {
    background: rgba(99, 102, 241, 0.1) !important;
    border-color: var(--premium-accent-1) !important;
    color: #fff !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.12) !important;
}

/* Icons */
.flow-icon {
    background: linear-gradient(135deg, var(--premium-accent-1), var(--premium-accent-2)) !important;
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.18) !important;
    color: #fff !important;
}

/* Stealth Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--premium-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--premium-surface);
    border: 3px solid var(--premium-bg);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--premium-accent-1);
}

/* Scroll Animations Baseline */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px) scale(0.98);
    filter: blur(4px);
    transition: 
        opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
        transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

#scroll-progress {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

#cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--bg-glow), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    transform: translate(-50%, -50%);
    transition: opacity 1s ease;
    mix-blend-mode: screen;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    #cursor-glow {
        display: none !important;
    }

    .hero-title {
        font-size: 2.2rem !important;
        letter-spacing: -0.04em !important;
        line-height: 1.15 !important;
    }

    .home-hero {
        padding: 3rem 0 !important;
    }

    .btn-solid, .btn-ghost {
        width: 100%;
        text-align: center;
        justify-content: center;
        margin-left: 0 !important;
        margin-bottom: 0.5rem;
    }

    .adtech-toolbox-panel {
        right: 1rem;
        left: 1rem;
        width: auto;
        top: 4.5rem;
    }
}

@media (pointer: coarse) {
    #cursor-glow {
        display: none !important;
    }
}
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 6.5rem;
    width: 3.5rem;
    height: 3.5rem;
    background: var(--premium-surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--premium-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 99;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#back-to-top:hover {
    background: var(--premium-accent-1);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

@media (max-width: 768px) {
    #back-to-top {
        right: auto;
        left: 1.5rem;
        bottom: 1.5rem;
        width: 3rem;
        height: 3rem;
    }
}
