/* --- Global & Body --- */
* {
    box-sizing: border-box;
}

body {
    background-color: #008080; /* Classic teal background */
    font-family: "MS Sans Serif", "Arial", sans-serif;
    font-size: 16px;
    margin: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- Accessibility: Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .aol-title-bar,
    .popup2-window .title-bar {
        animation: none !important;
        background: linear-gradient(to right, #ff4500, #ff8c00) !important;
    }
}

/* --- Focus Styles for Accessibility --- */
*:focus {
    outline: 2px dotted #000000;
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px dotted #000000;
    outline-offset: 2px;
}

/* --- Boot Screen --- */
.boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

.boot-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.boot-screen.hidden {
    display: none;
}

.boot-content {
    text-align: center;
    color: #ffffff;
}

.boot-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: boot-pulse 1.5s ease-in-out infinite;
}

@keyframes boot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.95); }
}

.boot-text {
    font-size: 18px;
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.boot-progress-container {
    width: 300px;
    height: 20px;
    background: #333333;
    border: 2px inset #666666;
    margin: 0 auto;
}

.boot-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #000080, #1084d0);
    animation: boot-progress 2s ease-out forwards;
}

@keyframes boot-progress {
    0% { width: 0%; }
    20% { width: 15%; }
    40% { width: 35%; }
    60% { width: 55%; }
    80% { width: 75%; }
    100% { width: 100%; }
}

/* --- Reusable Border Classes for Win95 Look --- */
.border-outset {
    border: 2px solid;
    border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: inset 1px 1px #ffffff;
}

.border-outset:active {
    border-color: #808080 #dfdfdf #dfdfdf #808080;
}

.border-inset {
    border: 2px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    box-shadow: inset 1px 1px #c0c0c0;
}

/* --- Desktop --- */
#desktop {
    flex-grow: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 30px;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90px;
    text-align: center;
    cursor: pointer;
    padding: 5px;
    border: 1px solid transparent;
    border-radius: 2px;
}

.desktop-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.desktop-icon img {
    width: 48px;
    height: 48px;
    pointer-events: none;
}

.desktop-icon span {
    color: white;
    margin-top: 8px;
    text-shadow: 1px 1px 2px black;
    padding: 2px 4px;
}

.desktop-icon:focus span,
.desktop-icon.selected span {
    background-color: #000080;
    outline: 1px dotted #ffffff;
}

.desktop-icon:focus {
    outline: none;
}

.desktop-icon:focus span {
    background-color: #000080;
    outline: 1px dotted #ffffff;
}

/* --- Context Menu --- */
.context-menu {
    position: fixed;
    background-color: #c0c0c0;
    border: 2px solid;
    border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    min-width: 180px;
}

.context-menu ul {
    list-style: none;
    margin: 2px;
    padding: 0;
}

.context-menu li {
    padding: 6px 25px 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.context-menu li:hover:not(.separator) {
    background-color: #000080;
    color: white;
}

.context-menu li.separator {
    height: 1px;
    background: #808080;
    border-bottom: 1px solid #ffffff;
    margin: 4px 2px;
    padding: 0;
    cursor: default;
}

/* --- Taskbar --- */
.taskbar {
    display: flex;
    align-items: center;
    background-color: #c0c0c0;
    padding: 3px;
    height: 34px;
    box-sizing: border-box;
    border-top: 2px solid #ffffff;
}

.start-button {
    display: flex;
    align-items: center;
    padding: 2px 6px;
    font-weight: bold;
    cursor: pointer;
    background-color: #c0c0c0;
    flex-shrink: 0;
}

.start-button img {
    width: 22px;
    height: 22px;
    margin-right: 4px;
}

.start-button.active {
    border-style: inset;
}

.taskbar-windows {
    display: flex;
    flex-grow: 1;
    margin: 0 5px;
    gap: 4px;
    height: 100%;
    overflow: hidden;
}

.taskbar-btn {
    flex: 1 1 0;
    max-width: 160px;
    min-width: 40px;
    text-align: left;
    padding: 0 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: #c0c0c0;
    border-style: outset;
    font-size: 14px;
    cursor: pointer;
}

.taskbar-btn.active {
    border-style: inset;
    font-weight: bold;
}

.clock {
    padding: 2px 8px;
    margin-right: 2px;
    flex-shrink: 0;
}

/* --- Start Menu --- */
.start-menu {
    position: absolute;
    bottom: 34px;
    left: 0;
    width: 220px;
    background-color: #c0c0c0;
    padding: 2px;
    display: flex;
    z-index: 1000;
}

.start-menu-sidebar {
    background: #808080;
    width: 30px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    padding: 10px 0;
}

.start-menu-sidebar::before {
    content: "BMA 95";
}

.start-menu ul {
    list-style: none;
    margin: 0;
    padding: 5px 0;
    width: 100%;
}

.start-menu li {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
}

.start-menu li:hover:not(.separator),
.start-menu li:focus:not(.separator) {
    background-color: #000080;
    color: white;
    outline: none;
}

.start-menu li.separator {
    height: 1px;
    background: #808080;
    border-bottom: 1px solid #ffffff;
    margin: 4px 2px;
    padding: 0;
    cursor: default;
}

.start-menu li img {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

/* --- Shutdown Dialog --- */
.shutdown-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.shutdown-dialog.hidden {
    display: none;
}

.shutdown-content {
    background: #c0c0c0;
    padding: 20px;
    text-align: center;
    min-width: 300px;
}

.shutdown-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.shutdown-header img {
    width: 48px;
    height: 48px;
    margin-right: 15px;
}

.shutdown-header h2 {
    margin: 0;
    font-size: 18px;
}

.shutdown-content p {
    margin: 15px 0;
}

.shutdown-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.shutdown-buttons button {
    padding: 8px 30px;
    background: #c0c0c0;
    cursor: pointer;
    font-size: 14px;
}

.shutdown-buttons button:hover {
    background: #d0d0d0;
}

/* --- Window --- */
.window {
    position: absolute;
    top: 50px;
    left: 150px;
    width: 450px;
    min-height: 250px;
    background: #c0c0c0;
    padding: 3px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-width: 260px;
    border: 2px solid;
    border-color: #dfdfdf #808080 #808080 #dfdfdf;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
}

.window.minimized {
    display: none;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 34px) !important;
}

.title-bar {
    background: linear-gradient(to right, #000080, #1084d0);
    color: white;
    padding: 4px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    cursor: move;
    flex-shrink: 0;
}

.title-bar-text {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}

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

.title-bar-controls button {
    width: 20px;
    height: 20px;
    background-color: #c0c0c0;
    font-family: "Marlett", "MS Sans Serif";
    font-size: 12px;
    padding: 0;
    line-height: 1;
    border: 2px solid;
    border-color: #dfdfdf #808080 #808080 #dfdfdf;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-bar-controls button:active {
    border-color: #808080 #dfdfdf #dfdfdf #808080;
}

.minimize-btn::before { content: "0"; }
.maximize-btn::before { content: "1"; }
.close-btn::before { content: "r"; }

.window.maximized .maximize-btn::before { content: "2"; }

.window-body {
    background: white;
    margin: 3px;
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
}

/* --- Resize Handles --- */
.resize-handle {
    position: absolute;
    z-index: 3;
}

/* corners */
.resize-nw, .resize-ne, .resize-se, .resize-sw {
    width: 12px;
    height: 12px;
}

.resize-nw { top: -2px; left: -2px; cursor: nwse-resize; }
.resize-ne { top: -2px; right: -2px; cursor: nesw-resize; }
.resize-se { bottom: -2px; right: -2px; cursor: nwse-resize; }
.resize-sw { bottom: -2px; left: -2px; cursor: nesw-resize; }

/* edges */
.resize-n, .resize-s { left: 6px; right: 6px; height: 6px; }
.resize-n { top: -2px; cursor: n-resize; }
.resize-s { bottom: -2px; cursor: s-resize; }
.resize-e, .resize-w { top: 6px; bottom: 6px; width: 6px; }
.resize-e { right: -2px; cursor: e-resize; }
.resize-w { left: -2px; cursor: w-resize; }

/* Hide resize handles when maximized */
.window.maximized .resize-handle {
    display: none;
}

/* Prevent accidental text selection while resizing */
body.resizing {
    user-select: none;
}

/* --- AOL Popup Styles --- */
.aol-popup {
    border: 4px solid #000080;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
    width: 400px;
}

.aol-title-bar {
    animation: flash 1s infinite;
}

@keyframes flash {
    0%, 100% { background: linear-gradient(to right, #ff4500, #ff8c00); }
    50% { background: linear-gradient(to right, #1e90ff, #4169e1); }
}

/* --- Popup2 Styles --- */
.popup2-window {
    border: 4px solid #ff0000;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
    width: 400px;
}

.popup2-window .title-bar {
    animation: flash2 1.5s infinite;
}

@keyframes flash2 {
    0%, 100% { background: linear-gradient(to right, #cd0639, #ff0746); }
    25% { background: linear-gradient(to right, #cd0639, #ff0746); }
    50% { background: linear-gradient(to right, #ffffff, #cccccc); }
    75% { background: linear-gradient(to right, #0a3161, #1157ad); }
}

.aol-popup .window-body {
    background: #f0f0f0;
    text-align: center;
}

.aol-popup .window-body h2 {
    color: #000080;
}

.aol-popup .window-body .promo-button,
.popup2-window .window-body .promo-button {
    background-color: #ffbf00;
    padding: 10px 20px;
    font-weight: bold;
    border: 2px outset #ffffff;
    cursor: pointer;
    font-size: 14px;
}

.aol-popup .window-body .promo-button:hover,
.popup2-window .window-body .promo-button:hover {
    background-color: #ffd700;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

/* --- Responsive Design --- */
@media (max-width: 640px) {
    .window {
        width: 95vw !important;
        min-height: 60vh;
        top: 2vh !important;
        left: 2.5vw !important;
        max-height: calc(100vh - 50px);
    }
    
    .window.maximized {
        width: 100vw !important;
        height: calc(100vh - 34px) !important;
        top: 0 !important;
        left: 0 !important;
    }
    
    #desktop {
        padding: 10px;
        gap: 15px;
        flex-direction: row;
    }
    
    .desktop-icon { 
        width: 70px; 
    }
    
    .desktop-icon img { 
        width: 40px; 
        height: 40px; 
    }
    
    .desktop-icon span { 
        font-size: 12px; 
    }
    
    .taskbar-btn { 
        max-width: 80px;
        font-size: 12px;
    }
    
    .start-menu { 
        width: 98vw; 
        z-index: 1000;
    }
    
    .context-menu {
        width: 90vw;
        left: 5vw !important;
    }
    
    /* Fix button sizing on mobile */
    .title-bar-controls button {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .title-bar-controls {
        gap: 4px;
    }
    
    /* Larger hit areas for resize handles on mobile */
    .resize-nw, .resize-ne, .resize-se, .resize-sw { 
        width: 16px; 
        height: 16px; 
    }
    
    .resize-n, .resize-s { 
        height: 10px; 
    }
    
    .resize-e, .resize-w { 
        width: 10px; 
    }
    
    /* Boot screen mobile */
    .boot-progress-container {
        width: 80vw;
        max-width: 300px;
    }
    
    .boot-logo {
        width: 80px;
        height: 80px;
    }
}

/* --- Print styles --- */
@media print {
    .taskbar,
    .start-menu,
    .boot-screen,
    .context-menu,
    .shutdown-dialog {
        display: none !important;
    }
    
    #desktop {
        background: white;
    }
}
