/* Windows 95 Theme CSS */
:root {
    --win95-gray: #c0c0c0;
    --win95-dark: #808080;
    --win95-darker: #404040;
    --win95-light: #ffffff;
    --win95-blue: #000080;
    --win95-teal: #008080;
    --win95-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Modern fallback */
}

@font-face {
    font-family: 'W95FA';
    src: url('https://cdnjs.cloudflare.com/ajax/libs/w95fa/1.1.0/w95fa.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body {
    background-color: var(--win95-teal);
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Desktop shouldn't scroll */
    font-family: 'W95FA', 'Segoe UI', sans-serif;
    color: black;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

/* Desktop Icons */
#desktop {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    height: calc(100vh - 40px);
    /* Subtract taskbar */
    padding: 10px;
    align-content: flex-start;
}

.desktop-icon {
    width: 70px;
    text-align: center;
    margin: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    text-shadow: 1px 1px 1px black;
    /* For visibility on teal */
}

.desktop-icon img {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
    image-rendering: pixelated;
}

.desktop-icon span {
    background-color: transparent;
    padding: 2px;
    border: 1px dotted transparent;
}

.desktop-icon:active span,
.desktop-icon.selected span {
    background-color: var(--win95-blue);
    border: 1px dotted var(--win95-light);
}

/* Windows */
.window {
    position: absolute;
    background-color: var(--win95-gray);
    border-top: 2px solid var(--win95-light);
    border-left: 2px solid var(--win95-light);
    border-right: 2px solid var(--win95-darker);
    border-bottom: 2px solid var(--win95-darker);
    box-shadow: 1px 1px 0px 0px black;
    min-width: 300px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    font-family: 'W95FA', sans-serif;
}

.title-bar {
    background: var(--win95-dark);
    /* Default inactive */
    padding: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #dfdfdf;
    font-weight: bold;
    cursor: default;
}

.window.active .title-bar {
    background: linear-gradient(90deg, var(--win95-blue), #1084d0);
    color: white;
}

.title-bar-text {
    margin-left: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-controls button {
    width: 16px;
    height: 14px;
    min-width: unset;
    padding: 0;
    font-size: 10px;
    line-height: 10px;
    font-weight: bold;
    background: var(--win95-gray);
    border-top: 1px solid var(--win95-light);
    border-left: 1px solid var(--win95-light);
    border-right: 1px solid var(--win95-darker);
    border-bottom: 1px solid var(--win95-darker);
    box-shadow: none;
}

.title-bar-controls button:active {
    border-top: 1px solid var(--win95-darker);
    border-left: 1px solid var(--win95-darker);
    border-right: 1px solid var(--win95-light);
    border-bottom: 1px solid var(--win95-light);
}

.window-body {
    padding: 10px;
    flex-grow: 1;
    overflow: auto;
    font-size: 14px;
    background: white;
    margin: 2px;
    border: 2px solid;
    border-color: var(--win95-dark) var(--win95-light) var(--win95-light) var(--win95-dark);
}

/* Maximized State */
.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 38px) !important;
    max-width: none !important;
    max-height: none !important;
}

/* Taskbar */
#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 38px;
    background-color: var(--win95-gray);
    border-top: 2px solid var(--win95-light);
    display: flex;
    align-items: center;
    padding: 2px;
    z-index: 1000;
}

#start-button {
    height: 32px;
    margin-left: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    font-size: 14px;
    padding: 0 5px;
}

/* W95 Button Style */
.btn-win95 {
    background: var(--win95-gray);
    color: black;
    border-top: 2px solid var(--win95-light);
    border-left: 2px solid var(--win95-light);
    border-right: 2px solid var(--win95-darker);
    border-bottom: 2px solid var(--win95-darker);
    box-shadow: 1px 1px 0 black;
    cursor: pointer;
    font-family: 'W95FA', sans-serif;
}

.btn-win95:active,
.btn-win95.active {
    border-top: 2px solid var(--win95-darker);
    border-left: 2px solid var(--win95-darker);
    border-right: 2px solid var(--win95-light);
    border-bottom: 2px solid var(--win95-light);
    box-shadow: none;
    transform: translate(1px, 1px);
}

.divider {
    width: 2px;
    height: 28px;
    background-color: var(--win95-dark);
    margin: 0 5px;
    border-right: 1px solid var(--win95-light);
}

#taskbar-items {
    flex-grow: 1;
    display: flex;
    padding: 0 5px;
    gap: 3px;
    overflow-x: auto;
}

.taskbar-item {
    height: 28px;
    min-width: 140px;
    max-width: 200px;
    padding: 2px 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

#clock {
    background: var(--win95-gray);
    border-top: 2px solid var(--win95-darker);
    border-left: 2px solid var(--win95-darker);
    border-right: 2px solid var(--win95-light);
    border-bottom: 2px solid var(--win95-light);
    padding: 2px 10px;
    margin-right: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    height: 24px;
}

#start-menu {
    position: absolute;
    bottom: 40px;
    left: 2px;
    background: var(--win95-gray);
    border: 2px solid var(--win95-light);
    border-right-color: var(--win95-darker);
    border-bottom-color: var(--win95-darker);
    box-shadow: 2px 2px 0 black;
    display: none;
    flex-direction: row;
    z-index: 2000;
}

.sidebar {
    background: var(--win95-blue);
    width: 25px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sidebar-text {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: white;
    font-weight: bold;
    font-size: 20px;
    padding-bottom: 10px;
}

.menu-items {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.menu-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    justify-content: flex-start;
}

.menu-item span {
    margin-left: auto;
    font-size: 10px;
}

.submenu {
    position: absolute;
    left: 100%;
    bottom: 0;
    background: var(--win95-gray);
    border: 2px solid var(--win95-light);
    border-right-color: var(--win95-darker);
    border-bottom-color: var(--win95-darker);
    box-shadow: 2px 2px 0 black;
    display: none;
    flex-direction: column;
    min-width: 150px;
}

.menu-item:hover {
    background-color: var(--win95-blue);
    color: white;
}

/* Helper Classes */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 16px;
    height: 16px;
    background: var(--win95-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--win95-gray);
    border-top: 1px solid var(--win95-light);
    border-left: 1px solid var(--win95-light);
    border-right: 1px solid var(--win95-darker);
    border-bottom: 1px solid var(--win95-darker);
}

::-webkit-scrollbar-button {
    background: var(--win95-gray);
    border-top: 1px solid var(--win95-light);
    border-left: 1px solid var(--win95-light);
    border-right: 1px solid var(--win95-darker);
    border-bottom: 1px solid var(--win95-darker);
    display: block;
    height: 16px;
    width: 16px;
}

/* Clippy */
#clippy {
    position: fixed;
    bottom: 50px;
    right: 20px;
    width: 100px;
    height: 100px;
    z-index: 2000;
    cursor: pointer;
    background-repeat: no-repeat;
    background-size: contain;
    /* Placeholder for Clippy base64 in JS or CSS background */
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

.clippy-bubble {
    position: absolute;
    bottom: 110px;
    right: 20px;
    background: #ffffe1;
    border: 1px solid black;
    border-radius: 5px;
    padding: 10px;
    width: 200px;
    font-size: 12px;
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    display: none;
    font-family: 'Segoe UI', sans-serif;
}

.clippy-bubble:after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 30px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #ffffe1 transparent;
    display: block;
    width: 0;
}

/* Tooltips */
.tooltip {
    position: absolute;
    background-color: #ffffe1;
    color: black;
    border: 1px solid black;
    padding: 2px 5px;
    font-size: 11px;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    z-index: 3000;
    pointer-events: none;
    display: none;
    white-space: nowrap;
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
}

.desktop-icon:hover .tooltip {
    display: block;
}

/* Boot Screen */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

.boot-logo {
    text-align: center;
    margin-bottom: 50px;
}

.boot-logo img {
    width: 300px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
}

.boot-text {
    font-size: 24px;
    margin-top: 20px;
    font-weight: bold;
}

.boot-loader {
    width: 300px;
    height: 20px;
    border: 2px solid #808080;
    padding: 2px;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #000080, #1084d0);
    animation: load 2.5s linear forwards;
}

@keyframes load {
    0% {
        width: 0%;
    }

    20% {
        width: 30%;
    }

    50% {
        width: 45%;
    }

    80% {
        width: 85%;
    }

    100% {
        width: 100%;
    }
}

#boot-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

/* Transitions for Desktop Reveal */
#desktop,
#taskbar {
    opacity: 0;
    transition: opacity 1s ease-in;
}

body.booted #desktop,
body.booted #taskbar {
    opacity: 1;
}

/* Context Menu */
#context-menu {
    position: fixed;
    background: var(--win95-gray);
    border: 2px solid var(--win95-light);
    border-right-color: var(--win95-darker);
    border-bottom-color: var(--win95-darker);
    box-shadow: 2px 2px 0 black;
    z-index: 5000;
    display: none;
    min-width: 150px;
}

.context-menu-item {
    padding: 5px 20px;
    cursor: default;
    font-size: 12px;
}

.context-menu-item:hover {
    background: var(--win95-blue);
    color: white;
}

.context-menu-divider {
    height: 1px;
    background: var(--win95-dark);
    border-bottom: 1px solid var(--win95-light);
    margin: 2px 0;
}

/* Marquee Selection */
#selection-marquee {
    position: absolute;
    border: 1px dotted white;
    background: rgba(0, 0, 128, 0.2);
    pointer-events: none;
    z-index: 4000;
    display: none;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    #desktop {
        flex-direction: row;
        justify-content: center;
        align-content: flex-start;
    }

    .desktop-icon {
        margin: 5px;
        width: 60px;
    }

    .window {
        width: 95vw !important;
        left: 2.5vw !important;
        min-width: unset;
    }

    .taskbar-item {
        min-width: 40px;
        width: 40px;
        font-size: 0;
        /* Hide text, keep icon */
    }
}