/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: white;
    background: #000;
}

/* --- NEW: Ocean Water Background --- */
body {
    background-color: #001f3f; /* Deep blue base color */
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(ellipse at 80% 90%, rgba(0, 116, 217, 0.2) 0%, transparent 40%),
        radial-gradient(ellipse at 20% 30%, rgba(127, 219, 255, 0.25) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 20%);
    animation: 
        caustics 20s linear infinite,
        shimmer 8s ease-in-out infinite alternate;
    background-size: 200% 200%, 300% 300%, 400% 400%;
    background-position: 0% 0%, 100% 100%, 50% 50%;
    opacity: 0;
    animation-delay: 0s, 1s; /* Stagger the animations */
    animation-fill-mode: forwards;
}

@keyframes caustics {
    0% { background-position: 0% 0%, 100% 100%, 50% 50%; }
    25% { background-position: 25% 50%, 75% 50%, 60% 40%; }
    50% { background-position: 50% 100%, 50% 0%, 50% 50%; }
    75% { background-position: 75% 50%, 25% 50%, 40% 60%; }
    100% { background-position: 100% 0%, 0% 100%, 50% 50%; }
}

@keyframes shimmer {
    from { opacity: 0.1; transform: scale(1.0); }
    to { opacity: 0.4; transform: scale(1.05); }
}

/* Black Transition Overlay */
#transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}}

/* WebGL Canvas (hidden) */
#main-canvas {
    display: none;
}

/* Center Text & Ball Styling */
/* Center Text & 3D Sphere Styling */
.center-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Merriweather", serif;
    font-size: 8vw;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    letter-spacing: 0.2em;
    /* Default state is a continuous, subtle animation */
    animation: subtlePulse 15s ease-in-out infinite alternate;
    transition: text-shadow 3s ease-in-out; /* Smooth transition for manual overrides */
}

.logo-word {
    display: inline-block;
    transition: opacity 2s ease-in-out; /* For potentially fading text */
}

/* --- NEW: Add spacing around the sphere --- */
.logo-word:first-child {
  position: relative;
  right: -0.1em; /* Pushes "SLAB" to the left */
}

.logo-word:last-child {
  position: relative;
  left: -0.3em; /* Pushes "SPARK" to the right */
}

#sphere-container {
    height: 2.5em;
    width: 2.5em;
    margin: 0 0.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* For mobile taps */
}

/* The canvas will be inserted here by JS */
#sphere-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    outline: none; /* Removes focus outline on click */
}

/* When in intense-mode, we switch to the more powerful animation */
.center-text.intense-mode {
    animation: intensePulse 8s ease-in-out infinite alternate;
}

/* Keyframe for the default, subtle glow. This runs all the time. */
@keyframes subtlePulse {
    from {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.6), 0 0 40px rgba(127, 219, 255, 0.3);
    }
    to {
        text-shadow: 0 0 35px rgba(255, 255, 255, 0.8), 0 0 55px rgba(127, 219, 255, 0.4);
    }
}

/* Keyframe for the intense, neon-like glow during the transition. */
@keyframes intensePulse {
    from {
        text-shadow:
            0 0 5px #fff,
            0 0 10px #fff,
            0 0 15px #fff,
            0 0 20px #00aaff,
            0 0 35px #00aaff,
            0 0 40px #00aaff;
    }
    to {
        text-shadow:
            0 0 3px #fff,
            0 0 8px #fff,
            0 0 12px #fff,
            0 0 18px #00aaff,
            0 0 30px #00aaff,
            0 0 38px #00aaff;
    }
}

/* --- NEW --- */
/* A dedicated class and animation for smoothly fading the glow out. */
.center-text.fade-out-glow {
    animation: fadeOutGlow 3.5s ease-in-out forwards;
}

@keyframes fadeOutGlow {
    from {
        /* This must match the "intensePulse" style */
        text-shadow:
            0 0 3px #fff,
            0 0 8px #fff,
            0 0 12px #fff,
            0 0 18px #00aaff,
            0 0 30px #00aaff,
            0 0 38px #00aaff;
    }
    to {
        /* This must match the "subtlePulse" style */
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.6), 0 0 40px rgba(127, 219, 255, 0.3);
    }
}


/* Hidden Audio Elements */
audio {
    position: absolute;
    top: -9999px;
    left: -9999px;
}

/* NoScript Fallback */
.noscript-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.fallback-image {
    max-width: 20vw;
    margin-bottom: 1.5rem;
}
.fallback-text {
    font-size: 6vw;
    letter-spacing: 0.15em;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
    body { background: #001f3f; }
    body::before, body::after { display: none; }
}
@media (prefers-contrast: high) {
    body { background: #000; }
    .fallback-text {
        color: #fff;
        text-shadow: 2px 2px 4px #000;
    }
    .fallback-image {
        filter: contrast(1.5) brightness(1.2);
    }
}
