/* CSS Variables: Modern Dark Theme */
:root {
    --bg-base: #050505;
    --bg-surface: #0f0f0f;
    --bg-elevated: #1a1a1a;
    --text-main: #f4f4f5;
    --text-muted: #8b8b90;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.15);
    --border: #222222;
    --border-hover: #333333;
    --danger: #ef4444;

    /* Typography Stack: Monospace for Eng/Num, Malgun Gothic for Korean */
    --font-mono: 'Consolas', 'Courier New', Courier, monospace;
    --font-kor: '맑은 고딕', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Combines both requirements: English uses mono, Korean falls back to Malgun Gothic */
    font-family: var(--font-mono), var(--font-kor);
    letter-spacing: -0.02em;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 185, 129, 0.45);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(16, 185, 129, 0.2) transparent;
}

/* Global Reset (Mobile-First Default) */
body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    background-image: linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: center center;
}

#app-root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* Animations */
@keyframes revealUp {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.anim-reveal {
    opacity: 0;
    animation: revealUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

/* Layout Structure: Navigation & Aside (Mobile-First Default) */
aside {
    width: 100%;
    height: auto;
    position: relative;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

aside .brand-header {
    padding: 1rem;
    cursor: default;
}

aside .brand-title {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
}

aside .brand-logo {
    width: 24px !important;
    height: 24px !important;
}

aside .brand-title p {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-main);
    letter-spacing: 0.05em;
    align-self: center;
}

aside .brand-subtitle {
    display: none;
}

aside .nav-menu {
    display: none;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 1.5rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    position: relative;
    text-decoration: none;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: var(--accent);
    transform: scaleY(0);
    transition: transform 0.3s ease;
    transform-origin: center;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: var(--bg-surface);
}

.nav-item.active {
    color: var(--accent);
    background-color: var(--accent-glow);
}

.nav-item.active::before {
    transform: scaleY(1);
}

/* Mobile Command Menu Trigger */
.mobile-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    z-index: 10000;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.05);
}

.mobile-menu-trigger:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.cursor-prompt {
    animation: blink-cursor 1s infinite step-end;
}

@keyframes blink-cursor {
    from, to { color: transparent }
    50% { color: var(--accent) }
}

/* Active State: Mobile Terminal Command Menu Overlay */
aside.menu-open {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 5, 5, 0.98);
    backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 1rem;
    border-bottom: none;
    overflow-y: auto;
}

aside.menu-open .brand-header {
    width: 100%;
    padding: 0 0 1rem 0;
    border-bottom: 1px dashed var(--border);
}

aside.menu-open .nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 2rem;
    padding: 0;
}

aside.menu-open .nav-item {
    opacity: 0;
    padding: 1rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    animation: revealUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Replace desktop vertical bar highlight with a CLI prompt prefix */
aside.menu-open .nav-item::before {
    content: '>';
    color: var(--accent);
    position: static;
    width: auto;
    height: auto;
    background-color: transparent;
    transform: none;
    display: inline;
    margin-right: 0.8rem;
    font-weight: bold;
    transition: transform 0.2s ease;
}

aside.menu-open .nav-item:hover::before,
aside.menu-open .nav-item.active::before {
    transform: translateX(4px);
}

aside.menu-open .nav-item:hover,
aside.menu-open .nav-item.active {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.12);
}

/* Staggered entry animation delay for menu items */
aside.menu-open .nav-item:nth-child(1) { animation-delay: 0.05s; }
aside.menu-open .nav-item:nth-child(2) { animation-delay: 0.1s; }
aside.menu-open .nav-item:nth-child(3) { animation-delay: 0.15s; }
aside.menu-open .nav-item:nth-child(4) { animation-delay: 0.2s; }
aside.menu-open .nav-item:nth-child(5) { animation-delay: 0.25s; }
aside.menu-open .nav-item:nth-child(6) { animation-delay: 0.3s; }
aside.menu-open .nav-item:nth-child(7) { animation-delay: 0.35s; }

/* Main Area & Container (Mobile-First Default) */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 60px - 120px);
    background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.03), transparent 50%);
}

main {
    flex: 1;
    padding: 2rem 1rem 180px 1rem;
    overflow-y: visible; /* Let body handle scrolling on mobile */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.content-wrapper {
    width: 100%;
    max-width: 960px;
    position: relative;
    padding-bottom: 20px; /* Mobile/Tablet base spacer */
}

/* Module Content Styles */
.module-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background-color: var(--accent-glow);
    color: var(--accent);
    font-size: 0.7rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.module-title {
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 2rem;
    font-weight: 300;
}

/* Information Cards */
.info-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.info-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.05);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-desc {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Details & Summary Collapsible UI */
details {
    margin-bottom: 1.5rem;
}

summary, summary.card-title {
    list-style: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0;
    padding: 1rem 1.5rem;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.2s ease;
    user-select: none;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: "▶";
    font-size: 0.8rem;
    color: var(--accent);
    transition: transform 0.2s ease;
}

details[open] summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 1px dashed var(--border);
}

details[open] summary::before {
    transform: rotate(90deg);
}

details .collapse-content {
    background-color: rgba(26, 26, 26, 0.5);
    border: 1px solid var(--border);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 1.5rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.card-title.accent {
    color: var(--accent);
}

.card-title.danger {
    color: var(--danger);
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    font-family: var(--font-kor);
}

/* Bottom Control Bar */
.control-bar {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-prev {
    color: var(--text-muted);
    border-color: transparent;
}

.btn-prev:hover:not(:disabled) {
    color: var(--text-main);
    background-color: var(--bg-surface);
}

.btn-next {
    background-color: var(--text-main);
    color: #000;
    border-color: var(--text-main);
}

.btn-next:hover:not(:disabled) {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-finish {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-finish.ready {
    background-color: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Radar Canvas Aspect Ratio (Mobile-First Default) */
#vigfoot-map {
    height: 300px !important;
    min-height: 220px !important;
    margin-top: 10px !important;
}

/* Autopilot & Telemetry Panels (Mobile-First Default) */
.anim-reveal.delay-3 {
    flex-direction: column;
}

#autopilot-panel {
    width: 100% !important;
    min-width: 100% !important;
    border-right: none !important;
    border-bottom: 1px dashed var(--border) !important;
}

#telemetry-panel {
    width: 100% !important;
}

/* Logger Bar (Mobile-First Default) */
.logger-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    gap: 0.5rem;
    margin-top: 0;
    height: 180px;
    overflow: hidden;
}

#logger-feed {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

#vigfoot-map {
    position: relative;
}

#vessel-stowage-hud {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 140px;
    background: rgba(10, 15, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px 4px 24px 24px;
    padding: 8px 8px 12px 8px;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

#vessel-stowage-hud > div[style*="grid-template-columns"] {
    grid-template-columns: repeat(6, 14%) !important;
    gap: 3px;
    padding: 0;
}

.compact-title {
    font-size: 0.95rem !important;
}

@keyframes alert-blink {
    0% { background-color: rgba(239, 68, 68, 0.1); color: #fca5a5; }
    50% { background-color: rgba(239, 68, 68, 0.4); color: #fff; }
    100% { background-color: rgba(239, 68, 68, 0.1); color: #fca5a5; }
}

.alert-danger {
    animation: alert-blink 0.8s infinite;
    border-color: #ef4444 !important;
}

.log-entry {
    display: flex;
    gap: 0.8rem;
    animation: fadeIn 0.2s ease-out forwards;
}

.log-time {
    color: #52525b;
    flex-shrink: 0;
}

.log-msg {
    color: var(--text-muted);
}

.log-msg.highlight {
    color: var(--accent);
}

/* Highlight only the latest log for better readability */
.log-entry:last-child .log-msg {
    color: var(--text-main);
}

/* Live Telemetry Wave Visualizer */
.live-wave {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--accent);
    background: transparent;
    padding: 0.5rem 0 0 0;
    margin-top: 0.5rem;
    width: max-content;
    pointer-events: none;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse-dot-anim 1.5s infinite;
}

@keyframes pulse-dot-anim {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.4);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.wave-svg {
    width: 50px;
    height: 10px;
}

.wave-path {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: wave-move 4s linear infinite;
}

@keyframes wave-move {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}


/* --- Desktop Layout overrides (min-width: 1200px) --- */
@media (min-width: 1200px) {
    body {
        flex-direction: row;
        overflow: hidden;
        height: 100vh;
    }

    /* CRT Scanline & Phosphor Flicker Overlay (Desktop Only) */
    body::after {
        content: " ";
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;
        background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%);
        background-size: 100% 4px;
        z-index: 99999;
        pointer-events: none;
        opacity: 0.3;
        animation: screen-flicker 0.15s infinite;
    }

    @keyframes screen-flicker {
        0% {
            opacity: 0.28;
        }
        50% {
            opacity: 0.32;
        }
        100% {
            opacity: 0.28;
        }
    }

    #app-root {
        flex-direction: row;
    }

    aside {
        width: 280px;
        height: 100vh;
        border-bottom: none;
        border-right: 1px solid var(--border);
    }

    aside .brand-header {
        padding: 2rem 1.5rem;
        border-bottom: 1px solid var(--border);
    }

    aside .brand-title {
        flex-wrap: wrap;
    }

    aside .brand-logo {
        width: auto !important;
        height: auto !important;
    }

    aside .brand-title p {
        font-size: 1.2rem;
    }

    aside .brand-subtitle {
        display: block;
        font-size: 0.7rem;
        color: var(--text-muted);
        margin-top: 0.5rem;
        text-transform: uppercase;
    }

    aside .nav-menu {
        display: flex;
        flex: 1;
        padding: 1.5rem 0;
        flex-direction: column;
        gap: 0.25rem;
    }

    .mobile-menu-trigger {
        display: none;
    }

    .main-container {
        height: 100vh;
        min-height: 0;
    }

    main {
        padding: 3rem 2rem;
        padding-bottom: 140px; /* Space for fixed logger-bar */
        overflow-y: auto;
    }

    .content-wrapper {
        padding-bottom: 160px; /* Desktop fixed logger-bar space */
    }

    /* Desktop Radar Canvas Scale */
    #vigfoot-map {
        height: 450px !important;
        aspect-ratio: auto !important;
    }

    /* Desktop Telemetry & Autopilot Row Layout */
    .anim-reveal.delay-3 {
        flex-direction: row !important;
    }

    #autopilot-panel {
        width: auto !important;
        flex: 0.9 !important;
        min-width: 240px !important;
        border-right: 1px dashed var(--border) !important;
        border-bottom: none !important;
    }

    #telemetry-panel {
        width: auto !important;
        flex: 2 !important;
    }

    /* Desktop Logger Bar Fixed Layout */
    .logger-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 280px !important;
        width: calc(100% - 280px) !important;
        height: 120px !important;
        min-height: 0 !important;
        flex-direction: row !important;
        border: none !important;
        border-top: 1px solid var(--border) !important;
        border-radius: 0 !important;
        padding: 1rem 1.5rem !important;
        gap: 0.3rem !important;
        margin-top: 0 !important;
        overflow-y: hidden !important;
    }


}
