/* --- AGNIDHRA OS (Cinematic FUI / Sci-Fi HUD - Level 2 Polish) --- */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
    /* Palette - Cyber HUD */
    --os-bg: #020204;
    --os-fg: #dcfce7;
    /* Pale green-white */
    --os-fg-dim: #94a3b8;

    /* Accents - High Contrast */
    --os-accent-primary: #00f3ff;
    /* Cyan */
    --os-accent-secondary: #ff003c;
    /* Cyber Red */
    --os-accent-warning: #facc15;
    /* Amber */

    /* Surfaces */
    --os-surface: rgba(4, 8, 15, 0.92);
    --os-surface-border: rgba(0, 243, 255, 0.4);

    /* Tech Specs */
    --os-border-width: 1px;
    --os-corner-cut: 20px;

    /* Z-Index Layers */
    --z-background: 0;
    --z-windows: 100;
    --z-taskbar: 9000;
    --z-modal: 9999;
}

/* --- GLOBAL RESET --- */
#os-desktop * {
    box-sizing: border-box;
    cursor: default;
    -webkit-font-smoothing: none;
}

#os-desktop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--os-bg);
    font-family: 'Rajdhani', sans-serif;
    color: var(--os-fg);
    overflow: hidden;
    user-select: none;
    z-index: 9999;

    /* Hex Grid Background */
    background-image:
        radial-gradient(circle at 50% 50%, rgba(0, 243, 255, 0.05) 0%, transparent 60%),
        linear-gradient(0deg, rgba(0, 0, 0, 0.8), transparent),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0l25.98 15v30L30 60 4.02 45V15z' fill-opacity='0.02' fill='%2300f3ff' fill-rule='evenodd'/%3E%3C/svg%3E");
}

/* CRT Scanline Overlay */
#os-desktop::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    z-index: 9998;
    /* Just below modal */
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    opacity: 0.6;
}

#os-background-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* EXIT BUTTON (Target Reticle) */
#os-exit-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--os-accent-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--os-accent-secondary);
    font-size: 24px;
    text-decoration: none;
    z-index: 10000;
    clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
    transition: all 0.2s;
    cursor: pointer;
}

#os-exit-btn:hover {
    background: var(--os-accent-secondary);
    color: #000;
    box-shadow: 0 0 20px var(--os-accent-secondary);
    animation: glitch-anim 0.3s infinite;
}

/* Force Graph Container */
#cy {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10 !important;
    pointer-events: auto !important;
}

#os-windows-container {
    position: absolute;
    inset: 0;
    z-index: var(--z-windows);
    pointer-events: none;
}

/* --- WINDOWS (FUI Data Panes) --- */
.os-window {
    position: absolute;
    width: 800px;
    height: 550px;

    background: var(--os-surface);
    border: 1px solid var(--os-surface-border);
    /* Chamfered Corners */
    clip-path: polygon(0 0,
            calc(100% - var(--os-corner-cut)) 0,
            100% var(--os-corner-cut),
            100% 100%,
            var(--os-corner-cut) 100%,
            0 calc(100% - var(--os-corner-cut)));

    box-shadow: 0 0 30px rgba(0, 243, 255, 0.05);

    display: flex;
    flex-direction: column;
    pointer-events: auto;
    transition: opacity 0.2s, transform 0.2s;
    transform-origin: center;
    overflow: hidden;
}

.os-window.booting {
    animation: holographicBoot 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes holographicBoot {
    0% {
        opacity: 0;
        transform: translateY(40px) scaleY(0) scaleX(1.2);
        filter: brightness(2) blue-shift(10px);
    }
    40% {
        opacity: 0.8;
        transform: translateY(-5px) scaleY(1.1) scaleX(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(2px) scaleY(0.95) scaleX(1.05);
        filter: brightness(1.5);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: brightness(1);
    }
}

/* Active Window Breathing Glow */
.os-window.active {
    box-shadow: 0 0 0 1px var(--os-accent-primary);
    border-color: var(--os-accent-primary);
    z-index: 500;
    animation: activePulse 4s infinite alternate;
}

@keyframes activePulse {
    0% {
        box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
        border-color: rgba(0, 243, 255, 0.6);
    }

    100% {
        box-shadow: 0 0 25px rgba(0, 243, 255, 0.5);
        border-color: rgba(0, 243, 255, 1);
    }
}

/* Clean Window Border */
.os-window::before {
    display: none; /* Removed TRK_ID for cleaner look */
}

.os-window::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid var(--os-surface-border);
    pointer-events: none;
    z-index: 5;
    /* Subtle Corner Marks (Internal) */
    background: 
        linear-gradient(90deg, var(--os-accent-primary) 1px, transparent 1px) 0 0,
        linear-gradient(0deg, var(--os-accent-primary) 1px, transparent 1px) 0 0,
        linear-gradient(-90deg, var(--os-accent-primary) 1px, transparent 1px) 100% 0,
        linear-gradient(0deg, var(--os-accent-primary) 1px, transparent 1px) 100% 0;
    background-repeat: no-repeat;
    background-size: 15px 15px;
    opacity: 0.4;
}

.os-window.minimized {
    display: none !important;
}

.os-window.maximized {
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    clip-path: none;
    border-radius: 0;
}

/* Header */
.window-header {
    height: 48px;
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.1), transparent);
    border-bottom: 1px solid var(--os-surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    cursor: grab;
    user-select: none;
}

.window-header:active {
    cursor: grabbing;
}

.window-title {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--os-accent-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.window-title::before {
    content: 'DATA_PANE';
    font-size: 8px;
    color: var(--os-accent-primary);
    opacity: 0.6;
    border-right: 1px solid rgba(0, 243, 255, 0.3);
    padding-right: 10px;
    margin-right: 2px;
}

/* Glitch Effect on Hover Title */
.window-header:hover .window-title {
    animation: glitch-anim 0.4s infinite;
}

@keyframes glitch-anim {
    0% {
        transform: translate(0);
        text-shadow: 0 0 5px var(--os-accent-primary);
    }

    20% {
        transform: translate(-1px, 1px);
        text-shadow: 1px 1px 0 var(--os-accent-secondary);
    }

    40% {
        transform: translate(0);
        text-shadow: -1px -1px 0 var(--os-accent-warning);
    }

    60% {
        transform: translate(1px, -1px);
        text-shadow: 1px -1px 0 var(--os-accent-secondary);
    }

    80% {
        transform: translate(0);
        text-shadow: -1px 1px 0 var(--os-accent-primary);
    }

    100% {
        transform: translate(0);
        text-shadow: 0 0 5px var(--os-accent-primary);
    }
}

/* Controls (Tech Blocks) */
.window-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Functional Progress Bar Style */
.window-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    background: var(--os-accent-primary);
    width: 0%;
    z-index: 1001;
    box-shadow: 0 0 10px var(--os-accent-primary);
    transition: width 0.1s ease-out;
}

.win-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--os-fg-dim);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: var(--os-fg-dim);
    transition: all 0.2s;
    position: relative;
    z-index: 10;
}

.win-min::after { content: '—'; }
.win-max::after { content: '□'; }
.win-close::after { content: '×'; }

.win-btn:hover {
    background: var(--os-accent-primary);
    border-color: var(--os-accent-primary);
    color: #000;
}

.win-close:hover {
    background: var(--os-accent-secondary);
    border-color: var(--os-accent-secondary);
}

/* Body */
.window-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at 50% 50%, rgba(0, 20, 30, 0.4), transparent);
}

.window-content {
    height: 100%;
    padding: 24px;
    overflow-y: auto;
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #ccc;
    font-weight: 500;
}

/* ORG-MODE STYLING FOR CONTENT */
.window-content h1, .window-content h2, .window-content h3, .window-content h4 {
    font-weight: bold;
    margin-top: 30px;
    margin-bottom: 15px;
    font-family: 'Share Tech Mono', monospace;
}

.window-content h1 { color: var(--os-accent-primary); font-size: 2.2rem; }
.window-content h1::before { content: '* '; color: #10b981; }

.window-content h2 { color: #3b82f6; font-size: 1.8rem; }
.window-content h2::before { content: '** '; color: #10b981; }

.window-content h3 { color: #f59e0b; font-size: 1.4rem; }
.window-content h3::before { content: '*** '; color: #10b981; }

.window-content h4 { color: #ef4444; font-size: 1.2rem; }
.window-content h4::before { content: '**** '; color: #10b981; }

.window-content p {
    line-height: 1.8;
    margin-bottom: 25px;
    font-size: 1.05rem;
}

.window-content a {
    color: #3b82f6;
    text-decoration: none;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.window-content a:hover {
    background: rgba(59, 130, 246, 0.1);
}

.window-content blockquote {
    border-left: 2px solid #3b82f6;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    margin: 30px 0;
    color: #9ca3af;
    font-style: normal;
}
.window-content blockquote::before {
    content: '#+BEGIN_QUOTE';
    display: block;
    color: #3b82f6;
    margin-bottom: 15px;
    font-size: 0.85rem;
}
.window-content blockquote::after {
    content: '#+END_QUOTE';
    display: block;
    color: #3b82f6;
    margin-top: 15px;
    font-size: 0.85rem;
}

.window-content pre {
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 25px;
}
.window-content pre::before {
    content: '#+BEGIN_SRC';
    display: block;
    color: #10b981;
    margin-bottom: 10px;
    font-size: 0.85rem;
}
.window-content pre::after {
    content: '#+END_SRC';
    display: block;
    color: #10b981;
    margin-top: 10px;
    font-size: 0.85rem;
}

/* Tech Scrollbar */
.window-content::-webkit-scrollbar {
    width: 8px;
}

.window-content::-webkit-scrollbar-track {
    background: #000;
}

.window-content::-webkit-scrollbar-thumb {
    background: #333;
    border: 1px solid #555;
}

.window-content::-webkit-scrollbar-thumb:hover {
    background: var(--os-accent-primary);
    border-color: #fff;
}

/* Resizer - Corner Grip */
.window-resizer {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, var(--os-accent-primary) 50%);
    cursor: se-resize;
    z-index: 20;
    opacity: 0.8;
}

/* --- TASKBAR (Segmented HUD) --- */
#os-taskbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    height: 60px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: var(--z-taskbar);
    pointer-events: none;
    /* Let clicks pass through gaps */
}

/* Start Module */
.taskbar-start {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--os-accent-primary);
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 20px;
    clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}

.start-btn {
    font-weight: 700;
    color: var(--os-accent-primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    transition: 0.2s;
}

.start-btn:hover {
    text-shadow: 0 0 10px var(--os-accent-primary);
    color: #fff;
    animation: glitch-anim 0.3s infinite;
}

.start-btn .icon {
    font-size: 20px;
}

/* Apps Module */
.taskbar-apps {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.8);
    border-top: 1px solid var(--os-surface-border);
    border-bottom: 1px solid var(--os-surface-border);
    height: 50px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 20px;
    position: relative;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 5% 100%);
}

.taskbar-apps::before {
    content: 'APPS';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--os-accent-primary);
    background: #000;
    padding: 0 4px;
}

/* App Items (Hexagons or Blocks) */
.task-item {
    width: 40px;
    height: 36px;
    background: rgba(0, 243, 255, 0.1);
    color: var(--os-accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.task-item:hover {
    background: rgba(0, 243, 255, 0.3);
    color: #fff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.task-item.active {
    border-bottom-color: var(--os-accent-primary);
    background: rgba(0, 243, 255, 0.2);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.task-item .title {
    display: none !important;
}

/* Tray Module */
.taskbar-tray {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #333;
    padding: 10px 20px;
    clip-path: polygon(0 0, 90% 0, 100% 10px, 100% 100%, 10px 100%, 0 90%);
}

#os-clock {
    font-family: 'Share Tech Mono', monospace;
    color: var(--os-fg-dim);
    font-size: 14px;
}

/* --- SIDEBAR --- */
.explorer-sidebar {
    background: rgba(0, 0, 0, 0.3);
    width: 200px;
    border-right: 1px solid var(--os-surface-border);
    padding: 20px 0;
}

.tree-item {
    padding: 8px 20px;
    font-family: 'Rajdhani', sans-serif;
    color: var(--os-fg-dim);
    font-size: 14px;
    text-transform: uppercase;
    cursor: pointer;
    border-left: 2px solid transparent;
}

.tree-item:hover {
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.1), transparent);
    color: #fff;
    border-left-color: var(--os-accent-primary);
}

.tree-item.active {
    color: var(--os-accent-primary);
    border-left-color: var(--os-accent-primary);
    background: linear-gradient(90deg, rgba(0, 243, 255, 0.2), transparent);
    text-shadow: 0 0 5px var(--os-accent-primary);
}

/* --- CRT & BOOT SEQUENCE EFFECTS (Notes UI) --- */
.window-content {
    position: relative;
}

.window-content::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 900;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
    opacity: 0.4;
}

.typewriter-text {
    visibility: hidden;
}

.typewriter-char {
    visibility: visible;
}

.typewriter-cursor {
    display: inline-block;
    width: 10px;
    height: 1.2em;
    background-color: var(--os-accent-primary);
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 5px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- MOBILE RESPONSIVENESS (SMARTPHONES) --- */
@media (max-width: 768px) {
    /* Force windows to full screen */
    .os-window {
        width: 100% !important;
        height: calc(100% - 60px) !important; /* Leave room for taskbar */
        top: 0 !important;
        left: 0 !important;
        border-radius: 0;
        clip-path: none !important;
        transform: none !important;
    }

    /* Hide corner accents on mobile */
    .os-window::before, .os-window::after {
        display: none;
    }

    /* Taskbar scrolling */
    .taskbar-apps {
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px; /* Scrollbar space */
    }

    .taskbar-apps::-webkit-scrollbar {
        height: 4px;
    }

    .taskbar-apps::-webkit-scrollbar-thumb {
        background: var(--os-accent-primary);
        border-radius: 2px;
    }

    /* Adjust start menu for mobile */
    #task-start-btn {
        padding: 0 10px;
    }
    
    .start-btn .text {
        display: none; /* Hide 'START' text, show only icon on small screens */
    }

    /* Hide resizer */
    .window-resizer {
        display: none !important;
    }
}