/* ============================================
   ENARGEIA — Nonfiction Desktop
   Windows93-style file explorer.
   ============================================ */

html:has(.nonfiction-page),
html:has(.nonfiction-page) body {
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
}

.nonfiction-page {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    background: #0a0a14;
    font-family: 'Courier New', monospace;
    color: #c8bfdb;
    user-select: none;
}

/* --- CRT scanline overlay --- */
.nonfiction-page::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
}

/* --- Taskbar --- */
.taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background: linear-gradient(180deg, #2a2040, #1a1230);
    border-top: 2px solid #3a2f55;
    z-index: 500;
    display: flex;
    align-items: center;
    padding: 0 6px;
    gap: 4px;
}

/* Start button */
.taskbar-start {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.7rem;
    color: #f0e6ff;
    padding: 2px 10px;
    background: linear-gradient(180deg, #3a2f55, #2a1f40);
    border: 1px outset #4a3f65;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.05em;
}

.taskbar-start:hover {
    background: linear-gradient(180deg, #4a3f65, #3a2f55);
}

.taskbar-start:active {
    border-style: inset;
}

.taskbar-start-icon {
    font-size: 0.8rem;
}

/* Taskbar divider */
.taskbar-divider {
    width: 1px;
    height: 20px;
    background: #3a2f55;
    margin: 0 2px;
}

/* Open window tabs in taskbar */
.taskbar-tabs {
    flex: 1;
    display: flex;
    gap: 2px;
    overflow: hidden;
}

.taskbar-tab {
    font-family: 'Courier New', monospace;
    font-size: 0.6rem;
    color: #8a8098;
    padding: 2px 8px;
    background: linear-gradient(180deg, #1a1230, #120a20);
    border: 1px solid #2a1f40;
    cursor: pointer;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: none;
}

.taskbar-tab.visible {
    display: block;
}

.taskbar-tab.active {
    background: linear-gradient(180deg, #2a1f40, #1a1230);
    color: #c4b5fd;
    border-color: #3a2f55;
}

/* Clock */
.taskbar-clock {
    font-size: 0.6rem;
    color: #5eead4;
    padding: 0 6px;
    border-left: 1px solid #2a1f40;
    margin-left: auto;
}

/* --- Desktop area --- */
.desktop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 32px;
    padding: 12px;
    z-index: 1;
}

/* --- Desktop nav --- */
.desktop-nav {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
}

.desktop-nav .return-link {
    font-family: 'MedievalSharp', cursive;
    font-size: 0.75rem;
    color: #8a8098;
    letter-spacing: 0.08em;
    transition: color 0.3s ease;
}

.desktop-nav .return-link:hover {
    color: #c4b5fd;
    text-shadow: 0 0 6px rgba(196, 181, 253, 0.3);
}

/* --- File Icons Grid --- */
.desktop-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 28px;
    align-content: flex-start;
    max-width: 100%;
}

.file-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    padding: 6px 4px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.file-icon:hover {
    background: rgba(196, 181, 253, 0.06);
    border-color: rgba(196, 181, 253, 0.1);
}

.file-icon.selected {
    background: rgba(196, 181, 253, 0.1);
    border-color: rgba(196, 181, 253, 0.2);
}

/* The icon graphic */
.file-icon-img {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 4px;
    position: relative;
}

/* Different icon types */
.file-icon-img.type-essay::before { content: '📄'; }
.file-icon-img.type-rant::before { content: '🔥'; }
.file-icon-img.type-manifesto::before { content: '📜'; }
.file-icon-img.type-letter::before { content: '✉️'; }
.file-icon-img.type-analysis::before { content: '🔍'; }
.file-icon-img.type-misc::before { content: '📝'; }

/* Icon label */
.file-icon-label {
    font-family: 'Courier New', monospace;
    font-size: 0.55rem;
    color: #c8bfdb;
    text-align: center;
    word-break: break-word;
    line-height: 1.3;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    max-width: 100%;
}

/* ============================================
   WINDOW (opens when you click a file)
   ============================================ */

.text-window {
    position: absolute;
    z-index: 100;
    min-width: 320px;
    max-width: clamp(360px, 55vw, 650px);
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    background: #0e0a18;
    border: 2px solid #3a2f55;
    box-shadow:
        4px 4px 0 rgba(0, 0, 0, 0.4),
        0 0 20px rgba(168, 85, 247, 0.05);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.text-window.open {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
}

/* Bring focused window to front */
.text-window.focused {
    z-index: 200;
}

/* --- Title bar --- */
.window-titlebar {
    display: flex;
    align-items: center;
    padding: 3px 4px;
    background: linear-gradient(90deg, #2a1f4e, #3a2f55, #2a1f4e);
    border-bottom: 1px solid #1a1230;
    cursor: grab;
    flex-shrink: 0;
    gap: 6px;
}

.window-titlebar:active {
    cursor: grabbing;
}

.window-titlebar-icon {
    font-size: 0.8rem;
}

.window-titlebar-text {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 0.65rem;
    color: #f0e6ff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
}

/* Window buttons (minimize, close) */
.window-btns {
    display: flex;
    gap: 2px;
}

.window-btn {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    background: linear-gradient(180deg, #2a1f40, #1a1230);
    border: 1px outset #3a2f55;
    color: #8a8098;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}

.window-btn:hover {
    color: #f0e6ff;
    background: linear-gradient(180deg, #3a2f55, #2a1f40);
}

.window-btn:active {
    border-style: inset;
}

.window-btn-close:hover {
    color: #fca5a5;
}

/* --- Menu bar --- */
.window-menubar {
    display: flex;
    gap: 0;
    padding: 1px 4px;
    background: #120a1a;
    border-bottom: 1px solid #2a1f40;
    flex-shrink: 0;
}

.window-menu-item {
    font-size: 0.6rem;
    color: #8a8098;
    padding: 1px 8px;
    cursor: default;
}

.window-menu-item:hover {
    background: #2a1f4e;
    color: #c4b5fd;
}

/* --- Metadata bar --- */
.window-meta {
    padding: 6px 10px;
    background: #0a0812;
    border-bottom: 1px solid #1a1230;
    font-size: 0.6rem;
    color: #8a8098;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    flex-shrink: 0;
}

.window-meta-field {
    display: inline-flex;
    gap: 4px;
}

.window-meta-label {
    color: #5eead4;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.window-meta-value {
    color: #c8bfdb;
}

/* --- Content area (scrollable) --- */
.window-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    font-size: clamp(0.75rem, 1.3vw, 0.85rem);
    color: #c8bfdb;
    line-height: 1.8;
    background: #0e0a18;
}

.window-content::-webkit-scrollbar { width: 12px; }
.window-content::-webkit-scrollbar-track {
    background: #0a0812;
    border-left: 1px solid #1a1230;
}
.window-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #3a2f55, #2a1f40);
    border: 1px solid #2a1f40;
}
.window-content::-webkit-scrollbar-button {
    background: #1a1230;
    border: 1px solid #2a1f40;
    height: 12px;
}

.window-content p {
    margin-bottom: 0.8rem;
    max-width: 100%;
}

.window-content h2 {
    font-family: 'MedievalSharp', cursive;
    font-size: 1rem;
    color: #c4b5fd;
    margin: 1rem 0 0.5rem;
}

/* --- Status bar --- */
.window-statusbar {
    padding: 2px 8px;
    background: #0a0812;
    border-top: 1px solid #1a1230;
    font-size: 0.55rem;
    color: #8a8098;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .text-window {
        min-width: 95vw;
        max-width: 95vw;
        max-height: 80vh;
        left: 2.5vw !important;
    }

    .file-icon {
        width: 65px;
    }
}