/* ==========================================================================
   Decibels — Global Styles
   Dark theme with blue/yellow highlights, Space Grotesk font.
   ========================================================================== */

/* --- Design tokens --- */
:root {
    --bg:           #000000;
    --text:         #c8c8c8;
    --text-dim:     #7a7a8a;
    --blue:         #4a90d9;
    --blue-bright:  #6ab0ff;
    --yellow:       #e8c547;
    --controls-bg:  rgba(0, 0, 0, 0.85);
    --font:         'Space Grotesk', system-ui, sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;          /* no scrollbars — fullscreen experience */
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* --- Skip link (visible on focus for keyboard users) --- */
.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--blue);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    z-index: 1000;
    font-size: 14px;
    text-decoration: none;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 16px;
}

/* --- Screen-reader-only utility --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Shader container (vertically constrained to sit between header and timeline) --- */
#shader-container {
    position: fixed;
    top: 80px;           /* clear the header area */
    left: 0;
    width: 100%;
    height: calc(100% - 80px - 120px);  /* top margin + bottom margin for controls */
    z-index: 0;
}

/* --- Splash screen --- */
#splash {
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow-y: scroll;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 10, 0.92);
    backdrop-filter: blur(12px);
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

#splash.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    max-width: 560px;
    padding: 48px 32px;
    text-align: left;
}

.splash-content p {
    margin-bottom: 16px;
    color: var(--text);
    font-weight: 300;
}

/* --- Audio legend on splash screen --- */
#audio-legend {
    margin: 24px 0 16px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}

.legend-play-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    cursor: pointer;
    min-height: 32px;
    min-width: 32px;
    transition: border-color 0.2s;
}

.legend-play-btn:hover {
    border-color: var(--blue);
}

.legend-icon-play {
    font-size: 12px;
    line-height: 1;
}

.legend-icon-stop {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: currentColor;
    border-radius: 1px;
}

.legend-text {
    font-size: 14px;
    font-weight: 300;
    color: var(--text);
}

.legend-text strong {
    font-weight: 600;
}

.splash-note {
    font-size: 14px;
    color: var(--text-dim);
}

.splash-content a {
    color: var(--blue);
    text-decoration: underline;
}

.splash-content a:hover {
    color: #fff;
}

#splash-enter {
    display: block;
    margin-top: 32px;
    margin-left: auto;
    margin-right: auto;
    padding: 14px 40px;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--bg);
    background: var(--blue);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    min-height: 48px;       /* accessible touch target */
    min-width: 48px;
    transition: background 0.2s, transform 0.1s;
}

#splash-enter:hover {
    background: var(--blue-bright);
}

#splash-enter:active {
    transform: scale(0.97);
}

#splash-enter:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 3px;
}

/* --- Main content --- */
#main-content {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;        /* let clicks pass through to shader canvas */
    transition: opacity 0.4s ease;
}

#main-content[aria-hidden="true"] {
    opacity: 0;
}

#main-content > * {
    pointer-events: auto;        /* re-enable clicks on actual UI elements */
}

/* --- Site header (top-left: title + date) --- */
#site-header {
    position: absolute;
    top: 24px;
    left: 24px;
}

#site-title {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #fff;
    margin-bottom: 4px;
}

#date-display {
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--text);
}

/* --- Info button (top-right) --- */
#info-btn-container {
    position: absolute;
    top: 24px;
    right: 24px;
}

#info-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, 'Times New Roman', serif;  /* serif italic i looks proper */
    font-size: 18px;
    font-weight: 400;
    font-style: italic;
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s, color 0.2s;
}

#info-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

/* --- Info dialog --- */
#info-dialog {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    overflow-y: scroll;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 10, 0.92);
    backdrop-filter: blur(12px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#info-dialog.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.info-content {
    max-width: 520px;
    padding: 48px 32px;
    text-align: left;
}

.info-content h2 {
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 20px;
}

.info-content p {
    margin-bottom: 24px;
    color: var(--text);
    font-weight: 300;
    line-height: 1.7;
}

.info-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.info-content ul {
    list-style: none;
    margin-bottom: 32px;
}

.info-content li {
    color: var(--text);
    font-weight: 300;
    padding: 3px 0;
}

.info-content a {
    color: var(--blue);
    text-decoration: underline;
}

.info-content a:hover {
    color: #fff;
}

#info-close {
    padding: 10px 32px;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    min-height: 44px;
    transition: border-color 0.2s, color 0.2s;
}

#info-close:hover {
    border-color: var(--blue);
    color: var(--blue);
}

/* --- Controls area (bottom of screen) --- */
#controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px 16px;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.6) 30%);
    padding-top: 32px;     /* extra space so the gradient fades gently */
}

/* --- Tutorial annotations (desktop only) --- */
#annotations {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.6s ease;
}

#annotations.hidden {
    opacity: 0;
    visibility: hidden;
}

.annotation {
    position: absolute;
    font-size: 13px;
    font-weight: 600;
    color: var(--yellow);
    white-space: nowrap;
}

.annotation-play {
    bottom: 140px;
    left: 16px;
}

.annotation-dot {
    bottom: 80px;
    left: 200px;
}

.annotation-banner {
    display: none;
    position: absolute;
    bottom: 160px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--yellow);
    padding: 10px 16px;
}

@media (max-width: 600px) {
    .annotation-desktop { display: none !important; }
    .annotation-banner { display: block !important; }
}

/* --- Play/Stop button (above timeline, left-aligned) --- */
#play-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    color: var(--text);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

/* Stop icon: CSS square instead of unicode glyph for reliable centering */
.stop-icon {
    width: 12px;
    height: 12px;
    background: currentColor;
    border-radius: 1px;
    font-size: 0;          /* hide the unicode character */
    line-height: 0;
}

#play-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

#play-btn:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

/* --- Storm markers (yellow circles above timeline) --- */
#storm-markers {
    position: relative;
    width: 100%;
    height: 16px;
}

.storm-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    padding: 0;
    background: var(--yellow);
    border: none;
    border-radius: 50%;
    outline: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
    -webkit-appearance: none;
    appearance: none;
    top: 4px;
    transform: translateX(-50%);
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.storm-dot:hover {
    transform: translateX(-50%) scale(1.6);
    background: #fff;
}

/* --- Timeline container --- */
#timeline-container {
    width: 100%;
    height: 32px;
    position: relative;
    cursor: pointer;
}

#timeline-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 2px;
    background: #000;
}

#timeline-canvas:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 2px;
}

/* --- Mobile layout --- */
@media (max-width: 600px) {
    .info-content {
        margin-top: 100px;
    }
    /* Smaller header text */
    #site-header {
        top: 16px;
        left: 16px;
    }

    #site-title {
        font-size: 1.1rem;
    }

    #date-display {
        font-size: 0.85rem;
    }

    /* Move info button closer to edge */
    #info-btn-container {
        top: 56px;
        right: 16px;
    }

    #info-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* Adjust shader container for smaller header/controls */
    #shader-container {
        top: 60px;
        height: calc(100% - 60px - 100px);
    }

    /* On mobile: tighter controls */
    #controls {
        padding: 8px 12px 12px;
        padding-top: 24px;
        gap: 4px;
    }

    /* Row for play button + timeline */
    #timeline-container {
        height: 36px;
    }

    #play-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
        margin-bottom: 6px;
    }

    .stop-icon {
        width: 10px;
        height: 10px;
    }

    #storm-markers {
        height: 12px;
    }

    .storm-dot {
        width: 6px;
        height: 6px;
        top: 3px;
    }

/* Splash screen tighter on mobile */
    .splash-content {
        padding: 32px 20px;
        max-width: 100%;
    }

    .splash-content p {
        font-size: 15px;
    }

    /* Info dialog full-width on mobile */
    .info-content {
        padding: 32px 20px;
        max-width: 100%;
    }
}

/* --- Reduced motion preference --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Focus styles for all interactive elements --- */
:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 2px;
}

/* Remove default outline for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}
