/* ============================================
   CSS Variables & Design Tokens
   ============================================ */
:root {
    /* Colors - Light Theme */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #f3e8ff 100%);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.05);
    /* Subtle border for light mode */
    --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    /* Remove the solid spread to keep border thin, keep only soft bloom */
    --card-shadow-hover: 0 0 20px rgba(16, 185, 129, 0.15), 0 10px 30px rgba(0, 0, 0, 0.04);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent-primary: #10b981;
    /* Emerald Green */
    --accent-secondary: #0d9488;
    /* Teal */
    --accent-gradient: linear-gradient(135deg, #10b981 0%, #0d9488 50%, #34d399 100%);
    --glow-color: rgba(16, 185, 129, 0.2);
    --header-bg: transparent;
    --footer-bg: transparent;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Typography */
    --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;
    --font-size-5xl: 3.5rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Aurora Colors - Light */
    --aurora-white: #ffffff;
    --aurora-black: #000000;
    --aurora-blue-500: #3b82f6;
    --aurora-indigo-300: #a5b4fc;
    --aurora-blue-300: #93c5fd;
    --aurora-violet-200: #ecfdf5;
    /* Very pale mint */
    --aurora-blue-400: #60a5fa;
    --aurora-transparent: transparent;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-gradient: linear-gradient(135deg, #0a0a0f 0%, #12121a 30%, #1a1025 60%, #0f0a1a 100%);
    --card-bg: rgba(25, 20, 45, 0.6);
    --card-border: rgba(16, 185, 129, 0.2);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    /* Remove solid spread for dark mode too */
    --card-shadow-hover: 0 0 35px rgba(16, 185, 129, 0.25), 0 15px 45px rgba(0, 0, 0, 0.4);
    --text-primary: #ffffff;
    /* User requested pure white */
    --text-secondary: #e2e8f0;
    /* User requested gray-white */
    --text-muted: #94a3b8;
    --glow-color: rgba(16, 185, 129, 0.3);
    --header-bg: transparent;
    --footer-bg: transparent;

    /* Aurora Colors - Dark */
    --aurora-white: #ffffff;
    --aurora-black: #000000;
}

/* ============================================
   Reset & Base Styles
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-gradient);
    min-height: 100vh;
    transition: background var(--transition-slow), color var(--transition-base);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

/* ============================================
   Header
   ============================================ */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: var(--space-md) var(--space-xl);
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: none;
    transition: background var(--transition-base);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.header-spacer {
    flex: 1;
}

.header-controls {
    display: flex;
    gap: var(--space-sm);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.control-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

.lang-toggle {
    width: auto;
    padding: 0 var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
    position: relative;
    min-height: 30vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(60px + var(--space-xl)) var(--space-xl) var(--space-lg);
    overflow: hidden;
}

.aurora-container {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}

.collision-container {
    position: fixed;
    inset: 0;
    z-index: 5;
    /* Above aurora, below header/content if we want it to feel like it's in the background */
    pointer-events: none;
    overflow: hidden;
}

#collision-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.aurora-gradient {
    position: absolute;
    inset: -10px;
    /* Use overlay or screen to allow white to be additive/bright */
    mix-blend-mode: overlay;
    opacity: 1;
    /* Remove global opacity limit */
    filter: blur(20px);
    background-image:
        /* White shine layer */
        repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.8) 3%, transparent 5%, transparent 7%, rgba(255, 255, 255, 0.8) 12%),
        /* Color layer - Pure Emerald & Teal */
        repeating-linear-gradient(100deg, rgba(16, 185, 129, 0.2) 10%, rgba(52, 211, 153, 0.2) 15%, rgba(13, 148, 136, 0.15) 20%, rgba(110, 231, 183, 0.15) 25%, rgba(16, 185, 129, 0.2) 30%);
    background-size: 300% 200%;
    background-position: 50% 50%, 50% 50%;
    will-change: transform;
    animation: aurora 80s linear infinite;
    /* Increase mask slightly to show more light */
    -webkit-mask-image: radial-gradient(ellipse at 100% 0%, black 20%, transparent 80%);
    mask-image: radial-gradient(ellipse at 100% 0%, black 20%, transparent 80%);
}

/* Dark mode overrides */
[data-theme="dark"] .aurora-gradient {
    filter: blur(20px);
    mix-blend-mode: normal;
    /* Normal blending for dark mode so white pops */
    opacity: 0.8;
    background-image:
        /* In dark mode, white needs to be bright but not overwhelming */
        repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.4) 7%, transparent 10%, transparent 12%, rgba(255, 255, 255, 0.4) 16%),
        /* Colors need more punch in dark mode */
        repeating-linear-gradient(100deg, rgba(16, 185, 129, 0.3) 10%, rgba(52, 211, 153, 0.3) 15%, rgba(13, 148, 136, 0.25) 20%, rgba(110, 231, 183, 0.25) 25%, rgba(16, 185, 129, 0.3) 30%);
}

.aurora-gradient::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(100deg, var(--aurora-white) 0%, var(--aurora-white) 3%, var(--aurora-transparent) 5%, var(--aurora-transparent) 7%, var(--aurora-white) 10%),
        repeating-linear-gradient(100deg, rgba(16, 185, 129, 0.15) 10%, rgba(52, 211, 153, 0.1) 15%, rgba(13, 148, 136, 0.15) 20%, rgba(110, 231, 183, 0.1) 25%, rgba(16, 185, 129, 0.15) 30%);
    background-size: 200% 100%;
    background-attachment: fixed;
    mix-blend-mode: overlay;
    animation: aurora-reverse 60s linear infinite;
}

[data-theme="dark"] .aurora-gradient::after {
    background-image:
        repeating-linear-gradient(100deg, var(--aurora-black) 0%, var(--aurora-black) 7%, var(--aurora-transparent) 10%, var(--aurora-transparent) 12%, var(--aurora-black) 16%),
        repeating-linear-gradient(100deg, rgba(16, 185, 129, 0.2) 10%, rgba(52, 211, 153, 0.15) 15%, rgba(13, 148, 136, 0.2) 20%, rgba(110, 231, 183, 0.15) 25%, rgba(16, 185, 129, 0.2) 30%);
}

@keyframes aurora {
    from {
        background-position: 50% 50%, 50% 50%;
    }

    to {
        background-position: 350% 50%, 350% 50%;
    }
}

@keyframes aurora-reverse {
    from {
        background-position: 350% 50%, 350% 50%;
    }

    to {
        background-position: 50% 50%, 50% 50%;
    }
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 800px;
}

.hero-title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
    /* background: var(--accent-gradient); */
    /* -webkit-background-clip: text; */
    /* -webkit-text-fill-color: transparent; */
    /* background-clip: text; */
    animation: fadeInUp 0.8s ease-out;
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-base);
    display: inline-block;
}

.hero-subtitle:hover {
    color: var(--accent-primary);
    transform: scale(1.02);
}

.hero-subtitle:active {
    transform: scale(0.98);
}

.hero-subtitle.loading-text {
    opacity: 0;
    filter: blur(10px);
    pointer-events: none;
    /* Prevent clicks during transition */
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Bento Grid
   ============================================ */
.bento-container {
    padding: var(--space-md) var(--space-xl);
    max-width: 1200px;
    margin: 0 auto;
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

/* Main card spans full width */
.bento-card-main {
    grid-column: 1 / -1;
}

/* ============================================
   Bento Cards
   ============================================ */
.bento-card {
    position: relative;
    background: var(--card-bg);
    /* Remove static border, use wrapper for dynamic border */
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-base);
    overflow: hidden;

    /* Variables for the glowing effect */
    --start: 0;
    --active: 0;
    --spread: 40;
}

/* Base border layer (faint) */
.bento-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    /* Border width */
    background: rgba(16, 185, 129, 0.05);
    /* Even fainter base */
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}

/* Dynamic Glowing Border Layer */
.bento-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;

    /* 
       THE LIGHT SWEEP:
       A fresh Mint Emerald & Lemon Yellow sweep that rotates with the mouse.
    */
    background: conic-gradient(from calc(var(--start) * 1deg - 40deg),
            transparent 0deg,
            rgba(52, 211, 153, 0.4) 15deg,
            /* Mint Emerald (Transparent) */
            #34d399 30deg,
            /* Emerald Core */
            #fde047 40deg,
            /* Bright Lemon */
            #34d399 50deg,
            rgba(52, 211, 153, 0.4) 65deg,
            transparent 80deg);

    /* 
       THE HOLLOW MASK:
       1. Inner mask: content-box (The hole)
       2. Outer mask: border-box (The full area)
       3. source-out: Only show background in the gap (the border).
    */
    padding: 2.2px;
    /* Precision border width */

    -webkit-mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
    -webkit-mask-clip: content-box, border-box;
    -webkit-mask-composite: source-out;

    mask-image: linear-gradient(#000, #000), linear-gradient(#000, #000);
    mask-clip: content-box, border-box;
    mask-composite: exclude;

    opacity: var(--active);
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 2;
}

.bento-card:hover {
    /* Remove transform: translateY(-8px); */
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.1);
}

/* 
.bento-card:hover .card-title,
.bento-card:hover .card-desc,
.bento-card:hover .card-tag {
    color: white;
    -webkit-text-fill-color: white;
} 
*/

.bento-card:hover .card-glow {
    opacity: 0;
}

/* Card Glow Effect - Hidden */
.card-glow {
    display: none;
}

/* Card Content */
.card-content {
    position: relative;
    z-index: 10;
    /* Ensure content is significantly above the glow */
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Main Card Layout */
.bento-card-main .card-content {
    flex-direction: row;
    align-items: center;
    gap: var(--space-xl);
}

.bento-card-main .card-logo {
    flex-shrink: 0;
}

.bento-card-main .card-logo img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: var(--radius-lg);
    transition: transform var(--transition-base);
}

.bento-card-main:hover .card-logo img {
    transform: scale(1.05);
}

.bento-card-main .card-text {
    flex: 1;
}

.bento-card-main .card-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.bento-card-main .card-desc {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
}

/* Small Card Layout */
.bento-card-small {
    min-height: 220px;
}

.bento-card-small .card-logo {
    margin-bottom: var(--space-lg);
}

.bento-card-small .card-logo img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: var(--radius-md);
    transition: transform var(--transition-base);
}

.bento-card-small:hover .card-logo img {
    transform: scale(1.1);
}

.card-tag {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: #3b82f6;
    color: white;
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

.bento-card-small .card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    line-height: 1.4;
}

.bento-card-small .card-desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    padding: var(--space-xl);
    background: var(--footer-bg);
    backdrop-filter: blur(10px);
    border-top: none;
    margin-top: auto;
    padding-top: var(--space-3xl);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.copyright {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.footer-links {
    display: block;
    margin-top: var(--space-sm);
}

.footer-links a {
    color: var(--text-secondary);
    margin: 0 var(--space-sm);
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent-primary);
}

/* ============================================
   Theme Toggle - Logo Visibility
   ============================================ */
[data-theme="dark"] .logo-light {
    display: none !important;
}

[data-theme="dark"] .logo-dark {
    display: block !important;
}

[data-theme="dark"] .icon-sun {
    display: none !important;
}

[data-theme="dark"] .icon-moon {
    display: block !important;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .hero-title {
        font-size: var(--font-size-3xl);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
    }

    .bento-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .bento-card-main .card-content {
        flex-direction: column;
        text-align: center;
    }

    .bento-card-main .card-logo img {
        width: 80px;
        height: 80px;
    }

    .bento-card-main .card-title {
        font-size: var(--font-size-xl);
    }

    .bento-card-small {
        min-height: auto;
    }

    .header {
        padding: var(--space-sm) var(--space-md);
    }

    .bento-container {
        padding: var(--space-md);
    }
}

@media (max-width: 480px) {
    .hero {
        padding-top: calc(60px + var(--space-2xl));
        min-height: 40vh;
    }

    .hero-title {
        font-size: var(--font-size-2xl);
    }

    .footer-links {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
    }

    .footer-links a {
        margin: 0;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* Stagger animation for cards */
.bento-card {
    animation: fadeInUp 0.6s ease-out backwards;
}

.bento-card-main {
    animation-delay: 0.3s;
}

.bento-card-small:nth-child(2) {
    animation-delay: 0.4s;
}

.bento-card-small:nth-child(3) {
    animation-delay: 0.5s;
}

.bento-card-small:nth-child(4) {
    animation-delay: 0.6s;
}

.bento-card-small:nth-child(5) {
    animation-delay: 0.7s;
}

/* ============================================
   Placeholder Card (Coming Soon)
   ============================================ */
.bento-card-placeholder {
    border: 2px dashed var(--text-muted);
    background: transparent;
    cursor: default;
}

.bento-card-placeholder:hover {
    transform: none;
    box-shadow: var(--card-shadow);
    border-color: var(--text-muted);
}

.bento-card-placeholder .card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* ============================================
   Spotlight Effect for Placeholder Card
   ============================================ */
.bento-card-placeholder {
    position: relative;
    overflow: hidden;
}

/* Spotlight glow that follows mouse */
.spotlight-glow {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at center,
            rgba(16, 185, 129, 0.8) 0%,
            /* Emerald Green */
            rgba(52, 211, 153, 0.6) 25%,
            /* Mint Emerald */
            rgba(52, 211, 153, 0.4) 50%,
            rgba(110, 231, 183, 0.2) 70%,
            /* Soft Mint */
            transparent 90%);
    filter: blur(15px);
    pointer-events: none;
    opacity: 0;
    z-index: 1;
    transform: translate(-50%, -50%);
    /* Slow fade out and shrink when mouse leaves */
    transition: opacity 0.6s ease-out, width 0.5s ease-out, height 0.5s ease-out;
}

.bento-card-placeholder:hover .spotlight-glow {
    opacity: 1;
    /* Fast fade in when mouse enters */
    transition: opacity 0.15s ease-in, width 0.15s ease-in, height 0.15s ease-in;
}

/* Shrink state when leaving */
.spotlight-glow.shrinking {
    width: 0px !important;
    height: 0px !important;
    opacity: 0 !important;
}

/* Grid pattern container - CSS rounded squares */
.grid-pattern-container {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, 16px);
    grid-template-rows: repeat(auto-fill, 16px);
    gap: 2px;
    padding: 2px;
    pointer-events: none;
    /* Default: invisible, controlled by mask */
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Radial mask - will be updated dynamically by JS */
    -webkit-mask-image: radial-gradient(circle 80px at var(--mouse-x, -100px) var(--mouse-y, -100px), black 0%, transparent 100%);
    mask-image: radial-gradient(circle 80px at var(--mouse-x, -100px) var(--mouse-y, -100px), black 0%, transparent 100%);
}

/* Show grid when hovering */
.bento-card-placeholder:hover .grid-pattern-container {
    opacity: 1;
}

/* Individual grid cell - rounded square */
.grid-cell {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    /* Light mode: white squares */
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

/* Dark mode grid cells - black squares */
[data-theme="dark"] .grid-cell {
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.6);
}

/* Placeholder content styling */
.placeholder-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.placeholder-text {
    font-size: var(--font-size-lg);
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}