/* Pixel Art Desktop & Window System Styles */

/* 1. DESKTOP WORKSPACE */
#desktop {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-desktop);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, var(--bg-desktop) 0%, var(--bg-dark) 100%);
    background-size: 24px 24px, 100% 100%;
}

/* 2. TOP SYSTEM BAR */
#topbar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
    background: var(--win-bg);
    border-bottom: 2px solid var(--win-border-dark);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    z-index: 10000;
    font-size: 8px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    color: var(--accent-gold);
}

.topbar-brand-icon {
    font-size: 11px;
}

.topbar-btn {
    padding: 3px 6px;
    font-size: 8px;
    height: 20px;
}

/* 3. DESKTOP ICONS GRID */
#desktop-icons {
    position: absolute;
    top: 36px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 50;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 68px;
    padding: 4px;
    background: transparent;
    border: 1px dashed transparent;
    color: var(--text-primary);
    text-align: center;
    transition: background 0.1s, transform 0.1s;
}

.desktop-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--win-border-light);
    transform: translateY(-2px);
}

.desktop-icon.active, .desktop-icon:focus {
    background: rgba(41, 173, 255, 0.25);
    border-color: var(--accent-cyan);
}

.desktop-icon-img {
    font-size: 24px;
    margin-bottom: 4px;
    filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.5));
}

.desktop-icon-label {
    font-size: 7.5px;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    line-height: 1.2;
    word-break: break-word;
}

/* 4. CHARACTER STAGE (CENTERPIECE) */
#character-stage {
    position: absolute;
    bottom: 42px;
    right: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 90;
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.4));
}

.character-container {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

#char-canvas {
    width: 256px;
    height: 256px;
    image-rendering: pixelated;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath d='M4,2 L7,2 L8,4 L9,2 L12,2 L14,5 L14,8 L8,14 L2,8 L2,5 Z' fill='%23ff3366' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E"), pointer;
}

#companion-canvas {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    margin-bottom: 8px;
    cursor: pointer;
}

.character-quickbar {
    margin-top: -12px;
    display: flex;
    gap: 6px;
    z-index: 100;
}

.character-quickbar button {
    font-size: 7.5px;
    padding: 4px 8px;
}

/* Desktop Window Default Positions */
@media (min-width: 769px) {
    #win-about { top: 48px; left: 105px; width: 440px; }
    #win-projects { top: 60px; left: 140px; width: 620px; }
    #win-skills { top: 80px; left: 180px; width: 480px; }
    #win-terminal { top: 100px; left: 210px; width: 500px; }
    #win-minigame { top: 70px; left: 240px; width: 520px; }
    #win-wardrobe { top: 90px; left: 260px; width: 440px; }
    #win-contact { top: 110px; left: 290px; width: 440px; }
}

/* 5. PIXEL WINDOWS */
.pixel-window {
    position: absolute;
    min-width: 340px;
    max-width: calc(100vw - 40px);
    background: var(--win-bg);
    border: 2px solid var(--win-border-dark);
    box-shadow: 
        inset 2px 2px 0 var(--win-border-light),
        inset -2px -2px 0 var(--win-border-dark),
        6px 6px 0 rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.pixel-window.hidden {
    display: none !important;
}

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

/* Window Titlebar */
.window-titlebar {
    height: 26px;
    background: var(--win-titlebar);
    border-bottom: 2px solid var(--win-border-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    cursor: move;
}

.pixel-window:focus-within .window-titlebar,
.pixel-window.active .window-titlebar {
    background: var(--win-titlebar-active);
}

.window-title-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.window-title-icon {
    font-size: 11px;
}

.window-title {
    font-size: 8.5px;
    color: var(--win-titlebar-text);
    text-shadow: 1px 1px 0 #000;
}

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

.window-control-btn {
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: #ff004d;
    color: #fff;
}

/* Window Content */
.window-body {
    padding: 12px;
    overflow-y: auto;
    max-height: calc(85vh - 70px);
}

/* 6. WINDOW CONTENTS - RPG CHARACTER SHEET (ABOUT) */
.char-sheet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 640px) {
    .char-sheet-grid {
        grid-template-columns: 1fr;
    }
}

.sheet-header {
    border-bottom: 2px solid var(--win-border-dark);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.sheet-name {
    font-size: 11px;
    color: var(--accent-gold);
    margin-bottom: 4px;
}

.sheet-class {
    font-size: 8px;
    color: var(--accent-cyan);
}

.stat-bar-container {
    margin-bottom: 8px;
}

.stat-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 7.5px;
    margin-bottom: 3px;
}

.stat-bar-track {
    width: 100%;
    height: 10px;
    background: #111;
    border: 1px solid var(--win-border-dark);
    box-shadow: inset 1px 1px 0 #000;
}

.stat-bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.bar-hp { background: var(--accent-primary); }
.bar-mp { background: var(--accent-cyan); }
.bar-exp { background: var(--accent-gold); }

.sheet-bio-box {
    margin-top: 10px;
    font-size: 8px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--win-border-dark);
}

.stat-val {
    color: var(--accent-green);
}

/* 7. PROJECTS WINDOW: RETRO CARTRIDGE DECK */
.projects-deck {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.cartridge-card {
    background: #201e38;
    border: 2px solid #100e20;
    box-shadow: 
        inset 1px 1px 0 #443e6a,
        inset -1px -1px 0 #100e20,
        3px 3px 0 rgba(0,0,0,0.3);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.cartridge-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-cyan);
}

.cartridge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.cartridge-title {
    font-size: 9.5px;
    color: var(--accent-gold);
}

.cartridge-badge {
    font-size: 7px;
    padding: 2px 5px;
    background: var(--accent-primary);
    color: #fff;
}

.cartridge-genre {
    font-size: 7.5px;
    color: var(--accent-cyan);
    margin-bottom: 6px;
}

.cartridge-desc {
    font-size: 8px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.cartridge-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.cartridge-tag {
    font-size: 7px;
    background: #111;
    color: #a0aec0;
    padding: 2px 4px;
    border: 1px solid #333;
}

.cartridge-actions {
    display: flex;
    gap: 6px;
}

.cartridge-actions .pixel-btn {
    flex: 1;
}

/* 8. SKILLS INVENTORY WINDOW */
.inventory-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 600px) {
    .inventory-container {
        grid-template-columns: 1fr;
    }
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.inventory-slot {
    aspect-ratio: 1;
    background: #191829;
    border: 2px solid #0f0e1a;
    box-shadow: inset 1px 1px 0 #3a3952;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    transition: background 0.1s ease;
}

.inventory-slot:hover {
    background: #292843;
    border-color: var(--accent-cyan);
}

.inventory-slot.active {
    background: #36345a;
    border-color: var(--accent-gold);
    box-shadow: 0 0 8px rgba(255, 236, 39, 0.4);
}

.slot-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.slot-name {
    font-size: 6.5px;
    line-height: 1.2;
}

.item-inspector {
    background: #161524;
    border: 2px solid #0f0e1a;
    padding: 10px;
}

.inspector-title {
    font-size: 10px;
    color: var(--accent-gold);
    margin-bottom: 4px;
}

.inspector-tier {
    font-size: 7.5px;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.inspector-power {
    font-size: 8px;
    color: var(--accent-green);
    margin-bottom: 6px;
}

.inspector-desc {
    font-size: 8px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* 9. TERMINAL WINDOW */
.terminal-window-body {
    background: #090a0f;
    padding: 8px;
    font-family: var(--font-terminal);
    font-size: 15px;
    line-height: 1.25;
    height: 280px;
    display: flex;
    flex-direction: column;
    border: 1px solid #1a1c2e;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    color: #4ade80;
    margin-bottom: 6px;
}

.terminal-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #22d3ee;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-family: var(--font-terminal);
    font-size: 15px;
}

.term-cmd { color: #fde047; font-weight: bold; }
.term-cyan { color: #22d3ee; }
.term-green { color: #4ade80; }
.term-yellow { color: #facc15; }
.term-red { color: #f87171; }
.term-prompt { color: #38bdf8; }

/* 10. ARCADE MINIGAME WINDOW */
.minigame-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#minigame-canvas {
    border: 3px solid #111;
    box-shadow: 0 4px 0 #000;
}

/* 11. WARDROBE / CUSTOMIZER WINDOW */
.wardrobe-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.wardrobe-section-title {
    font-size: 8px;
    color: var(--accent-cyan);
    margin-bottom: 6px;
}

.wardrobe-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* 12. CONTACT POST OFFICE WINDOW */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 7.5px;
    color: var(--accent-gold);
}

.form-input, .form-textarea {
    background: #181729;
    border: 2px solid #0f0e1a;
    box-shadow: inset 1px 1px 0 #3a3952;
    padding: 6px;
    color: #ffffff;
    font-family: var(--font-pixel);
    font-size: 8px;
    outline: none;
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--accent-cyan);
}

.form-textarea {
    resize: none;
    height: 70px;
}

.social-links-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.social-links-row .pixel-btn {
    flex: 1;
}

/* 13. BOTTOM TASKBAR & DOCK */
#taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    z-index: 10000;
}

.taskbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

#start-menu-btn {
    font-size: 8.5px;
    height: 24px;
    background: var(--accent-primary);
    color: #fff;
}

#taskbar-windows {
    display: flex;
    gap: 4px;
}

.taskbar-item {
    font-size: 7.5px;
    height: 24px;
    max-width: 130px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 8px;
}

.taskbar-item.active {
    background: var(--win-titlebar-active);
    color: #fff;
    box-shadow: inset 2px 2px 0 var(--win-border-dark);
}

.taskbar-dot {
    display: inline-block;
    width: 4px;
    height: 4px;
    background: var(--accent-green);
    margin-right: 5px;
}

/* PIXEL TOAST NOTIFICATION */
#pixel-toast {
    position: fixed;
    top: 38px;
    right: 16px;
    background: var(--accent-gold);
    color: #12121e;
    border: 2px solid #000;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.4);
    padding: 8px 12px;
    font-size: 8px;
    z-index: 999999;
    transition: transform 0.2s ease, opacity 0.2s ease;
    transform: translateY(-20px);
    opacity: 0;
    pointer-events: none;
}

#pixel-toast.show {
    transform: translateY(0);
    opacity: 1;
}


/* ========================================================= */
/* 14. MOBILE & RESPONSIVE ADAPTATIONS (PHONES & TABLETS)    */
/* ========================================================= */

@media (max-width: 768px) {
    /* TOPBAR */
    #topbar {
        height: 30px;
        padding: 0 4px;
        font-size: 7px;
    }

    .topbar-left, .topbar-right {
        gap: 4px;
    }

    .topbar-brand span:last-child {
        display: none; /* Keep just the star icon on mobile */
    }

    .topbar-btn {
        padding: 2px 4px;
        font-size: 6.5px;
        height: 20px;
    }

    #system-clock {
        font-size: 6.5px;
        display: none; /* Save space for buttons */
    }

    /* DESKTOP ICONS GRID ON MOBILE */
    #desktop-icons {
        top: 34px !important;
        left: 6px !important;
        right: 6px !important;
        width: calc(100vw - 12px) !important;
        max-width: 100vw !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        z-index: 40 !important;
    }

    .desktop-icon {
        width: 52px !important;
        height: 50px !important;
        padding: 2px !important;
    }

    .desktop-icon-img {
        font-size: 16px !important;
        margin-bottom: 2px !important;
    }

    .desktop-icon-label {
        font-size: 6px !important;
        line-height: 1.1 !important;
    }

    /* CHARACTER STAGE ON MOBILE */
    #character-stage {
        right: 2px !important;
        bottom: 34px !important;
        z-index: 70 !important;
        transform: scale(0.65) !important;
        transform-origin: bottom right !important;
        pointer-events: auto !important;
    }

    .character-quickbar {
        margin-top: -8px;
        gap: 3px;
    }

    .character-quickbar button {
        font-size: 6px;
        padding: 2px 4px;
    }

    .pixel-speech-bubble {
        min-width: 130px;
        max-width: 180px;
        font-size: 7px;
        padding: 6px 8px;
        bottom: calc(100% + 4px);
    }

    /* PIXEL WINDOWS AS MOBILE BOTTOM/CENTER SHEETS */
    #win-about, #win-projects, #win-skills, #win-terminal, #win-minigame, #win-wardrobe, #win-contact, .pixel-window {
        position: fixed !important;
        left: 6px !important;
        right: 6px !important;
        top: 34px !important;
        width: calc(100vw - 12px) !important;
        max-width: calc(100vw - 12px) !important;
        min-width: 0 !important;
        height: calc(100vh - 72px) !important;
        max-height: calc(100vh - 72px) !important;
        transform: none !important;
        z-index: 500 !important;
    }

    .window-titlebar {
        height: 28px;
        padding: 0 6px;
    }

    .window-title {
        font-size: 7.5px;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .window-body {
        padding: 8px;
        max-height: calc(100vh - 104px) !important;
        -webkit-overflow-scrolling: touch;
    }

    /* WINDOW INTERNAL GRIDS ON MOBILE */
    .char-sheet-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .sheet-name {
        font-size: 9.5px;
    }

    .sheet-class {
        font-size: 7px;
    }

    .stat-row {
        font-size: 7px;
    }

    .projects-deck {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cartridge-card {
        padding: 8px;
    }

    .cartridge-title {
        font-size: 8.5px;
    }

    .cartridge-desc {
        font-size: 7.5px;
    }

    .inventory-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .inventory-grid {
        gap: 6px;
    }

    .inventory-slot {
        padding: 4px;
    }

    .slot-icon {
        font-size: 16px;
        margin-bottom: 2px;
    }

    .slot-name {
        font-size: 5.5px;
    }

    .item-inspector {
        padding: 8px;
    }

    .inspector-title {
        font-size: 8.5px;
    }

    .inspector-desc {
        font-size: 7px;
    }

    /* MINIGAME ON MOBILE */
    #minigame-canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    /* TERMINAL ON MOBILE */
    .terminal-window-body {
        height: 240px;
        font-size: 13px;
    }

    /* WARDROBE ON MOBILE */
    .wardrobe-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* TASKBAR ON MOBILE */
    #taskbar {
        height: 32px;
        padding: 0 4px;
    }

    #taskbar-windows {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 110px);
    }

    .taskbar-item {
        font-size: 6.5px;
        height: 22px;
        max-width: 90px;
        padding: 0 6px;
    }

    .taskbar-right {
        display: none; /* Hide tip on mobile to give room to window tabs */
    }

    #start-menu-btn {
        font-size: 7px;
        height: 22px;
        padding: 0 6px;
    }
}
