/* ==========================================================================
   bada.quest - Deep Sea Submersible HUD
   Color Palette from DESIGN.md:
     Water Surface: #0077b6
     Water Mid: #023e8a
     Water Deep: #03045e
     Abyss: #010213
     HUD Teal: #008080
     HUD Glow: #00ffcc
     Alert: #ff6b35
     Glass: rgba(0, 128, 128, 0.15)
     Text: #c0e8e0
     Sonar: #00ff88
     Metal: #8a8a8a, #d0d0d0
   Fonts: Orbitron (display), Exo 2 (body), Share Tech Mono (data)
   ========================================================================== */

@property --sonar-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Exo 2', sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    font-weight: 400;
    color: #c0e8e0;
    background: #010213;
    overflow-x: hidden;
}

/* ==========================================================================
   Ocean Background (full viewport, fixed)
   ========================================================================== */

#ocean-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(180deg, #0077b6 0%, #023e8a 30%, #03045e 60%, #010213 100%);
    transition: background 0.3s ease;
}

/* ==========================================================================
   Bioluminescent Particles
   ========================================================================== */

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    filter: blur(1px);
    opacity: 0;
    animation: particle-drift linear infinite;
}

@keyframes particle-drift {
    0% {
        transform: translate(0, 0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translate(var(--dx), var(--dy));
        opacity: 0;
    }
}

/* ==========================================================================
   Depth Gauge (fixed left side)
   ========================================================================== */

#depth-gauge {
    position: fixed;
    left: 16px;
    top: 70px;
    bottom: 30px;
    width: 40px;
    z-index: 100;
    display: flex;
    gap: 4px;
}

#depth-gauge-track {
    position: relative;
    width: 8px;
    height: 100%;
    background: rgba(0, 128, 128, 0.2);
    border: 1px solid rgba(0, 255, 204, 0.2);
    border-radius: 4px;
    overflow: visible;
}

#depth-gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, #0077b6, #023e8a, #03045e, #010213);
    border-radius: 4px;
    transition: height 0.1s linear;
}

#depth-gauge-marker {
    position: absolute;
    top: 0%;
    left: -4px;
    width: 16px;
    height: 3px;
    background: #00ffcc;
    border-radius: 2px;
    box-shadow: 0 0 8px #00ffcc, 0 0 16px rgba(0, 255, 204, 0.4);
    transition: top 0.1s linear;
}

#depth-gauge-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 0;
}

.gauge-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.55rem;
    color: rgba(0, 255, 204, 0.5);
    white-space: nowrap;
}

/* ==========================================================================
   Sonar Display (fixed bottom-right)
   ========================================================================== */

#sonar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(0, 20, 20, 0.8);
    border: 2px solid rgba(0, 255, 136, 0.3);
    z-index: 100;
    overflow: hidden;
}

#sonar-sweep {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from var(--sonar-angle), rgba(0, 255, 136, 0.4) 0deg, transparent 30deg, transparent 360deg);
    animation: sonar-rotate 3s linear infinite;
}

@keyframes sonar-rotate {
    from { --sonar-angle: 0deg; }
    to { --sonar-angle: 360deg; }
}

#sonar-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #00ff88;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px #00ff88;
}

#sonar-ring-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 50%;
    border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#sonar-ring-outer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    border: 1px solid rgba(0, 255, 136, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Cross-hairs */
#sonar::before,
#sonar::after {
    content: '';
    position: absolute;
    background: rgba(0, 255, 136, 0.08);
}
#sonar::before {
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
}
#sonar::after {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: translateY(-50%);
}

#sonar-blips {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sonar-blip {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 6px #00ff88, 0 0 12px rgba(0, 255, 136, 0.5);
    transform: translate(-50%, -50%);
    animation: blip-fade 3s ease-out forwards;
}

@keyframes blip-fade {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
}

/* ==========================================================================
   Instrument Bar (fixed top)
   ========================================================================== */

#instrument-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
    background: rgba(1, 2, 19, 0.85);
    border-bottom: 1px solid rgba(0, 255, 204, 0.15);
    backdrop-filter: blur(8px);
    padding: 0 80px;
}

.instrument {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.instrument-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(0, 255, 204, 0.5);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.instrument-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    color: #00ffcc;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

#dive-content {
    position: relative;
    z-index: 10;
}

.dive-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 80px 40px;
    gap: 40px;
}

/* ==========================================================================
   Porthole (Hero)
   ========================================================================== */

#hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#porthole {
    position: relative;
    width: 80vmin;
    height: 80vmin;
    max-width: 600px;
    max-height: 600px;
}

#porthole-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #8a8a8a 0%, #d0d0d0 40%, #8a8a8a 70%, #6a6a6a 100%);
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.6),
        inset 0 0 20px rgba(0, 0, 0, 0.3),
        0 0 60px rgba(0, 128, 128, 0.15);
}

/* Rivets */
.rivet {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #d0d0d0, #6a6a6a);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
    top: 50%;
    left: 50%;
    transform: rotate(var(--angle)) translateY(calc(-80vmin / 2 + 8px)) translate(-50%, -50%);
}

@media (min-width: 600px) {
    .rivet {
        transform: rotate(var(--angle)) translateY(calc(-300px + 8px)) translate(-50%, -50%);
    }
}

#porthole-glass {
    position: absolute;
    top: 6%;
    left: 6%;
    width: 88%;
    height: 88%;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(180deg, #0077b6 0%, #023e8a 50%, #03045e 100%);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4);
}

#porthole-water {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 30% 20%, rgba(0, 255, 204, 0.08), transparent 60%);
}

#porthole-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 20px;
}

#site-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 700;
    color: #c0e8e0;
    text-shadow: 0 0 20px rgba(0, 255, 204, 0.4), 0 0 40px rgba(0, 255, 204, 0.15);
    letter-spacing: 0.08em;
}

#site-subtitle {
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: rgba(192, 232, 224, 0.7);
    font-weight: 400;
}

#dive-status {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: #00ffcc;
    letter-spacing: 0.2em;
    margin-top: 16px;
    animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#dive-instruction {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: rgba(0, 255, 204, 0.4);
    letter-spacing: 0.15em;
    margin-top: 8px;
    animation: instruction-pulse 3s ease-in-out infinite;
}

@keyframes instruction-pulse {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 0.8; transform: translateY(4px); }
}

/* ==========================================================================
   HUD Panels
   ========================================================================== */

.hud-panel {
    backdrop-filter: blur(12px);
    background: rgba(0, 128, 128, 0.12);
    border: 1px solid rgba(0, 255, 204, 0.3);
    border-radius: 12px;
    padding: 24px;
    max-width: 520px;
    width: 100%;
    position: sticky;
    top: 80px;
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.hud-panel.visible {
    opacity: 1;
    transform: translateX(0);
}

.hud-panel-right {
    align-self: flex-end;
    transform: translateX(40px);
}

.hud-panel-right.visible {
    transform: translateX(0);
}

.hud-panel-center {
    align-self: center;
    transform: translateY(30px);
}

.hud-panel-center.visible {
    transform: translateY(0);
}

.hud-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 255, 204, 0.15);
}

.hud-panel-id {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    color: rgba(0, 255, 204, 0.5);
    letter-spacing: 0.1em;
    padding: 2px 8px;
    border: 1px solid rgba(0, 255, 204, 0.2);
    border-radius: 3px;
}

.hud-panel-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 700;
    color: #c0e8e0;
    letter-spacing: 0.08em;
}

.hud-panel-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-data {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    display: flex;
    gap: 8px;
}

.data-label {
    color: rgba(0, 255, 204, 0.5);
}

.data-value {
    color: #00ffcc;
}

.hud-text {
    font-family: 'Exo 2', sans-serif;
    font-size: 0.9rem;
    line-height: 1.65;
    color: #c0e8e0;
    margin-top: 4px;
}

/* ==========================================================================
   Creature Panels
   ========================================================================== */

.creature-panel {
    max-width: 400px;
}

.creature-entry {
    display: flex;
    align-items: center;
    gap: 16px;
}

.creature-porthole {
    width: 80px;
    height: 80px;
    min-width: 80px;
    border-radius: 50%;
    background: rgba(0, 20, 20, 0.6);
    border: 2px solid rgba(0, 255, 204, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.creature-svg {
    width: 60px;
    height: 60px;
}

.creature-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.creature-name {
    font-family: 'Exo 2', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    font-style: italic;
    color: #c0e8e0;
}

.creature-common {
    font-family: 'Exo 2', sans-serif;
    font-size: 0.8rem;
    color: rgba(192, 232, 224, 0.6);
}

.creature-depth {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.7rem;
    color: #00ffcc;
    margin-top: 2px;
}

/* ==========================================================================
   Dive Complete
   ========================================================================== */

#dive-complete {
    margin-top: 60px;
}

#final-message {
    font-size: 1rem;
    text-align: center;
    margin-top: 12px;
    color: rgba(192, 232, 224, 0.8);
    line-height: 1.8;
}

#final-depth-readout {
    font-family: 'Share Tech Mono', monospace;
    color: #00ffcc;
    text-align: center;
}

/* ==========================================================================
   Alert color for warnings (used by JS)
   ========================================================================== */

.alert-value {
    color: #ff6b35;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .dive-section {
        padding: 80px 20px 40px;
    }

    #depth-gauge {
        left: 6px;
        width: 30px;
    }

    .gauge-label {
        font-size: 0.45rem;
    }

    #instrument-bar {
        gap: 12px;
        padding: 0 16px;
        height: 48px;
    }

    .instrument-label {
        font-size: 0.45rem;
    }

    .instrument-value {
        font-size: 0.7rem;
    }

    #sonar {
        width: 80px;
        height: 80px;
        bottom: 12px;
        right: 12px;
    }

    #porthole {
        width: 85vmin;
        height: 85vmin;
    }

    .hud-panel {
        max-width: 100%;
        padding: 16px;
    }

    .hud-panel-right {
        align-self: center;
    }
}

@media (max-width: 480px) {
    #instrument-bar {
        gap: 6px;
        padding: 0 8px;
    }

    .instrument-label {
        font-size: 0.4rem;
    }

    .instrument-value {
        font-size: 0.6rem;
    }

    #depth-gauge {
        display: none;
    }
}
