/* ============================================================
   Virtual Aquarium — style.css
   Complete stylesheet: design system, layout, components, 
   responsive breakpoints, and animations.
   ============================================================ */

/* ---- CSS Variables / Design Tokens ---- */
:root {
    /* Page background gradient (outer — dark teal/navy, NO purple) */
    --bg-gradient-start: #060e18;
    --bg-gradient-mid:   #0d2137;
    --bg-gradient-end:   #071019;

    /* Card */
    --card-bg:      #0b1a2b;
    --card-border:  #1a3550;
    --card-radius:  12px;
    --card-shadow:  0 8px 32px rgba(0, 0, 0, 0.5),
                    0 0 80px rgba(13, 148, 136, 0.04);

    /* Sidebars */
    --sidebar-bg:    rgba(8, 20, 35, 0.55);
    --sidebar-width: 56px;

    /* Title bar & footer */
    --bar-bg:           rgba(8, 20, 35, 0.8);
    --bar-border:       rgba(94, 234, 212, 0.08);
    --title-bar-height: 48px;
    --footer-height:    42px;

    /* Icons */
    --icon-size:           28px;
    --icon-color:          #5eead4;
    --icon-hover-color:    #a7f3d0;
    --icon-hover-bg:       rgba(94, 234, 212, 0.08);
    --icon-secret-opacity: 0.28;

    /* Typography */
    --font-pixel: 'Silkscreen', cursive;

    /* Accent */
    --accent:      #14b8a6;
    --accent-glow: rgba(20, 184, 166, 0.3);

    /* Tank frame */
    --tank-border:     #1e3a52;
    --tank-inner-glow: rgba(0, 0, 0, 0.3);
    --tank-outer-glow: rgba(20, 184, 166, 0.12);

    /* Text */
    --text-primary:   #e2e8f0;
    --text-secondary: #94a3b8;
    --text-dim:       #475569;

    /* Transitions */
    --transition-speed: 0.25s;
}


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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-pixel);
    color: var(--text-primary);
    background: linear-gradient(135deg,
        var(--bg-gradient-start) 0%,
        var(--bg-gradient-mid)   50%,
        var(--bg-gradient-end)   100%);
    display: flex;
    align-items: center;
    justify-content: center;

    /* Keep pixel font crisp */
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
    text-rendering: optimizeSpeed;
}

/* Pixel-crisp rendering for all images and canvas */
img,
canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}


/* ============================================================
   START SCREEN
   ============================================================ */
#start-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(ellipse at 50% 40%,
        #0d2845 0%,
        #06101f 70%,
        #020810 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.8s ease;
    user-select: none;
}

#start-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.start-content {
    text-align: center;
}

.start-title {
    font-family: var(--font-pixel);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 3px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(94, 234, 212, 0.3);
    animation: titleGlow 3s ease-in-out infinite;
}

.start-subtitle {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    animation: breathe 2.5s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 20px rgba(94, 234, 212, 0.25); }
    50%      { text-shadow: 0 0 40px rgba(94, 234, 212, 0.5),
                            0 0 80px rgba(94, 234, 212, 0.15); }
}

@keyframes breathe {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}


/* ============================================================
   MODULAR FLOATING PODS & CRT AQUARIUM
   ============================================================ */
#app-container {
    width: min(93vw, 1380px);
    height: min(89vh, 820px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    user-select: none;
}

/* Shared Pod Styling */
.pod {
    background: rgba(10, 24, 40, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(94, 234, 212, 0.16);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45),
                0 0 30px rgba(13, 148, 136, 0.04),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
}


/* ---- Header Pod (Top Extreme) ---- */
.header-pod {
    height: var(--title-bar-height);
    min-height: var(--title-bar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    width: 100%;
}

.title-text {
    font-family: var(--font-pixel);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 2px;
    text-shadow: 0 0 12px var(--accent-glow);
}

.fish-counter {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(94, 234, 212, 0.1);
}


/* ---- Main Workspace Area ---- */
#main-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 0; /* prevent flex child overflow */
}


/* ---- Sidebar Pods (Far Left and Far Right Extremes) ---- */
.sidebar-pod {
    position: relative;
    z-index: 25;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 20px 0;
    border-radius: 24px;
}


/* ---- Icon Buttons ---- */
.icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: var(--icon-color);
    transition: color var(--transition-speed) ease,
                transform var(--transition-speed) ease,
                background var(--transition-speed) ease;
}

.icon-btn svg {
    width: var(--icon-size);
    height: var(--icon-size);
    flex-shrink: 0;
}

.icon-btn:hover {
    color: var(--icon-hover-color);
    background: var(--icon-hover-bg);
    transform: scale(1.1);
    z-index: 30;
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    z-index: 30;
}

/* CSS Tooltips via ::after pseudo-element */
.icon-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    font-family: var(--font-pixel);
    font-size: 10px;
    white-space: nowrap;
    background: rgba(4, 12, 22, 0.96);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(94, 234, 212, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease;
    z-index: 100;
}

/* Left sidebar: tooltips appear to the right */
#sidebar-left .icon-btn::after {
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
}

/* Right sidebar: tooltips appear to the left */
#sidebar-right .icon-btn::after {
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
}

.icon-btn:hover::after,
.icon-btn:focus::after {
    opacity: 1;
}

/* Secret star icon — subtle, low contrast */
.icon-secret {
    color: var(--text-dim);
    opacity: var(--icon-secret-opacity);
    transition: opacity var(--transition-speed) ease,
                color var(--transition-speed) ease,
                transform var(--transition-speed) ease;
}

.icon-secret:hover {
    opacity: 0.55;
    color: var(--text-secondary);
    background: transparent;
}

/* Disabled state for add/remove at limits */
.icon-btn.disabled {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}


/* ============================================================
   CRT TV / GLASSY AQUARIUM TANK POD (Central Feature)
   ============================================================ */
.tank-pod.crt-frame {
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    margin: 4px 12px;
    cursor: crosshair;
    
    /* Background image fallback */
    background: url('assets/background.png') center / cover no-repeat;
    image-rendering: pixelated;
    
    /* Chunky Retro CRT TV Frame / Bezel */
    border-radius: 40px;
    border: 10px solid #0d1e30;
    outline: 2px solid rgba(94, 234, 212, 0.22);
    outline-offset: -2px;
    box-shadow:
        0 18px 45px rgba(0, 0, 0, 0.7),
        0 0 35px var(--tank-outer-glow),
        inset 0 0 50px rgba(0, 0, 0, 0.75),
        inset 0 0 120px rgba(4, 12, 24, 0.85);
}

#tank-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 28px;
    cursor: crosshair;
}

/* Glassy Glare Reflection & CRT Scanlines */
.crt-glare {
    position: absolute;
    inset: 0;
    border-radius: 28px;
    pointer-events: none;
    z-index: 5;
    background: 
        linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.03) 25%, transparent 50%),
        radial-gradient(ellipse at 50% 0%, rgba(94, 234, 212, 0.1) 0%, transparent 60%);
    box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.2),
                inset 0 -2px 4px rgba(0, 0, 0, 0.4);
}

.crt-glare::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.14) 3px,
        rgba(0, 0, 0, 0.14) 4px
    );
    opacity: 0.6;
    pointer-events: none;
}

/* Flash overlay for snapshot (Phase 7) */
#flash-overlay {
    position: absolute;
    inset: 0;
    border-radius: 28px;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.15s ease;
}

#flash-overlay.flash {
    opacity: 0.7;
}


/* ---- Footer Pod (Bottom Extreme) ---- */
.footer-pod {
    height: var(--footer-height);
    min-height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    width: 100%;
}

.footer-credit {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.footer-contact {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.5px;
    opacity: 0.65;
    padding: 4px 8px;
    border-radius: 4px;
    transition: opacity var(--transition-speed) ease,
                background var(--transition-speed) ease;
}

.footer-contact:hover {
    opacity: 1;
    text-decoration: underline;
    background: rgba(94, 234, 212, 0.06);
}

.footer-volume {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-icon {
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}


/* ---- Custom Volume Slider ---- */
#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: rgba(94, 234, 212, 0.12);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: background var(--transition-speed) ease;
}

#volume-slider:hover {
    background: rgba(94, 234, 212, 0.2);
}

/* Webkit (Chrome, Safari, Edge) */
#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #0b1a2b;
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-glow);
    transition: transform var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
}

#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Firefox */
#volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #0b1a2b;
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-glow);
}

#volume-slider::-moz-range-track {
    background: rgba(94, 234, 212, 0.12);
    height: 4px;
    border-radius: 2px;
    border: none;
}


/* ============================================================
   MODALS
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-speed) ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    padding: 28px 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5),
                0 0 30px rgba(20, 184, 166, 0.06);
}

.modal-card h2 {
    font-family: var(--font-pixel);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color var(--transition-speed) ease,
                background var(--transition-speed) ease;
    font-family: var(--font-pixel);
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(94, 234, 212, 0.08);
}

/* ---- Help Modal Content ---- */
.help-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(94, 234, 212, 0.08);
}

.help-row:last-of-type {
    border-bottom: none;
}

.help-key {
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    min-width: 90px;
    text-shadow: 0 0 6px rgba(94, 234, 212, 0.3);
}

.help-desc {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.35;
    text-align: right;
}

.help-shortcuts {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
}

.shortcut-tag {
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--text-dim);
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    margin-right: 4px;
}


/* ---- Secret Modal Form ---- */
.secret-form {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

#secret-input {
    flex: 1;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-pixel);
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
}

#secret-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

#secret-input::placeholder {
    color: var(--text-dim);
}

.modal-btn {
    padding: 10px 18px;
    background: var(--accent);
    color: #0a1628;
    border: none;
    border-radius: 6px;
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background var(--transition-speed) ease,
                transform var(--transition-speed) ease;
}

.modal-btn:hover {
    background: var(--icon-hover-color);
    transform: scale(1.05);
}

.modal-btn:active {
    transform: scale(0.97);
}

.error-text {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: #f87171;
    margin-top: 4px;
}


/* ---- Birthday Modal ---- */
.birthday-card {
    text-align: center;
    padding: 32px 28px;
    max-width: 440px;
    border-color: rgba(251, 191, 36, 0.4);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6),
                0 0 35px rgba(251, 191, 36, 0.15);
}

.birthday-cake-icon {
    font-size: 36px;
    margin-bottom: 8px;
    animation: float 2.5s ease-in-out infinite alternate;
}

@keyframes float {
    from { transform: translateY(0px) scale(1); }
    to { transform: translateY(-6px) scale(1.05); }
}

.birthday-card h2 {
    color: #fbbf24;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
    font-size: 15px;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

.birthday-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.birthday-message {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
}

.birthday-subtext {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    background: rgba(251, 191, 36, 0.08);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.birthday-footer {
    margin-top: 14px;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: #fbbf24;
    letter-spacing: 0.5px;
}


/* ---- Modal shake animation (wrong password) ---- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.modal-card.shake {
    animation: shake 0.5s ease;
}


/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
    display: none !important;
}

/* Override for modal hidden — use opacity instead of display
   so transitions work */
.modal.hidden {
    display: flex !important;
    opacity: 0;
    pointer-events: none;
}


/* ============================================================
   RESPONSIVE — Small Screens (<768px)
   ============================================================ */
/* ============================================================
   RESPONSIVE — Small Screens (<768px)
   ============================================================ */
@media (max-width: 768px) {

    /* Layout fills more viewport */
    #app-container {
        width: 95vw;
        height: 94vh;
        gap: 10px;
    }

    /* Header shrinks */
    .header-pod {
        height: 40px;
        min-height: 40px;
        padding: 0 16px;
    }

    .title-text {
        font-size: 12px;
        letter-spacing: 1px;
    }

    .fish-counter {
        font-size: 9px;
        padding: 4px 8px;
    }

    /* Main body stacks vertically: tank on top, then controls */
    #main-area {
        flex-direction: column;
        gap: 8px;
    }

    .tank-pod.crt-frame {
        order: 1;
        flex: 1;
        border-radius: 18px;
    }

    .tank-pod.crt-frame #tank-canvas,
    .crt-glare,
    #flash-overlay {
        border-radius: 14px;
    }

    /* Sidebars become horizontal pods below the tank */
    .sidebar-pod {
        flex-direction: row;
        width: 100%;
        min-width: unset;
        height: auto;
        padding: 6px 12px;
        justify-content: center;
        gap: 12px;
        border-radius: 12px;
    }

    #sidebar-left {
        order: 2;
    }

    #sidebar-right {
        order: 3;
    }

    /* Tooltips below icons on mobile */
    .icon-btn::after {
        top: calc(100% + 6px) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }

    /* Footer stacks */
    .footer-pod {
        order: 4;
        flex-direction: column;
        height: auto;
        min-height: unset;
        padding: 8px 14px;
        gap: 6px;
        border-radius: 12px;
    }

    .footer-credit,
    .footer-contact {
        font-size: 9px;
    }

    #volume-slider {
        width: 90px;
    }

    /* Start screen responsive */
    .start-title {
        font-size: 20px;
        letter-spacing: 2px;
    }

    .start-subtitle {
        font-size: 10px;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    #app-container {
        width: 98vw;
        height: 98vh;
        gap: 6px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .icon-btn svg {
        width: 22px;
        height: 22px;
    }

    .start-title {
        font-size: 16px;
    }
}
