/* Basic Reset & Dark Theme Variables */
:root {
    --bg-dark: #181818;
    --bg-medium: #282828;
    --bg-light: #383838;
    --bg-selected: #505050;
    --border-color: #4a4a4a;
    --text-light: #d0d0d0;
    --text-medium: #a0a0a0;
    --text-dark: #777;
    --accent-green: #0EA100;
    --terminal-green: #0EA100;
    --star-color: #ffc107;
    --button-bg: #404040;
    --button-border: #5a5a5a;
    --button-hover-bg: #555555;
    --input-bg: #101010;
    --input-border: #4a4a4a;
    --header-height: 70px;
    --footer-height: 22px;
    --sidebar-width: 190px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif; font-size: 11px; background-color: var(--bg-dark); color: var(--terminal-green); height: 100vh; overflow: hidden; margin: 0; }
.app-container { display: flex; flex-direction: column; width: 100%; height: 100vh; background-color: var(--bg-medium); overflow: hidden; }
.app-header { height: var(--header-height); background-color: var(--bg-light); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: flex-end; padding: 0 8px; flex-shrink: 0; color: var(--text-light); }

.main-tabs-container {
    display: flex;
    height: auto;
    padding: 0 4px;
    flex-shrink: 0;
    position: relative;
    top: -15px;
    z-index: 10;
    margin-bottom: -15px;
}

.main-tab {
    padding: 10px 20px;
    margin-right: 2px;
    border: 1px solid var(--border-color);
    border-radius: 5px 5px 0 0;
    background-color: var(--button-bg);
    color: var(--text-light);
    cursor: pointer;
    font-size: 11.5px;
    font-weight: bold;
    position: relative;
    display: flex;
    align-items: center;
}
.main-tab:last-child {
    margin-right: 0;
}

.main-tab.active {
    z-index: 2;
    color: var(--terminal-green);
}

.main-tab.active[data-tab-target="search-content"] {
    background-color: var(--bg-medium);
    border-color: var(--border-color);
    border-bottom-color: var(--bg-medium);
}

.main-tab.active[data-tab-target="empty-content"] {
    background-color: #000000;
    border-color: var(--border-color);
    border-bottom-color: #000000;
    color: var(--terminal-green);
}

.main-tab:hover:not(.active) {
    background-color: var(--button-hover-bg);
    color: var(--text-light);
}

.main-content-area {
    flex: 1; display: flex; overflow: hidden;
}

.tab-content { display: none; width: 100%; height: 100%; overflow: hidden; }
.tab-content.active { display: flex; }
#search-content { background-color: var(--bg-medium); }

/* Terminal Menu Styles */
.terminal-menu-container { 
    width: 100%; 
    height: 100%; 
    background-color: #000; 
    color: var(--terminal-green); 
    padding: 10px; 
    font-family: 'Courier New', Courier, monospace; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    box-sizing: border-box;
}
.terminal-menu-container h3 { text-transform: uppercase; margin-bottom: 12px; border-bottom: 1px dashed var(--terminal-green); padding-bottom: 4px; display: inline-block; align-self: flex-start; font-size: 12px; }
.terminal-menu { list-style: none; padding: 0; margin: 0; }
.terminal-menu li { margin-bottom: 6px; }
.terminal-menu li a { color: inherit; text-decoration: none; cursor: pointer; display: inline-block; padding: 2px 4px; border-radius: 2px; font-size: 11.5px; }
.terminal-menu li a:hover { background-color: rgba(14, 161, 0, 0.2); color: #fff; }
.terminal-prompt { margin-top: 15px; font-weight: bold; }

/* Add to your existing terminal styles */
.terminal-menu li a.selected {
    background-color: var(--terminal-green);
    color: #000;
    border-radius: 2px;
}

.terminal-menu li a {
    transition: background-color 0.2s ease;
    display: block;
    padding: 4px 8px;
}

.terminal-menu li a:hover {
    background-color: rgba(14, 161, 0, 0.3);
}

/* Add to your terminal styles */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Sidebar --- */
.sidebar { flex: 0 0 var(--sidebar-width); background-color: var(--bg-medium); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.search-type-selector { margin: 4px; }
.sidebar-tab-button { display: block; width: 100%; padding: 5px 8px; margin-bottom: 2px; background-color: var(--button-bg); border: 1px solid var(--button-border); color: var(--terminal-green); text-align: left; cursor: pointer; font-size: 10.5px; }
.search-type-selector .sidebar-tab-button:last-of-type { margin-bottom: 0; }
.sidebar-button-group .panel-header { font-weight: bold; padding: 6px 4px; color: var(--text-light); background-color: var(--bg-light); border-bottom: 1px solid var(--border-color); margin-bottom: 0; text-align: center; flex-shrink: 0; font-size: 11px; }
.sidebar-tab-button.active { background-color: var(--button-hover-bg); color: var(--accent-green); border-color: var(--button-border); cursor: default; }
.sidebar-tab-button:not(.active):hover { background-color: var(--button-hover-bg); color: var(--accent-green); }
.sidebar-content-area { margin: 8px 4px 4px 4px; flex-grow: 1; overflow: hidden; border: 1px solid var(--border-color); background-color: #202020; display: flex; }
.sidebar-tab-content { display: none; width: 100%; height: 100%; overflow: hidden; flex-direction: column; }
.sidebar-tab-content.active { display: flex; }
.sidebar-tab-content > .panel-header { flex-shrink: 0; text-align: center; margin-bottom: 5px; font-size: 11px; font-weight: bold; background-color: var(--bg-light); border-bottom: 1px solid var(--border-color); color: var(--text-light); padding: 6px 4px; }
.search-criteria { border: none; margin: 0; background-color: transparent; display: flex; flex-direction: column; height: 100%; }
.search-criteria .panel-header { flex-shrink: 0; margin-bottom: 4px; }
.search-criteria > div:not(.panel-header) { overflow-y: hidden; padding: 0 4px 4px 4px; }
.search-criteria label { display: block; margin-top: 6px; margin-bottom: 1px; color: var(--terminal-green); padding-left: 4px; }
.search-criteria input[type="text"], .search-criteria select { width: calc(100% - 8px); padding: 3px; background-color: var(--input-bg); border: 1px solid var(--input-border); color: var(--terminal-green); margin-bottom: 4px; margin-left: 4px; font-size: 10.5px; }
.search-criteria select { height: 22px; }
.more-options { margin-top: 8px; margin-left: 4px; display: flex; align-items: center; }
.more-options input[type="checkbox"] { width: 12px; height: 12px; margin-right: 4px; }
.more-options label { margin: 0; padding-left: 0; font-size: 10.5px;}
.search-button { display: block; width: calc(100% - 8px); margin: 12px auto 4px auto; padding: 6px; background-color: var(--button-bg); border: 1px solid var(--button-border); color: var(--terminal-green); cursor: pointer; font-weight: bold; }
.search-button:hover { background-color: var(--button-hover-bg); }
.sidebar-placeholder-content { padding: 8px; color: var(--terminal-green); font-size: 10.5px; flex-grow: 1; overflow-y: auto; }
#sb-whatsnew .chat-log { flex-grow: 1; overflow-y: auto; padding: 6px; background-color: #202020; }
.chat-message { margin-bottom: 8px; color: var(--terminal-green); }
.chat-meta { font-size: 9.5px; color: var(--text-medium); margin-bottom: 1px; }
.chat-username { font-weight: bold; color: var(--text-light); }
.chat-text { line-height: 1.3; font-size: 10.5px; }
.sidebar-bottom-tabs { display: flex; margin: 4px 0 0 0; border-top: 1px solid var(--border-color); padding: 4px 4px 0 4px; margin-top: auto; flex-shrink: 0; }
.sidebar-bottom-tabs .sidebar-tab-button { flex-grow: 1; padding: 5px 0; margin: 0 1px; text-align: center; border-bottom: none; }

.logo-placeholder {
    margin-top: 20px;
}

/* === Main Content (Right Side) === */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background-color: var(--bg-medium); }
.search-results-panel { flex: 3; display: flex; flex-direction: column; overflow: hidden; margin: 4px; border: 1px solid var(--border-color); background-color: var(--bg-dark); }
.downloads-panel { flex: 1; min-height: 65px; display: flex; flex-direction: column; overflow: hidden; margin: 0 4px 4px 4px; border: 1px solid var(--border-color); background-color: var(--bg-dark); }
.results-header { background-color: var(--bg-light); padding: 4px 6px; border-bottom: 1px solid var(--border-color); font-weight: bold; color: var(--text-light); flex-shrink: 0; font-size: 11px;}
.results-table-container { overflow-y: auto; flex-grow: 1; background-color: var(--bg-dark); position: relative; }
.results-actions { padding: 6px; background-color: var(--bg-medium); border-top: 1px solid var(--border-color); display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.downloads-panel .panel-header { background-color: var(--bg-light); padding: 5px 6px; border-bottom: 1px solid var(--border-color); text-align: left; font-weight: bold; color: var(--text-light); flex-shrink: 0; font-size: 11px;}
.downloads-table-container { overflow-y: auto; flex-grow: 1; background-color: var(--bg-dark); }
.downloads-actions { padding: 4px 6px; background-color: var(--bg-medium); border-top: 1px solid var(--border-color); display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.player-controls { padding: 6px; background-color: var(--bg-dark); border: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; margin: 0 4px 4px 4px; flex-shrink: 0; }

/* === Tables === */
table { width: 100%; border-collapse: collapse; table-layout: fixed; }

.search-results-panel thead::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    background-color: var(--bg-light);
    z-index: 1;
}

.search-results-panel thead::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    z-index: 3;
    pointer-events: none;
    background-image: none;
}

.search-results-panel thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: none;
    border-bottom: 1px solid #2a2a2a;
    line-height: 0;
}

.search-results-panel thead th {
    position: relative;
    z-index: 2;
    background-color: transparent;
    padding: 5px 6px;
    text-align: left;
    border-right: none;
    color: var(--text-light);
    font-weight: normal;
    white-space: nowrap;
    height: 24px;
    vertical-align: middle;
    line-height: normal;
    font-size: 11px;
}

.search-results-panel table {
    border-spacing: 0;
    border-collapse: collapse;
    font-size: 0;
}

.search-results-panel table * {
    font-size: 11px;
}

thead th.sortable-header { cursor: pointer; position: relative; }
thead th.sortable-header:hover { background-color: var(--button-hover-bg); }
thead th.sortable-header::after { content: ''; display: inline-block; width: 0; height: 0; border-left: 3px solid transparent; border-right: 3px solid transparent; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0.4; }
thead th.sortable-header.sort-asc::after { border-bottom: 4px solid var(--terminal-green); opacity: 1; }
thead th.sortable-header.sort-desc::after { border-top: 4px solid var(--terminal-green); opacity: 1; }

.search-results-panel thead th:nth-child(1){width: 60px;}
.search-results-panel thead th:nth-child(2){width: 340px;}
.search-results-panel thead th:nth-child(3){width: 46px;} /* Action column width */
.search-results-panel thead th:nth-child(4){width: 35px;}
.search-results-panel thead th:nth-child(5){width: 30px;}
.search-results-panel thead th:nth-child(6){width: 45px;}
.search-results-panel thead th:nth-child(7){width: 65px;}
.search-results-panel thead th:nth-child(8){width: 80px;}

.downloads-panel thead th:nth-child(2){width: 70px;}
.downloads-panel thead th:nth-child(3){width: 130px;}
.downloads-panel thead th:nth-child(4){width: 90px;}
.downloads-panel thead th:nth-child(5){width: 65px;}
.downloads-panel thead th:nth-child(6){width: 45px;}

tbody td { padding: 3px 6px; border-bottom: 1px solid #2a2a2a; border-right: 1px solid #2a2a2a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--terminal-green); }
.downloads-panel tbody td { padding: 2px 6px; }
tbody td:last-child { border-right: none; }

.search-results-panel tbody td:nth-child(1),
.search-results-panel tbody td:nth-child(3), 
.search-results-panel tbody td:nth-child(4),
.search-results-panel tbody td:nth-child(5) {
    text-align: center;
}
.search-results-panel tbody td:first-child { color: var(--star-color); }
.search-results-panel tbody td:first-child span { color: #444 !important; }

.play-button,
.watch-button,
.inspect-button {
    display: inline-block;
    width: 46px; /* Adjusted width */
    height: 16px;
    background-color: var(--terminal-green);
    color: var(--bg-dark);
    border: 1px solid #0a7d00;
    border-radius: 3px;
    text-align: center;
    line-height: 14px;
    cursor: pointer;
    font-size: 8.5px;
    font-weight: 600;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.play-button:hover,
.watch-button:hover,
.inspect-button:hover {
    background-color: #1fcc1f;
}

/* === Modal Styles === */
.modal-overlay {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3); /* Start state for transition */
    backdrop-filter: blur(0px);          /* Start state for transition */
    -webkit-backdrop-filter: blur(0px);
    opacity: 0;                          /* Start state for transition */
    z-index: 1000;
    transition: opacity 1.5s ease, background-color 1.5s ease, backdrop-filter 1.5s ease, -webkit-backdrop-filter 1.5s ease;
}

.inspect-modal {
    display: none; 
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95); /* Start state for transition */
    opacity: 0;                                  /* Start state for transition */
    width: 60vw;
    height: 60vh;
    background-color: var(--bg-medium);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    z-index: 1001;
    color: var(--text-light);
    overflow: hidden;
    flex-direction: column; 
    transition: opacity 1.5s ease, transform 1.5s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--terminal-green);
}

.modal-close {
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    color: var(--text-light);
    background-color: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: 3px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover {
    background-color: var(--button-hover-bg);
    color: var(--accent-green);
}

.modal-content {
    display: flex; /* Enable flexbox for side-by-side layout */
    flex-grow: 1;
    overflow: hidden; /* Prevent scrollbars on the main modal content */
    padding: 0; /* Remove padding, will be on inner divs */
}

.modal-description-panel {
    width: 40%; /* Description takes 40% of the space */
    padding: 15px;
    background-color: var(--bg-dark); /* Or another suitable background */
    overflow-y: auto; /* Allow scrolling for description content */
    border-right: 1px solid var(--border-color);
    color: var(--text-light);
}

.modal-3d-viewer-panel {
    width: 60%; /* 3D viewer takes 60% of the space */
    position: relative; /* For positioning canvas if needed */
    background-color: var(--bg-dark); /* Match scene background or desired */
}

.modal-3d-viewer-panel canvas {
    display: block;
    width: 100%;
    height: 100%;
}


.modal-overlay.active {
    display: block; 
    opacity: 1;                         /* End state for transition */
    background-color: rgba(0, 0, 0, 0.6); /* End state for transition */
    backdrop-filter: blur(3px);         /* End state for transition */
    -webkit-backdrop-filter: blur(3px);
}

.inspect-modal.active {
    display: flex; 
    opacity: 1;                                /* End state for transition */
    transform: translate(-50%, -50%) scale(1); /* End state for transition */
}


/* =============================================== */
/* --- ZORK FOCUS: BOOT BUTTON + BACK NAV --- */
/* =============================================== */
/* Compact horizontal header: back-nav (left) | BOOT button (center) | logo (right) */
.app-header {
    height: auto !important;
    min-height: 64px;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 14px !important;
    position: relative;
    gap: 16px;
    flex-wrap: wrap;
}
.logo-placeholder {
    margin-top: 0 !important;
    flex-shrink: 0;
    order: 3;
}
.logo-placeholder img {
    max-height: 48px !important;
    max-width: 220px !important;
    width: auto !important;
    height: auto !important;
    display: block;
}

.back-nav {
    position: static !important;
    flex-shrink: 0;
    order: 1;
}
.back-nav .back-to-main {
    display: inline-block;
    color: #ff3366 !important;
    font-family: 'Roboto Mono', monospace, Courier, monospace;
    font-weight: 700;
    text-decoration: none !important;
    border: 1px solid #ff3366;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 11px;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    background: rgba(0,0,0,0.5);
    white-space: nowrap;
}
.back-nav .back-to-main:hover {
    background: #ff3366;
    color: #000 !important;
    box-shadow: 0 0 12px rgba(255,51,102,0.5);
}

/* BOOT ZORK button — main call to action, centered */
.zork-launch-container {
    flex: 1;
    text-align: center;
    margin: 0;
    order: 2;
    min-width: 0;
}
.boot-zork-btn {
    display: inline-block;
    font-family: 'Roboto Mono', monospace, Courier, monospace;
    font-weight: 700;
    font-size: 0.85em;
    color: limegreen;
    background: rgba(50, 205, 50, 0.06);
    border: 2px solid limegreen;
    border-radius: 4px;
    padding: 8px 18px;
    cursor: pointer;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(50, 205, 50, 0.4), inset 0 0 10px rgba(50, 205, 50, 0.1);
    animation: boot-zork-pulse 2s infinite alternate ease-in-out;
    transition: color 0.25s, background 0.25s, border-color 0.25s, box-shadow 0.25s, transform 0.2s;
    white-space: nowrap;
}
.boot-zork-btn:hover {
    color: #000;
    background: limegreen;
    border-color: #fff;
    box-shadow: 0 0 28px limegreen, inset 0 0 24px rgba(255,255,255,0.15);
    transform: translateY(-2px) scale(1.03);
    animation: none;
}
@keyframes boot-zork-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(50, 205, 50, 0.4), inset 0 0 12px rgba(50, 205, 50, 0.1); }
    50%      { box-shadow: 0 0 22px rgba(50, 205, 50, 0.8), 0 0 36px rgba(50, 205, 50, 0.4), inset 0 0 18px rgba(50, 205, 50, 0.15); }
}
.zork-launch-hint {
    margin: 4px 0 0 0;
    font-family: 'Roboto Mono', monospace, Courier, monospace;
    font-size: 0.7em;
    color: #888;
    opacity: 0.75;
    letter-spacing: 0.04em;
    text-align: center;
    display: none; /* hidden in compact header; shown on wider screens via media query */
}
@media (min-width: 900px) {
    .zork-launch-hint { display: block; }
}
.zork-launch-hint code {
    color: limegreen;
    background: rgba(50,205,50,0.1);
    padding: 1px 6px;
    border-radius: 2px;
    font-weight: 700;
}

/* Highlight ZORK_TERMINAL tab (the star of the show) */
.main-tab[data-tab-target="empty-content"] {
    color: limegreen !important;
    border-color: limegreen !important;
    font-weight: 700;
}
.main-tab[data-tab-target="empty-content"].active {
    background: rgba(50,205,50,0.15) !important;
    box-shadow: inset 0 -3px 0 limegreen;
}

/* Mobile: stack & shrink */
@media (max-width: 600px) {
    .app-header {
        flex-direction: column !important;
        align-items: center !important;
        gap: 8px;
        padding: 8px !important;
    }
    .back-nav { order: 1; align-self: flex-start; }
    .zork-launch-container { order: 2; width: 100%; }
    .logo-placeholder { order: 3; }
    .logo-placeholder img { max-height: 40px !important; }
    .back-nav .back-to-main { font-size: 10px; padding: 3px 8px; }
    .boot-zork-btn { font-size: 0.8em; padding: 8px 14px; }
}

/* ================================================================ */
/* --- DESKTOP-ONLY NOTICE ---------------------------------------- */
/* This page simulates desktop software: a fixed 190px sidebar in a
   flex row inside a 100vh shell. It cannot collapse sensibly onto a
   phone without destroying the concept, so below 600px we hide the
   app entirely and show a short in-character notice instead.        */
/* ================================================================ */

/* Hidden by default -- only revealed at narrow widths. */
.desktop-only-notice { display: none; }

@media (max-width: 600px) {
    /* Hide the desktop app shell rather than let it overflow. */
    .app-container { display: none !important; }

    .desktop-only-notice {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100svh;   /* svh tolerates mobile browser chrome */
        padding: 24px 20px;
        background-color: var(--bg-dark);
        text-align: center;
    }

    .don-inner {
        max-width: 320px;
        border: 1px solid var(--terminal-green);
        padding: 22px 18px;
        background-color: #101010;
    }

    .don-title {
        font-family: 'Courier New', Courier, monospace;
        color: var(--terminal-green);
        font-size: 0.95rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        margin: 0 0 14px 0;
    }

    .don-body {
        font-family: 'Courier New', Courier, monospace;
        color: var(--text-light);
        font-size: 0.8rem;
        line-height: 1.7;
        margin: 0 0 8px 0;
    }

    .don-meta {
        font-family: 'Courier New', Courier, monospace;
        color: var(--text-dark);
        font-size: 0.68rem;
        letter-spacing: 0.05em;
        margin: 16px 0 0 0;
    }

    .don-link {
        display: inline-block;
        margin-top: 18px;
        padding: 11px 16px;      /* >=44px tall tap target */
        font-family: 'Courier New', Courier, monospace;
        font-size: 0.75rem;
        letter-spacing: 0.06em;
        color: var(--terminal-green);
        text-decoration: none;
        border: 1px solid var(--terminal-green);
    }
    .don-link:hover,
    .don-link:focus-visible {
        background-color: var(--terminal-green);
        color: #000;
        outline: none;
    }

    /* The base body rule sets height:100vh + overflow:hidden for the
       desktop app shell. That clips the notice and blocks scrolling on a
       phone, so relax it here. */
    body {
        height: auto;
        min-height: 100svh;
        overflow: visible;
    }

    /* Safety: no sideways scrolling on the notice screen. */
    html, body { max-width: 100%; overflow-x: hidden; }
}
