/* ============================================
   1. VARIABLES & BASE
   ============================================ */

:root {
    --xp-blue: #0053e1;
    --xp-blue-dark: #0030ad;
    --xp-header-gradient: linear-gradient(to bottom, #0058e6 0%, #0869ff 4%, #0050ee 14%, #003dd7 43%, #0030ad 80%, #0030ad 100%);
    --xp-bg: #ece9d8;
    --xp-green-start: linear-gradient(to bottom, #388238 0%, #53a353 10%, #388238 20%, #388238 90%, #245e24 100%);
    --glitch-green: #00ff41;
}

body {
    background: url('assets/WindowsXPWallpaper.jpg') no-repeat center center fixed;
    background-size: cover;
    margin: 0;
    padding: 0;
    font-family: "Tahoma", "Segoe UI", sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    filter: saturate(0.6) contrast(1.2) brightness(0.9);
    transition: filter 0.5s ease;
}

* {
    box-sizing: border-box;
}

/* ============================================
   2. COUCHES D'AMBIANCE (LOST MEDIA / URBEX)
   ============================================ */

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 3px, 3px 100%;
    z-index: 9999;
    pointer-events: none;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://commons.wikimedia.org/wiki/Category:Image_noise#/media/File:4k_Dissolve_Noise_Texture.png');
    opacity: 0.04;
    z-index: 9998;
    pointer-events: none;
    animation: noise-anim 0.2s infinite;
}

@keyframes noise-anim {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-1%, 1%); }
    100% { transform: translate(1%, -1%); }
}

/* ============================================
   3. BUREAU & ICÔNES
   ============================================ */

#desktop {
    width: 100%;
    height: calc(100vh - 30px);
    position: relative;
}

.desktop-icons {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, 85px);
    grid-template-rows: repeat(auto-fill, 90px);
    grid-gap: 25px;
    z-index: 5;
    position: relative;
}

.icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s;
}

.icon:active {
    transform: scale(0.95);
}

.icon img {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

.icon span {
    color: white;
    font-size: 11px;
    text-shadow: 1px 1px 2px black;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 4px;
    border-radius: 2px;
}

.icon:hover span {
    background: var(--xp-blue);
}

/* ============================================
   4. FENÊTRES XP (LUNA STYLE)
   ============================================ */

.window {
    position: absolute;
    min-width: 250px;
    background: var(--xp-bg);
    border: 3px solid var(--xp-blue);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.4);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.window-header {
    background: var(--xp-header-gradient);
    height: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px 0 10px;
    cursor: move;
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-shadow: 1px 1px 2px #000;
}

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

.window-controls button {
    width: 21px;
    height: 21px;
    border: 1px solid white;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.window-controls button:hover {
    filter: brightness(1.1);
}

.minimize-btn {
    background: var(--xp-blue);
}

.close-btn {
    background: linear-gradient(to bottom, #e76c3c 0%, #e9573f 10%, #d44e34 50%, #bc422b 100%);
}

.window-content {
    padding: 10px;
    color: #000;
    background: white;
    margin: 2px;
    border: 1px solid #808080;
    min-height: 80px;
    overflow-y: auto;
}

.window.minimized {
    display: none !important;
}

/* ============================================
   5. EFFETS NARRATIFS & HORREUR
   ============================================ */

/* Censure Léo */
.censored {
    background: #ff0000;
    color: #ff0000;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
    cursor: help;
}

.censored:hover {
    background: transparent;
    color: #ff0000;
}

/* Horloge hantée */
.glitch-clock {
    color: #ff0000 !important;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.8);
    animation: clock-vibrate 0.1s infinite;
}

@keyframes clock-vibrate {
    0% { transform: translate(0, 0); }
    50% { transform: translate(-1px, 1px); }
    100% { transform: translate(1px, -1px); }
}

/* Photos corruptibles */
.corruptible-photo {
    width: 100%;
    filter: grayscale(1) contrast(1.2);
    transition: filter 0.3s, opacity 0.15s, transform 0.3s;
    cursor: crosshair;
}

.corruptible-photo:hover {
    filter: invert(1) contrast(2) hue-rotate(90deg);
}

/* Ghost Windows */
.ghost-window {
    pointer-events: none !important;
    z-index: 40 !important;
    opacity: 0.5;
    filter: hue-rotate(180deg) invert(0.1) blur(1px);
    animation: fadeOutGhost 0.5s forwards;
}

@keyframes fadeOutGhost {
    to {
        opacity: 0;
        transform: scale(0.98);
    }
}

/* ============================================
   6. BARRE DES TÂCHES
   ============================================ */

.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background: linear-gradient(to bottom, #245edb 0%, #3f8cf3 9%, #245edb 18%, #245edb 92%, #1941a5 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.3);
}

.start-button {
    height: 100%;
    padding: 0 15px;
    background: var(--xp-green-start);
    color: white;
    font-weight: bold;
    font-style: italic;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    border: none;
    cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.start-button:hover {
    filter: brightness(1.1);
}

.task-item {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    padding: 2px 10px;
    margin-left: 10px;
    font-size: 11px;
    cursor: pointer;
    border-radius: 2px;
}

.task-item:hover {
    background: rgba(255, 255, 255, 0.3);
}

#clock {
    margin-left: auto;
    color: white;
    padding-right: 15px;
    font-size: 12px;
    cursor: pointer;
}

/* ============================================
   7. TERMINAL & BSOD
   ============================================ */

#terminal {
    position: fixed;
    bottom: 40px;
    right: 20px;
    width: 250px;
    height: 150px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--glitch-green);
    z-index: 800;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.2);
}

.terminal-header {
    background: var(--glitch-green);
    color: black;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 5px;
}

#terminal-content {
    padding: 5px;
    color: var(--glitch-green);
    font-family: 'Courier New', monospace;
    font-size: 10px;
    overflow-y: auto;
    flex-grow: 1;
}

.log-entry {
    margin-bottom: 2px;
}

.log-entry.warning {
    color: #ff0000;
    font-weight: bold;
}

.bsod {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0000aa;
    color: white;
    font-family: 'Lucida Console', monospace;
    padding: 50px;
    z-index: 10000;
    display: none;
}

.bsod h1 {
    font-size: 16px;
    margin-bottom: 20px;
}

.bsod p {
    font-size: 14px;
    margin: 5px 0;
}

/* ============================================
   8. ÉVOLUTION DU GLITCH
   ============================================ */

body.glitch-level-1 { filter: contrast(1.2) saturate(0.8); }
body.glitch-level-2 { animation: shake 0.2s infinite; }
body.glitch-level-3 { filter: hue-rotate(180deg) invert(0.2); animation: shake 0.1s infinite; }

@keyframes shake {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 2px); }
    50% { transform: translate(2px, -2px); }
    75% { transform: translate(-2px, -2px); }
    100% { transform: translate(2px, 2px); }
}

/* ============================================
   9. LECTEUR DE PHOTOS
   ============================================ */

.photo-viewer-container {
    background: #7b7b7b;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #808080;
    margin: 2px;
}

.image-display {
    width: 100%;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: white;
}

.image-display img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.photo-toolbar {
    width: 100%;
    height: 40px;
    background: linear-gradient(to bottom, #f0f0f0 0%, #dcdcdc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-top: 1px solid #808080;
}

.photo-toolbar button {
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 4px;
    cursor: pointer;
}

.photo-toolbar button:hover {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid #999;
}

.photo-toolbar button img {
    width: 20px;
    height: 20px;
    display: block;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #a0a0a0;
}

/* ============================================
   10. STYLE DU JEU DÉMINEUR
   ============================================ */

.mine-cell {
    width: 25px;
    height: 25px;
    background: #bdbdbd;
    border: 2px outset #eee;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.mine-cell.revealed {
    border: 1px solid #7b7b7b;
    background: #c0c0c0;
}

.mine-cell.bomb {
    background: #ff4444;
    animation: clock-vibrate 0.1s infinite;
}

.mine-cell.flagged {
    background-color: #f1c40f;
    position: relative;
}

.mine-cell.flagged::after {
    content: "🚩";
    font-size: 14px;
}

/* ============================================
   11. POP-UPS DE SPAM (HORREUR)
   ============================================ */

.spam-popup {
    position: absolute;
    width: 200px;
    background: #ece9d8;
    border: 2px solid #0053e1;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.2);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: popIn 0.2s ease-out;
}

.spam-header {
    background: linear-gradient(to right, #e74c3c, #c0392b);
    color: white;
    padding: 3px 5px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

.spam-content {
    padding: 15px;
    text-align: center;
    font-size: 12px;
    color: black;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============================================
   12. ÉLÉMENTS GLOBAUX & RESPONSIVE
   ============================================ */

a {
    color: blue;
    text-decoration: underline;
    cursor: pointer;
}

a:hover {
    color: darkblue;
}

table {
    border-collapse: collapse;
}

table th, table td {
    padding: 5px 10px;
    border: 1px solid #ccc;
}

table th {
    font-weight: bold;
    text-align: left;
}

@media (max-width: 768px) {
    .desktop-icons { grid-template-columns: repeat(auto-fill, 70px); }
    .window { max-width: 90vw; }
    #terminal { width: 200px; height: 120px; }
}