/* Global Reset & Background */
body {
    background-color: #0f1115; /* Fallback deep dark minimalist background */
    color: #c9d1d9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    overflow: hidden; /* Prevent scrolling for the full page */
}

/* Mapbox Background */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
}

.container {
    z-index: 1; /* Keep terminal above map */
    pointer-events: none; /* Let clicks pass through empty space to the map */
}

/* Terminal Window Container */
.mac-terminal {
    pointer-events: auto; /* Re-enable pointer events for terminal */
    background-color: rgba(30, 30, 30, 0.75); /* More transparent to see the map */
    backdrop-filter: blur(8px); /* Modern blur effect */
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    max-width: 900px;
    border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle border */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

/* Header with Traffic Light Buttons */
.terminal-header {
    background-color: #2d2e32;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
}

.traffic-lights {
    display: flex;
    gap: 8px;
    z-index: 2; /* Keep above the absolute positioned title */
}

.traffic-lights .dot {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.traffic-lights .dot:hover {
    opacity: 0.8;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot.red { background-color: #ff5f56; box-shadow: 0 0 2px #ff5f56; }
.dot.yellow { background-color: #ffbd2e; box-shadow: 0 0 2px #ffbd2e; }
.dot.green { background-color: #27c93f; box-shadow: 0 0 2px #27c93f; }

/* Header Title (Centered) */
.header-title {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    color: #8b9298;
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: none; /* Allows clicking through to elements below if needed */
}

/* Typography and Layout inside Terminal */
.terminal-body {
    padding: 30px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.8875rem;
    line-height: 1.6;
    height: 60vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    color: #eeeeee; /* Classic Linux terminal light grey/white */
}

/* WebKit: hide scrollbar */
.terminal-body::-webkit-scrollbar {
    display: none;
}

/* Prompt Colors (Linux Bash style) */
.prompt { margin-right: 8px; font-weight: bold; }
.prompt-time { color: #888888; margin-right: 6px; font-weight: normal; } 
.prompt-user { color: #8ae234; } /* Linux Green */
.prompt-dir { color: #729fcf; }  /* Linux Blue */
.prompt-symbol { color: #eeeeee; }

/* Command Line Styling */
.command-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.command-text {
    color: #eeeeee;
    font-weight: normal;
}

/* Styles for interactive terminal inputs */
.terminal-input {
    background: transparent;
    border: none;
    color: #eeeeee;
    font-family: inherit;
    font-size: inherit;
    font-weight: normal;
    outline: none;
    flex-grow: 1;
    padding: 0;
    width: 50%;
    caret-color: #eeeeee;
}

/* Blinking Cursor Animation */
.cursor {
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background-color: #eeeeee;
    vertical-align: middle;
    margin-left: 4px;
    animation: blink 1s step-end infinite;
}

.cursor.inactive {
    display: none;
}

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

/* Fade In Animation for the whole terminal */
.fade-in {
    animation: fadeInWindow 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInWindow {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Minimize & Restore Window Animations */
.mac-terminal.minimized {
    animation: minimizeWindow 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: none; /* Disable interactions while minimized */
}

.mac-terminal.restored {
    animation: restoreWindow 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes minimizeWindow {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(60px) scale(0.85);
    }
}

@keyframes restoreWindow {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Output Text Styles */
.terminal-output {
    color: #eeeeee;
    margin-bottom: 15px;
    opacity: 0;
    animation: textFadeIn 0.5s ease forwards;
}

/* Links inside the terminal: Linux terminal style with a soft halo on hover */
.terminal-body a,
.terminal-output a,
.command-text a {
    color: #34e2e2; /* Cyan */
    text-decoration: none;
    border: none;
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 -4px; /* Adjust margin to compensate for padding */
    transition: all 0.3s ease;
}

.terminal-body a:hover,
.terminal-output a:hover,
.command-text a:hover {
    color: #ffffff;
    background: rgba(52, 226, 226, 0.15);
    box-shadow: 0 0 10px 2px rgba(52, 226, 226, 0.4); /* Soft minimalist halo */
}

@keyframes textFadeIn {
    to { opacity: 1; }
}

/* Instant display for user-triggered command outputs */
.terminal-output.immediate {
    opacity: 1;
    animation: none;
    margin-bottom: 10px;
}

/* Restore Button ("æ") */
.restore-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e6e6e6;
    font-size: 1.4rem;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    padding: 0;
    line-height: 1;
}

.restore-btn:hover {
    background-color: rgba(60, 60, 60, 0.85);
    transform: scale(1.05);
}

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

.restore-btn.hidden {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

/* Marker wrapper: a neutral container that Mapbox will position via inline transform */
/* Reduced to 80% to shrink overall marker size while keeping layout centered */
.pulsing-dot-wrapper {
    width: 22px; /* 28px * 0.8 ≈ 22px */
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

/* Pulsing Dot Marker (visual element only) */
/* Core dot reduced to 80% of original (12px -> ~10px) with same styling and pulse behavior */
.pulsing-dot {
    width: 10px; /* ~80% of 12px */
    height: 10px;
    background-color: rgba(255,255,255,0.5); /* 50% translucent white core */
    border-radius: 50%;
    position: relative;
    box-shadow: none;
    cursor: pointer;
    transform-origin: center center;
    /* default values; will be overridden per-marker via inline styles */
    animation: inner-pulse 2s infinite;
}

/* Separate DOM element for the expanding ring so we can set per-marker delays/durations */
.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    transform: translate(-50%, -50%) scale(1);
    border-radius: 50%;
    background-color: rgba(255,255,255,0.32); /* slightly lighter translucent ring */
    opacity: 0.5;
    pointer-events: none;
    animation: pulse-ring 2.2s infinite;
}

/* Inner animations — subtle breathing of the core dot (slightly more pronounced) */
@keyframes inner-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.96; }
    100% { transform: scale(1); opacity: 1; }
}

/* Pulse ring expands evenly from the center of the dot, with larger final scale */
@keyframes pulse-ring {
    0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.5; }
    60% { transform: translate(-50%, -50%) scale(2.4); opacity: 0.08; }
    100% { transform: translate(-50%, -50%) scale(2.8); opacity: 0; }
}

/* Video Terminal Specifics */
.video-terminal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    z-index: 1050;
    display: none;
}
.video-terminal.show {
    display: block;
    animation: fadeInVideoWindow 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInVideoWindow {
    from {
        opacity: 0;
        transform: translate(-50%, -45%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.video-terminal .terminal-body {
    padding: 0 !important;
}

/* Mobile Adjustments */
@media (max-width: 576px) {
    .terminal-body {
        padding: 20px 15px;
        font-size: 0.7875rem; /* slightly smaller on mobile after global reduction */
    }
    .traffic-lights { gap: 6px; }
    .dot { width: 10px; height: 10px; }
    .command-table {
        gap: 8px !important;
    }
}

/* Command table container (Grid for perfect tabulation) */
.command-table {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 12px 20px;
    margin-top: 12px;
    margin-bottom: 16px;
    align-items: center;
}

.cmd-row {
    display: contents; /* Allows children to participate in the grid */
}

.cmd-desc {
    color: #a0a0a0;
    font-size: 0.95em;
}

/* Command button styling (minimalist text link look matching Linux terminal) */
.cmd-btn {
    background: transparent;
    border: none;
    color: #34e2e2;
    font-family: 'JetBrains Mono', 'Fira Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: inherit;
    padding: 2px 4px;
    margin: 0 -4px; /* Adjust margin to compensate for padding */
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none;
}

.cmd-btn:hover, .cmd-btn:focus {
    color: #ffffff;
    background: rgba(52, 226, 226, 0.15);
    box-shadow: 0 0 10px 2px rgba(52, 226, 226, 0.4); /* Soft minimalist halo */
    transform: none;
}

.cmd-btn:active {
    transform: none;
    opacity: 0.8;
}