/** =============================================================================
 *
 *  Project    : Google IO Experience
 *  File       : Visual Identity (style.css)
 *  Created    : May 1, 2026
 *  Maintainer : Shubham Darda
 *  Purpose    : Manages visual identity, responsive layout, and Gemini-inspired
 *               aesthetics, implementing modern Glassmorphism and animations.
 *
 * ============================================================================= **/

/* Global Reset for predictable layout math */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Theme Variables */
:root {
    color-scheme: dark light;
    /* Dark Theme (Default) */
    --bg-color-start: #0a0a1a;
    --bg-color-end: #050505;
    --ui-glow: rgba(66, 133, 244, 0.3);
    --stat-bg: rgba(255, 255, 255, 0.05);
    --stat-border: rgba(255, 255, 255, 0.1);
    --label-color: rgba(255, 255, 255, 0.5);
    --footer-color: rgba(255, 255, 255, 0.25);
    --ball-color: #ffffff;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-color-start: #f8f9fa;
        --bg-color-end: #e8eaed;
        --ui-glow: rgba(66, 133, 244, 0.15);
        --stat-bg: rgba(0, 0, 0, 0.05);
        --stat-border: rgba(0, 0, 0, 0.1);
        --label-color: rgba(0, 0, 0, 0.6);
        --footer-color: rgba(0, 0, 0, 0.4);
        --ball-color: #34A853; /* Green for light theme */
    }
}

/* Base Document Configuration */
body {
    margin: 0;
    overflow: hidden;
    /* Premium shifting mesh background */
    background: radial-gradient(circle at center, var(--bg-color-start) 0%, var(--bg-color-end) 100%);
    font-family: 'Google Sans', sans-serif;
    /* Prevent text selection to deter fraud and improve game feel */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#flowCanvas {
    display: block;
}

/* Unified HUD Row */
#hud {
    position: absolute;
    top: 2vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 12px;
    width: 95vw;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    z-index: 10;
}

#ui-text {
    background: linear-gradient(90deg, #4285F4, #9B72CB, #D96570, #13B5C7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.05em;
    text-transform: none;
    font-weight: 900;
    line-height: 1.2;
    width: 100%;
    text-align: center;
    filter: drop-shadow(0 0 10px var(--ui-glow));
    overflow: hidden;
    text-overflow: ellipsis;
    animation: text-glow 3s infinite alternate ease-in-out;
}

/* Responsive Hero Brand Background */
#hero-brand {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    text-align: center;
    font-size: clamp(24px, 8.5vw, 120px);
    font-weight: 900;
    background: linear-gradient(90deg, #4285F4, #9B72CB, #D96570, #FBBC05);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.1;
    display: none;
    pointer-events: none;
    z-index: 1;
    text-transform: uppercase;
}

/* Centered Layout for Final Victory Screen */
#hud.final-screen {
    top: 2vh !important;
    transform: translateX(-50%) !important;
}

#hud.final-screen + #hero-brand {
    display: block;
    opacity: 0.8;
    background-size: 200% auto;
    animation: hero-shimmer 8s linear infinite, congrats-pulse 2s ease-in-out infinite alternate;
}

@keyframes hero-shimmer {
    from { background-position: 0% center; }
    to { background-position: 200% center; }
}

@keyframes congrats-pulse {
    from { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
    to { transform: translate(-50%, -50%) scale(1.03); filter: brightness(1.15) drop-shadow(0 0 20px var(--ui-glow)); }
}

#hud.final-screen #ui-text {
    font-size: clamp(14px, 4vw, 24px);
}
.stat-card {
    background: var(--stat-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--stat-border);
    border-radius: 10px;
    padding: 8px 4px;
    flex: 1;
    min-width: 0;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);
}

.stat-card .label {
    color: var(--label-color);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0px;
}

.stat-card .value {
    font-size: clamp(12px, 3.5vw, 24px);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#score-val {
    color: #34A853;
    text-shadow: 0 0 4px rgba(52, 168, 83, 0.3);
}

#chances-val {
    color: #4285F4; /* Blue for light theme */
    text-shadow: 0 0 4px rgba(66, 133, 244, 0.3);
}

#sound-val {
    color: #FBBC05;
    text-shadow: 0 0 4px rgba(251, 188, 5, 0.3);
}

#sound-card {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.1s ease;
}

#sound-card:active {
    transform: scale(0.95);
}

/* Final Credits Layout: Centered below Hero Brand */
#final-credits {
    position: absolute;
    top: 72%;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 15px;
    z-index: 10;
    pointer-events: auto; /* Enable link clicks */
}

#hud.final-screen ~ #final-credits {
    display: flex;
}

#final-credits .stat-card {
    min-width: 200px;
    height: 65px;
    padding: 8px 20px;
    flex: 0 1 auto;
}

#final-credits .stat-card .value {
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card a {
    background: linear-gradient(90deg, #4285F4, #9B72CB, #D96570, #13B5C7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    font-weight: 900;
}

/* Animations & Transitions */
@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Responsive Adjustments for Mobile and Portrait Viewports */
@media (max-width: 1024px) {
    #hud {
        top: 20px;
        width: 95vw;
        justify-content: center;
        gap: 12px; /* Uniform margin between rows and columns */
        flex-wrap: wrap; /* Allow wrapping to two rows */
    }

    #status-card {
        flex: 1 0 100%; /* Ensure row 1 fills the container width exactly */
    }

    #final-credits {
        width: 95vw;
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    #final-credits .stat-card {
        min-width: 0;
        flex: 1;
    }

    .stat-card {
        height: 53px;
        padding: 4px;
    }

    .stat-card .label {
        font-size: 7px;
    }

    .stat-card .value {
        font-size: clamp(10px, 3vw, 18px);
    }
}

/* Pulsing glow animation for the main title */
@keyframes text-glow {
    from { text-shadow: 0 0 5px rgba(66, 133, 244, 0.4); }
    to { text-shadow: 0 0 15px rgba(234, 67, 53, 0.6); }
}

/* Minimalist Footer Branding */
#footer-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
    user-select: none;
    width: 100%;
    z-index: 5;
    color: var(--footer-color);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: none;
}

#footer-hint .dot {
    margin: 0 10px;
    opacity: 0.5;
}
