/* ============================================
   BBATTL.com - Deep Ocean Command Interface
   Seapunk Command Center Aesthetic
   ============================================ */

/* CSS Custom Properties */
:root {
    --depth-primary: #0B3D4E;
    --coral-signal: #D4426E;
    --phosphor-gold: #D4A843;
    --midnight-ocean: #060E18;
    --surface-glass: #0F2A3A;
    --text-primary: #E8F0F2;
    --text-secondary: #C8E6F5;
    --glow-accent: #00F5D4;
    --abyssal-slate: #1A2F3D;

    --ease-water: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --cell-radius: 2px;
    --gutter: 16px;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    background: var(--midnight-ocean);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.65;
}

::selection {
    background: var(--midnight-ocean);
    color: var(--coral-signal);
}

/* Scan-line overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 245, 212, 0.03) 3px,
        rgba(0, 245, 212, 0.03) 4px
    );
    opacity: 0;
    transition: opacity 1.5s var(--ease-water);
}

body.booted::after {
    opacity: 1;
}

/* Isometric grid underlay */
#grid-underlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

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

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--glow-accent);
    border-radius: 50%;
    opacity: 0;
    animation: float-up linear infinite;
}

@keyframes float-up {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100vh) translateX(20px);
        opacity: 0;
    }
}

/* HUD Frame */
#hud-frame {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    padding: 32px 24px 24px;
    border: 1px solid var(--abyssal-slate);
    margin: 8px;
    opacity: 0;
    transition: opacity 1s var(--ease-water);
}

body.booted #hud-frame {
    opacity: 1;
}

/* HUD corner brackets */
.hud-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    z-index: 20;
}

.hud-corner::before,
.hud-corner::after {
    content: '';
    position: absolute;
    background: var(--glow-accent);
}

.hud-corner-tl { top: -1px; left: -1px; }
.hud-corner-tl::before { top: 0; left: 0; width: 24px; height: 2px; }
.hud-corner-tl::after { top: 0; left: 0; width: 2px; height: 24px; }

.hud-corner-tr { top: -1px; right: -1px; }
.hud-corner-tr::before { top: 0; right: 0; width: 24px; height: 2px; }
.hud-corner-tr::after { top: 0; right: 0; width: 2px; height: 24px; }

.hud-corner-bl { bottom: -1px; left: -1px; }
.hud-corner-bl::before { bottom: 0; left: 0; width: 24px; height: 2px; }
.hud-corner-bl::after { bottom: 0; left: 0; width: 2px; height: 24px; }

.hud-corner-br { bottom: -1px; right: -1px; }
.hud-corner-br::before { bottom: 0; right: 0; width: 24px; height: 2px; }
.hud-corner-br::after { bottom: 0; right: 0; width: 2px; height: 24px; }

/* Coordinate Bar */
#coordinate-bar {
    height: 32px;
    overflow: hidden;
    background: rgba(11, 61, 78, 0.4);
    border-bottom: 1px solid var(--abyssal-slate);
    margin: -32px -24px 16px -24px;
    padding: 0;
    display: flex;
    align-items: center;
    backdrop-filter: blur(8px);
}

.coordinate-scroll {
    display: flex;
    white-space: nowrap;
    animation: marquee 60s linear infinite;
}

.coord-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.15em;
    color: var(--glow-accent);
    padding: 0 40px;
    flex-shrink: 0;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Bento Grid */
#bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, minmax(180px, auto));
    grid-template-areas:
        "hero   hero   sonar  typo"
        "hero   hero   compass depth"
        "icon1  icon2  data   wave";
    gap: var(--gutter);
    padding: 0;
}

/* Bento Cell Base */
.bento-cell {
    position: relative;
    background: var(--depth-primary);
    border: 1px solid var(--abyssal-slate);
    border-radius: var(--cell-radius);
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s var(--ease-water);
    backdrop-filter: blur(8px);
}

.bento-cell.visible {
    opacity: 1;
    transform: translateY(0);
}

.bento-cell:hover {
    border-color: var(--glow-accent);
    box-shadow: inset 0 0 30px rgba(0, 245, 212, 0.08);
}

.bento-cell:hover .cell-corner::before,
.bento-cell:hover .cell-corner::after {
    background: var(--glow-accent);
}

.bento-cell:hover .cell-corner-tl { transform: translate(-4px, -4px); }
.bento-cell:hover .cell-corner-tr { transform: translate(4px, -4px); }
.bento-cell:hover .cell-corner-bl { transform: translate(-4px, 4px); }
.bento-cell:hover .cell-corner-br { transform: translate(4px, 4px); }

/* Cell corner brackets */
.cell-corner {
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 5;
    transition: transform 0.4s var(--ease-water);
}

.cell-corner::before,
.cell-corner::after {
    content: '';
    position: absolute;
    background: var(--glow-accent);
    opacity: 0.5;
    transition: all 0.4s var(--ease-water);
}

.cell-corner-tl { top: 4px; left: 4px; }
.cell-corner-tl::before { top: 0; left: 0; width: 16px; height: 1px; }
.cell-corner-tl::after { top: 0; left: 0; width: 1px; height: 16px; }

.cell-corner-tr { top: 4px; right: 4px; }
.cell-corner-tr::before { top: 0; right: 0; width: 16px; height: 1px; }
.cell-corner-tr::after { top: 0; right: 0; width: 1px; height: 16px; }

.cell-corner-bl { bottom: 4px; left: 4px; }
.cell-corner-bl::before { bottom: 0; left: 0; width: 16px; height: 1px; }
.cell-corner-bl::after { bottom: 0; left: 0; width: 1px; height: 16px; }

.cell-corner-br { bottom: 4px; right: 4px; }
.cell-corner-br::before { bottom: 0; right: 0; width: 16px; height: 1px; }
.cell-corner-br::after { bottom: 0; right: 0; width: 1px; height: 16px; }

/* Cell content wrapper */
.cell-content {
    position: relative;
    z-index: 2;
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cell-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--glow-accent);
    opacity: 0.7;
    text-transform: uppercase;
    margin-top: auto;
    padding-top: 12px;
}

/* Grid Area Assignments */
.cell-hero    { grid-area: hero; }
.cell-sonar   { grid-area: sonar; }
.cell-typo    { grid-area: typo; }
.cell-compass { grid-area: compass; }
.cell-depth   { grid-area: depth; }
.cell-icon-1  { grid-area: icon1; }
.cell-icon-2  { grid-area: icon2; }
.cell-data    { grid-area: data; }
.cell-wave    { grid-area: wave; }

/* =====================
   HERO CELL
   ===================== */
.cell-hero {
    background: linear-gradient(135deg, var(--depth-primary), var(--surface-glass));
}

.jellyfish-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}

.jellyfish-orb {
    position: absolute;
    border-radius: 50% 50% 40% 40%;
    background: radial-gradient(ellipse at center, rgba(0, 245, 212, 0.12), rgba(0, 245, 212, 0.02), transparent);
    filter: blur(2px);
    animation: jellyfish-pulse 6s ease-in-out infinite;
}

@keyframes jellyfish-pulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-20px) scale(1.05);
        opacity: 0.5;
    }
}

.hero-content {
    position: relative;
    z-index: 3;
    justify-content: center;
    align-items: flex-start;
}

.hero-title {
    font-family: 'EB Garamond', serif;
    font-size: clamp(2rem, 5vw, 4.5rem);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-shadow: 0 0 40px rgba(0, 245, 212, 0.15);
}

.hero-subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--glow-accent);
    margin-bottom: 24px;
}

.hero-body {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.65;
    color: var(--text-secondary);
    opacity: 0.85;
    max-width: 480px;
    margin-bottom: 32px;
}

.hero-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--abyssal-slate);
}

.status-dot.active {
    background: var(--glow-accent);
    box-shadow: 0 0 8px var(--glow-accent);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--glow-accent); }
    50% { opacity: 0.5; box-shadow: 0 0 16px var(--glow-accent); }
}

.status-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--glow-accent);
}

/* =====================
   SONAR CELL
   ===================== */
.cell-sonar {
    background: var(--surface-glass);
}

.sonar-container {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 12px;
}

.sonar-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--glow-accent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sonar-ring-1 { width: 120px; height: 120px; opacity: 0.15; }
.sonar-ring-2 { width: 90px; height: 90px; opacity: 0.2; }
.sonar-ring-3 { width: 60px; height: 60px; opacity: 0.25; }
.sonar-ring-4 { width: 30px; height: 30px; opacity: 0.3; }

.sonar-center {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--glow-accent);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px var(--glow-accent);
}

.sonar-sweep {
    position: absolute;
    width: 50%;
    height: 2px;
    top: 50%;
    left: 50%;
    transform-origin: left center;
    background: linear-gradient(to right, var(--glow-accent), transparent);
    animation: sonar-rotate 4s linear infinite;
    opacity: 0.6;
}

@keyframes sonar-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.sonar-blip {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--glow-accent);
    opacity: 0;
    animation: blip-pulse 4s ease-in-out infinite;
}

.blip-1 { top: 25%; left: 65%; animation-delay: 0.5s; }
.blip-2 { top: 60%; left: 30%; animation-delay: 1.8s; }
.blip-3 { top: 40%; left: 75%; animation-delay: 3.1s; }

@keyframes blip-pulse {
    0%, 80%, 100% { opacity: 0; transform: scale(1); }
    10% { opacity: 0.8; transform: scale(1.5); }
    40% { opacity: 0.3; transform: scale(1); }
}

/* =====================
   TYPOGRAPHY CELL
   ===================== */
.cell-typo {
    background: linear-gradient(180deg, var(--depth-primary), var(--surface-glass));
}

.typo-heading {
    font-family: 'EB Garamond', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.typo-body {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    opacity: 0.85;
    margin-bottom: 16px;
}

.typo-mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--glow-accent);
    opacity: 0.6;
}

/* =====================
   COMPASS CELL
   ===================== */
.cell-compass {
    background: var(--surface-glass);
}

.compass-container {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 8px;
}

.compass-svg {
    width: 100%;
    height: 100%;
    animation: compass-drift 20s ease-in-out infinite;
}

@keyframes compass-drift {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(3deg); }
    75% { transform: rotate(-2deg); }
}

/* =====================
   DEPTH GAUGE CELL
   ===================== */
.cell-depth {
    background: var(--surface-glass);
}

.depth-gauge {
    display: flex;
    gap: 12px;
    align-items: stretch;
    height: 120px;
    margin-bottom: 8px;
}

.depth-track {
    width: 12px;
    background: var(--midnight-ocean);
    border: 1px solid var(--abyssal-slate);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.depth-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, var(--coral-signal), var(--glow-accent));
    border-radius: 1px;
    transition: height 2s var(--ease-water);
}

.depth-markers {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* =====================
   ISOMETRIC ICON CELLS
   ===================== */
.cell-icon-1, .cell-icon-2 {
    background: var(--depth-primary);
}

.iso-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 8px;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(6, 14, 24, 0.6));
}

.cell-icon-1 .cell-content,
.cell-icon-2 .cell-content {
    align-items: center;
    text-align: center;
}

/* =====================
   DATA STREAM CELL
   ===================== */
.cell-data {
    background: var(--surface-glass);
}

.data-stream {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.data-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(26, 47, 61, 0.5);
}

.data-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    opacity: 0.7;
}

.data-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--glow-accent);
}

/* =====================
   WAVEFORM CELL
   ===================== */
.cell-wave {
    background: var(--depth-primary);
}

#waveform-canvas {
    width: 100%;
    height: 100px;
    margin-bottom: 8px;
}

/* =====================
   BOTTOM BAR
   ===================== */
#bottom-bar {
    display: flex;
    justify-content: space-between;
    padding: 12px 0 0;
    margin-top: var(--gutter);
    border-top: 1px solid var(--abyssal-slate);
}

.hud-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--glow-accent);
    opacity: 0.5;
}

/* =====================
   BOOT SEQUENCE
   ===================== */
body.booting #hud-frame {
    opacity: 0;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 900px) {
    #bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        grid-template-areas:
            "hero   hero"
            "sonar  typo"
            "compass depth"
            "icon1  icon2"
            "data   wave";
    }
}

@media (max-width: 560px) {
    #bento-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "hero"
            "sonar"
            "typo"
            "compass"
            "depth"
            "icon1"
            "icon2"
            "data"
            "wave";
    }

    #bottom-bar {
        flex-direction: column;
        gap: 4px;
        align-items: center;
    }

    #hud-frame {
        padding: 32px 12px 12px;
    }
}

/* =====================
   GUTTER GRADIENT ANIMATION
   ===================== */
#bento-grid {
    background: linear-gradient(135deg, var(--midnight-ocean), var(--depth-primary));
    background-size: 200% 200%;
    animation: gutter-shift 15s ease-in-out infinite;
    padding: var(--gutter);
    border-radius: var(--cell-radius);
}

@keyframes gutter-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .particle,
    .sonar-sweep,
    .sonar-blip,
    .compass-svg,
    .coordinate-scroll,
    .jellyfish-orb {
        animation: none;
    }

    .bento-cell {
        transition: none;
    }

    body::after {
        transition: none;
    }
}
