:root {
    --c-gold: #D5B05E;
    --c-purple: #704C58;
    --c-brown: #381E19;
    --c-void: #050505;
    --c-paper: #F4F4F0;
    --bg-color: var(--c-paper);
    --text-primary: var(--c-brown);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-bg-subtle: rgba(255, 255, 255, 0.35);
    --glass-border: rgba(255, 255, 255, 0.6);
    --nav-glass: rgba(244, 244, 240, 0.8);
    --cursor-dot: var(--c-purple);
    --cursor-outline: var(--c-purple);
    --cursor-hover-bg: rgba(112, 76, 88, 0.1);
    --stroke-color: var(--c-purple);
    --radius-card: 16px;
    --radius-control: 16px;
    --transition-overlay: rgba(244, 244, 240, 0.9);
}

.dark {
    --bg-color: var(--c-void);
    --text-primary: var(--c-paper);
    --glass-bg: rgba(20, 20, 20, 0.6);
    --glass-bg-subtle: rgba(20, 20, 20, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);
    --nav-glass: rgba(5, 5, 5, 0.8);
    --cursor-dot: var(--c-gold);
    --cursor-outline: var(--c-gold);
    --cursor-hover-bg: rgba(213, 176, 94, 0.1);
    --stroke-color: rgba(255, 255, 255, 0.2);
    --transition-overlay: rgba(5, 5, 5, 0.85);
}

body {
    overflow-x: hidden;
    cursor: none;
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: background-color 0.8s cubic-bezier(0.16, 1, 0.3, 1), color 0.8s ease;
}

html { scroll-behavior: smooth; }

:where(.qa-reveal) {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
    transition: opacity 700ms cubic-bezier(0.16, 1, 0.3, 1), transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}
:where(.qa-reveal.qa-reveal--visible) {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

.qa-page-transition {
    position: fixed;
    inset: 0;
    background: var(--transition-overlay, var(--bg-color));
    backdrop-filter: blur(10px) saturate(1.08);
    -webkit-backdrop-filter: blur(10px) saturate(1.08);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 9998;
}
.qa-page-transition.active {
    opacity: 0.72;
}

:where(a, button):focus-visible {
    outline: 2px solid var(--c-gold);
    outline-offset: 4px;
}

.nav-scrolled {
    background-color: var(--nav-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom-color: rgba(56, 30, 25, 0.1);
}
.dark .nav-scrolled { border-bottom-color: rgba(255, 255, 255, 0.1); }

.micro-lift {
    transition: transform 450ms cubic-bezier(0.16, 1, 0.3, 1), letter-spacing 450ms cubic-bezier(0.16, 1, 0.3, 1), filter 450ms cubic-bezier(0.16, 1, 0.3, 1), opacity 450ms cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}
.micro-lift:hover { transform: translate3d(0, -3px, 0); }
.micro-glow:hover { filter: drop-shadow(0 22px 30px rgba(213, 176, 94, 0.18)); }
.dark .micro-glow:hover { filter: drop-shadow(0 22px 30px rgba(213, 176, 94, 0.22)); }

.marquee-container:hover .marquee-content { animation-play-state: paused; opacity: 0.5; }

:where(a.qa-nav-active) {
    color: var(--c-gold);
}
:where(a.qa-nav-active) span {
    width: 100% !important;
}
:where(a.qa-nav-home-active) {
    color: var(--c-gold);
}

#qa-module-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 1.25rem;
    background: rgba(5, 5, 5, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
}
.dark #qa-module-overlay { background: rgba(5, 5, 5, 0.62); }
#qa-module-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
#qa-module-sheet {
    width: min(820px, 100%);
    transform: translate3d(0, 26px, 0);
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), opacity 220ms cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.98;
}
#qa-module-overlay.active #qa-module-sheet { transform: translate3d(0, 0, 0); }

#qa-reading-progress {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 2px;
    pointer-events: none;
    z-index: 101;
}
#qa-reading-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--c-gold), var(--c-purple));
    box-shadow: 0 10px 30px rgba(213, 176, 94, 0.18);
}

/* --- LAYERS --- */
.layer-bg { z-index: 0; }
.layer-noise { z-index: 10; pointer-events: none; }
.layer-content { z-index: 20; position: relative; }
.layer-nav { z-index: 100; }
.layer-overlay { z-index: 90; }
.layer-cursor { z-index: 9999; pointer-events: none; }

/* Fluid Background */
.gradient-bg {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    transition: background 0.8s ease;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    /* Smoother transition for parallax */
    transition: transform 0.1s linear; 
}

.dark .blob { opacity: 0.3; filter: blur(120px); }

/* Glass Cards */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
    box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.1s ease-out, box-shadow 0.3s ease;
    transform-style: preserve-3d;
}

.glass-panel-subtle {
    background: var(--glass-bg-subtle);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
    box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.1s ease-out, box-shadow 0.3s ease;
    transform-style: preserve-3d;
}

/* Shared Components */
.qa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.1rem 2.5rem;
    border-radius: 9999px;
    font-family: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    line-height: 1;
    transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), background-color 260ms ease, color 260ms ease, border-color 260ms ease, box-shadow 260ms ease, opacity 260ms ease, filter 260ms ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.qa-btn:not(:disabled):hover { transform: translate3d(0, -2px, 0); filter: contrast(1.03) saturate(1.02); }
.qa-btn:active { transform: scale(0.98); }
.qa-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.qa-btn--primary {
    background: var(--c-brown);
    color: var(--c-paper);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(56, 30, 25, 0.2);
}
.qa-btn--primary:hover {
    background: var(--c-gold);
    color: var(--c-void);
    border-color: rgba(213, 176, 94, 0.9);
    box-shadow: 0 22px 70px rgba(213, 176, 94, 0.28);
}
.dark .qa-btn--primary {
    background: var(--c-paper);
    color: var(--c-brown);
    border-color: rgba(255, 255, 255, 0.2);
}
.dark .qa-btn--primary:hover {
    background: var(--c-gold);
    color: var(--c-void);
    border-color: rgba(213, 176, 94, 0.9);
    box-shadow: 0 22px 70px rgba(213, 176, 94, 0.28);
}

.qa-btn--outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(56, 30, 25, 0.18);
}
.qa-btn--outline:hover {
    background: rgba(213, 176, 94, 0.12);
    border-color: rgba(213, 176, 94, 0.75);
    color: var(--c-brown);
    box-shadow: 0 18px 55px rgba(213, 176, 94, 0.16);
}
.dark .qa-btn--outline { border-color: rgba(255, 255, 255, 0.18); }
.dark .qa-btn--outline:hover {
    background: rgba(213, 176, 94, 0.14);
    border-color: rgba(213, 176, 94, 0.75);
    color: var(--c-paper);
    box-shadow: 0 18px 55px rgba(213, 176, 94, 0.18);
}

.qa-btn--sm {
    padding: 0.9rem 1.6rem;
    font-size: 0.7rem;
    letter-spacing: 0.24em;
}

.qa-control { border-radius: var(--radius-control); }

/* Inner reflection glare */
.glass-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(600px circle at var(--glare-x, 50%) var(--glare-y, 50%), rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 55%);
    mix-blend-mode: screen;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 2;
}

.tilt-card:hover .glass-panel::after {
    opacity: 1;
}

.dark .glass-panel {
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

/* Tilt Effect */
.tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
    --glare-x: 50%;
    --glare-y: 50%;
}

/* Custom Cursor */
.cursor-dot {
    width: 8px;
    height: 8px;
    background-color: var(--cursor-dot);
    position: fixed;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s linear; /* Ultra fast */
}

.cursor-outline {
    width: 48px;
    height: 48px;
    border: 1px solid var(--cursor-outline);
    position: fixed;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s, background-color 0.3s, border-color 0.3s, transform 0.15s ease-out;
}

body.hovering .cursor-outline {
    width: 80px;
    height: 80px;
    background-color: var(--cursor-hover-bg);
    border-color: transparent;
    backdrop-filter: invert(0.05);
}

/* Noise Texture */
.noise {
    position: fixed;
    inset: 0;
    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.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.5'/%3E%3C/svg%3E");
    opacity: 0.03;
}

/* Marquee */
.marquee-container { display: flex; overflow: hidden; gap: 4rem; padding: 2rem 0; }
.marquee-content { flex-shrink: 0; display: flex; gap: 4rem; min-width: 100%; animation: marquee 30s linear infinite; }
.stroke-text { -webkit-text-stroke: 1px var(--stroke-color); color: transparent; }
.dark .marquee-stroke { -webkit-text-stroke: 1.25px rgba(248, 246, 240, 0.75); opacity: 0.5; }

/* Mobile Menu */
#mobile-menu-overlay {
    clip-path: circle(0% at 100% 0);
    transition: clip-path 0.7s cubic-bezier(0.87, 0, 0.13, 1);
    background: var(--bg-color);
}
#mobile-menu-overlay.active { clip-path: circle(150% at 100% 0); }

/* Added missing marquee keyframes so the text actually moves */
@keyframes marquee {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

/* Responsive Fixes */
@media (hover: none) and (pointer: coarse) {
    .cursor-dot, .cursor-outline { display: none !important; }
    body { cursor: auto; }
    /* Enable simplified tilt/parallax on mobile if handled by JS, but reset defaults */
    .tilt-card { transform: none; } 
    .glass-panel { transform: none; }
}

/* Touch Ripple */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.75s cubic-bezier(0.16, 1, 0.3, 1);
    background-color: var(--cursor-hover-bg);
    pointer-events: none;
    z-index: 999;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Relative positioning for ripple container */
.hoverable, button, a {
    position: relative;
    overflow: hidden; /* Contains the ripple */
}

:where(button):not(:disabled):hover {
    filter: contrast(1.03) saturate(1.02);
}

@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .cursor-dot, .cursor-outline { display: none !important; }
    body { cursor: auto; }
}
