/* =============================================
   PUMP FOIL PHYSICS - Hydrodynamic Laboratory
   Deep ocean aesthetic with synchronized animations
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Saira:wght@300;400;600;700;900&family=Exo+2:wght@300;400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap');

:root {
    /* Deep Ocean Color System */
    --ocean-deep: #0a1628;
    --ocean-mid: #0d1b2a;
    --ocean-surface: #1b263b;
    --ocean-light: #415a77;

    /* Cyan Spectrum */
    --cyan-primary: #00d9ff;
    --cyan-bright: #00ffff;
    --cyan-glow: #4dffd2;
    --cyan-accent: #00ffc8;

    /* Status Colors */
    --status-optimal: #00ff88;
    --status-warning: #ffba08;
    --status-danger: #ff006e;

    /* Typography */
    --font-display: 'Saira', sans-serif;
    --font-body: 'Exo 2', sans-serif;
    --font-mono: 'Fira Code', monospace;

    /* Effects */
    --glow-cyan: 0 0 20px rgba(0, 217, 255, 0.6), 0 0 40px rgba(0, 217, 255, 0.3);
    --glow-strong: 0 0 30px rgba(0, 255, 200, 0.8), 0 0 60px rgba(0, 255, 200, 0.4);
    --panel-glass: rgba(27, 38, 59, 0.85);
}

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

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

body {
    font-family: var(--font-body);
    background: var(--ocean-deep);
    color: #e0f4ff;
    line-height: 1.5;
    position: relative;
}

/* =============================================
   ANIMATED BACKGROUND
   ============================================= */
.ocean-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: linear-gradient(135deg,
        var(--ocean-deep) 0%,
        var(--ocean-mid) 30%,
        #0e2a47 60%,
        var(--ocean-surface) 100%
    );
    animation: gradientShift 20s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

#particleCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.3;
}

/* =============================================
   LAYOUT STRUCTURE
   ============================================= */
.app-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.main-header {
    background: var(--panel-glass);
    backdrop-filter: blur(20px);
    border-bottom: 2px solid rgba(0, 217, 255, 0.2);
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.title-main {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    color: #fff;
    text-shadow: var(--glow-cyan);
}

.title-sub {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    letter-spacing: 0.2em;
    color: var(--cyan-glow);
    text-transform: uppercase;
}

/* Phase Indicator Compact */
.phase-indicator-compact {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.phase-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 217, 255, 0.2);
    border: 2px solid rgba(0, 217, 255, 0.4);
    transition: all 0.3s ease;
}

.phase-dot.active {
    background: var(--cyan-primary);
    border-color: var(--cyan-bright);
    box-shadow: var(--glow-cyan);
    transform: scale(1.3);
}

/* Main Layout */
.main-layout {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 320px 1fr 320px;
    gap: 2rem;
    flex: 1;
}

/* =============================================
   CONTROL PANEL (LEFT)
   ============================================= */
.control-panel {
    background: var(--panel-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: 16px;
    padding: 2rem;
    height: fit-content;
    position: sticky;
    top: 120px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(0, 217, 255, 0.2);
}

.panel-header h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--cyan-primary);
}

.btn-play-pause {
    background: rgba(0, 217, 255, 0.1);
    border: 2px solid var(--cyan-primary);
    color: var(--cyan-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-play-pause:hover {
    background: var(--cyan-primary);
    color: var(--ocean-deep);
    box-shadow: var(--glow-cyan);
    transform: scale(1.1);
}

/* Control Groups */
.control-group {
    margin-bottom: 2rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.label-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #a0c4d4;
}

.label-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--cyan-primary);
}

.slider {
    width: 100%;
    height: 6px;
    background: rgba(65, 90, 119, 0.4);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    margin: 0.5rem 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--cyan-primary), var(--cyan-glow));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--glow-cyan);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--glow-strong);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--cyan-primary), var(--cyan-glow));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--glow-cyan);
}

.control-hint {
    font-size: 0.75rem;
    color: #6b8a9e;
    font-style: italic;
    margin-top: 0.5rem;
}

/* Strouhal Display */
.strouhal-display {
    margin-top: 2.5rem;
    padding: 1.5rem;
    background: rgba(0, 217, 255, 0.05);
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 12px;
}

.strouhal-label {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #a0c4d4;
    margin-bottom: 0.5rem;
}

.strouhal-value {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 900;
    color: var(--cyan-primary);
    text-shadow: var(--glow-cyan);
    margin-bottom: 1rem;
}

.strouhal-gauge {
    position: relative;
    height: 12px;
    margin: 1.5rem 0;
}

.gauge-zones {
    display: flex;
    height: 100%;
    border-radius: 6px;
    overflow: hidden;
}

.zone {
    flex: 1;
}

.zone-low {
    background: linear-gradient(90deg, var(--status-danger), #ff4488);
}

.zone-optimal {
    background: var(--status-optimal);
}

.zone-high {
    background: linear-gradient(90deg, #ff8800, var(--status-warning));
}

.gauge-needle {
    position: absolute;
    top: -4px;
    left: 50%;
    width: 4px;
    height: 20px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    transform: translateX(-50%);
    transition: left 0.3s ease;
}

.strouhal-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--status-optimal);
    font-weight: 600;
    margin-top: 0.75rem;
}

/* =============================================
   VISUALIZATION AREA (CENTER)
   ============================================= */
.visualization-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Phase Banner */
.phase-banner {
    background: linear-gradient(135deg, var(--panel-glass), rgba(0, 217, 255, 0.1));
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.phase-number {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--cyan-primary);
}

.phase-name {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: #fff;
}

.phase-description {
    font-size: 0.95rem;
    color: #a0c4d4;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: rgba(10, 22, 40, 0.6);
    border: 2px solid rgba(0, 217, 255, 0.2);
    border-radius: 16px;
    padding: 2rem;
    overflow: hidden;
}

#pumpCanvas {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

/* Floating Displays */
.aoa-display,
.tilt-display {
    position: absolute;
    background: rgba(0, 217, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid var(--cyan-primary);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.aoa-display {
    top: 2rem;
    right: 2rem;
}

.tilt-display {
    top: 2rem;
    left: 2rem;
}

.aoa-label,
.tilt-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #a0c4d4;
}

.aoa-value,
.tilt-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--cyan-primary);
    text-shadow: var(--glow-cyan);
}

/* Force Graph */
.graph-container {
    background: var(--panel-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.graph-header h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--cyan-primary);
}

.graph-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #a0c4d4;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

#forceGraph {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

/* =============================================
   METRICS PANEL (RIGHT)
   ============================================= */
.metrics-panel {
    background: var(--panel-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: 16px;
    padding: 2rem;
    height: fit-content;
    position: sticky;
    top: 120px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metric-card {
    background: rgba(10, 22, 40, 0.6);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.metric-card:hover {
    border-color: var(--cyan-primary);
    box-shadow: var(--glow-cyan);
    transform: translateY(-2px);
}

.metric-card.highlight {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.1), rgba(0, 217, 255, 0.1));
    border: 2px solid var(--status-optimal);
}

.metric-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #a0c4d4;
}

.metric-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--cyan-primary);
    line-height: 1;
}

.metric-card.highlight .metric-value {
    color: var(--status-optimal);
    text-shadow: var(--glow-strong);
}

.metric-unit {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #6b8a9e;
}

/* Theory Card */
.theory-card {
    background: rgba(0, 217, 255, 0.05);
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.theory-card h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cyan-primary);
    margin-bottom: 1rem;
}

.theory-card p {
    font-size: 0.9rem;
    color: #b0d0e0;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.theory-card ul {
    list-style: none;
    margin: 1rem 0;
}

.theory-card li {
    font-size: 0.85rem;
    color: #a0c4d4;
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.theory-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--cyan-primary);
}

.theory-card strong {
    color: var(--cyan-glow);
    font-weight: 600;
}

.theory-emphasis {
    font-weight: 600;
    color: var(--status-optimal) !important;
    font-style: italic;
}

/* =============================================
   FOOTER
   ============================================= */
.info-footer {
    background: var(--panel-glass);
    backdrop-filter: blur(15px);
    border-top: 2px solid rgba(0, 217, 255, 0.2);
    padding: 2rem;
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.equation-display {
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.eq-label {
    font-size: 0.85rem;
    color: #a0c4d4;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.eq-formula {
    font-size: 1rem;
    color: var(--cyan-primary);
    font-weight: 600;
}

.credit {
    font-size: 0.8rem;
    color: #6b8a9e;
    font-style: italic;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 217, 255, 0.8);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Pulsing effect for active phase */
.phase-dot.active {
    animation: pulse-glow 1s ease-in-out infinite;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1600px) {
    .main-layout {
        grid-template-columns: 280px 1fr 280px;
        gap: 1.5rem;
    }
}

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .control-panel,
    .metrics-panel {
        position: static;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: 1rem;
    }

    .title-main {
        font-size: 1.8rem;
    }

    .main-layout {
        padding: 1rem;
    }

    .aoa-display,
    .tilt-display {
        position: static;
        margin-bottom: 1rem;
    }
}

/* =============================================
   TABS AND NAVIGATION - Hydrodynamic Segmented Control
   ============================================= */
.tab-navigation {
    display: flex;
    gap: 0;
    background: rgba(10, 22, 40, 0.8);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 217, 255, 0.15);
    border-radius: 16px;
    padding: 6px;
    position: relative;
    overflow: hidden;
}

/* Animated background slider */
.tab-navigation::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(50% - 6px);
    height: calc(100% - 12px);
    background: linear-gradient(135deg,
        rgba(0, 217, 255, 0.25) 0%,
        rgba(0, 255, 200, 0.2) 100%);
    border-radius: 12px;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow:
        0 0 20px rgba(0, 217, 255, 0.4),
        inset 0 0 20px rgba(0, 255, 200, 0.2);
    z-index: 0;
}

.tab-navigation.theory-active::before {
    transform: translateX(calc(100% + 6px));
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(160, 196, 212, 0.7);
    padding: 0.85rem 2rem;
    border-radius: 12px;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    position: relative;
    z-index: 1;
    flex: 1;
    white-space: nowrap;
}

.tab-btn:hover:not(.active) {
    color: rgba(0, 217, 255, 0.9);
    transform: scale(1.02);
}

.tab-btn.active {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(0, 217, 255, 0.8);
}

.tab-icon {
    font-size: 1.3rem;
    filter: drop-shadow(0 0 8px rgba(0, 217, 255, 0.5));
    transition: transform 0.3s ease;
}

.tab-btn.active .tab-icon {
    transform: scale(1.15);
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(0, 217, 255, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 15px rgba(0, 255, 200, 0.8));
    }
}

.tab-label {
    text-transform: uppercase;
    font-weight: 700;
}

/* Tab Content */
.tab-content-container {
    width: 100%;
}

.tab-content {
    display: none;
    opacity: 0;
    animation: fadeOut 0.2s ease;
}

.tab-content.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* =============================================
   THEORY PAGE
   ============================================= */
.theory-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.theory-article {
    background: var(--panel-glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: 16px;
    padding: 3rem;
    line-height: 1.8;
}

.theory-article h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 1rem;
    text-shadow: var(--glow-cyan);
}

.theory-article h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--cyan-primary);
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid rgba(0, 217, 255, 0.3);
}

.theory-article h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--cyan-glow);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.theory-article p {
    margin-bottom: 1.5rem;
    color: #e0f4ff;
    font-size: 1.05rem;
}

.theory-article strong {
    color: var(--cyan-primary);
    font-weight: 600;
}

.theory-article ul,
.theory-article ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

.theory-article li {
    margin-bottom: 0.75rem;
    color: #d0e8f5;
}

.theory-article hr {
    border: none;
    border-top: 2px solid rgba(0, 217, 255, 0.2);
    margin: 3rem 0;
}

.theory-article .katex-display {
    margin: 2rem 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.theory-article .katex {
    color: var(--cyan-bright);
}

.theory-article code {
    background: rgba(0, 217, 255, 0.1);
    color: var(--cyan-bright);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.theory-article pre {
    background: rgba(10, 22, 40, 0.8);
    border: 1px solid rgba(0, 217, 255, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.theory-article pre code {
    background: none;
    padding: 0;
}

.loading-theory {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--cyan-primary);
    font-family: var(--font-mono);
    font-size: 1.2rem;
}

/* Make equations more visible */
.theory-article .katex-display {
    background: rgba(0, 217, 255, 0.05);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--cyan-primary);
}

/* Responsive for theory page */
@media (max-width: 768px) {
    .theory-container {
        padding: 1.5rem 1rem;
    }

    .theory-article {
        padding: 2rem 1.5rem;
    }

    .theory-article h1 {
        font-size: 1.8rem;
    }

    .theory-article h2 {
        font-size: 1.4rem;
    }

    .tab-navigation {
        gap: 0.5rem;
    }

    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .tab-icon {
        font-size: 1rem;
    }
}

.phase-indicator-compact {
    transition: opacity 0.3s ease;
}
