@font-face {
    font-family: 'VGA';
    src: url('assets/vga.ttf') format('truetype');
}

/* CSS Variables for Consistency */
:root {
    --primary-bg: #008080; /* Teal */
    --window-bg: #c0c0c0; /* Silver */
    --highlight-bg: #d0d0d0; /* Light silver */
    --border-light: #ffffff; /* White */
    --border-dark: #000000; /* Black */
    --title-bar-start: #000080; /* Navy */
    --title-bar-end: #1084d0; /* Light blue */
    --text-dark: #000000; /* Black */
    --text-light: #ffffff; /* White */
    --link-color: #000080; /* Navy link */
    --hover-color: #ff00ff; /* Magenta hover */
    --shadow-light: #dfdfdf;
    --shadow-dark: #808080;
    --icon-size: 32px;
    --taskbar-height: 48px;
    --window-width: 800px;
    --window-height: 500px;
}

body {
    background-color: var(--primary-bg);
    font-family: 'VGA', 'MS Sans Serif', Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    color: var(--text-dark);
    cursor: default;
}

.desktop {
    position: relative;
    height: 100%;
    width: 100%;
    background: url('images/bg1.jpg') no-repeat center center;
    background-size: contain; /* Fit entire image without zooming */
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg, rgba(0,0,0,0.05), rgba(0,0,0,0.05) 1px, transparent 1px, transparent 2px);
    pointer-events: none;
    z-index: 1000;
    animation: flicker 5s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.95; }
}

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeOut 1s forwards 0.5s;
}

@keyframes fadeOut {
    to { opacity: 0; display: none; }
}

.loading-text {
    font-size: 16px;
    color: var(--text-light);
    text-shadow: 1px 1px var(--text-dark);
}

/* Desktop Icons */
.icon-grid {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 100px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1;
}

.desktop-icon {
    text-align: center;
    color: var(--text-light);
    text-decoration: none;
    width: 100%;
    transition: transform 0.2s ease-in-out;
}

.desktop-icon:hover {
    transform: translateY(-2px);
}

.desktop-icon span {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    text-shadow: 1px 1px 0 var(--text-dark);
}

.icon-image {
    width: var(--icon-size);
    height: var(--icon-size);
    background-size: cover;
    background-color: transparent;
    margin: 0 auto;
    transform: perspective(500px) translateZ(0);
    transition: transform 0.3s ease-in-out;
}

.desktop-icon:hover .icon-image {
    transform: perspective(500px) translateZ(10px);
}

.home-icon { background-image: url('images/home-icon.png'); }
.discography-icon { background-image: url('images/discography-icon.png'); }
.gallery-icon { background-image: url('images/gallery-icon.png'); }
.contact-icon { background-image: url('images/contact-icon.png'); }
.live-icon { background-image: url('images/live-icon.png'); }
.store-icon { background-image: url('images/store-icon.png'); }
.spotify-icon { background-image: url('images/spotify.png'); }
.skifree-icon { background-image: url('images/skifree.png'); }

.desktop-icon:active .icon-image {
    border: 1px dotted var(--text-light);
}

/* Window Styles */
.window {
    background-color: var(--window-bg);
    border: 2px solid var(--border-light);
    border-right-color: var(--border-dark);
    border-bottom-color: var(--border-dark);
    box-shadow: 2px 2px 0 var(--border-dark);
    position: absolute;
    width: var(--window-width);
    height: var(--window-height);
    min-width: 200px;
    min-height: 150px;
    z-index: 10;
    resize: both;
    overflow: auto;
    transition: transform 0.1s ease-in-out, opacity 0.2s ease-in-out;
}

.window.maximized {
    top: 0 !important;
    left: 90px !important;
    width: calc(100% - 100px) !important;
    height: calc(100vh - var(--taskbar-height)) !important;
    border-width: 2px !important;
    box-shadow: none !important;
    resize: none !important;
}

.window.active {
    z-index: 50;
    transform: scale(1.01);
}

.bio-window {
    top: 50px;
    left: 120px;
    opacity: 0;
    transform: translateY(-20px);
    animation: window-open 0.3s forwards;
}

.news-window {
    top: 100px;
    left: 300px; /* Shifted right to avoid overlap */
    width: 600px;
    height: 400px;
    opacity: 0;
    transform: translateY(-20px);
    animation: window-open 0.3s forwards;
}

.skifree-window {
    width: var(--window-width);
    height: var(--window-height);
    min-width: 300px;
    min-height: 200px;
    top: 50px; /* Consistent with bio-window */
    left: 120px; /* Consistent with bio-window */
}

@keyframes window-open {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title-bar {
    background: linear-gradient(to right, var(--title-bar-start), var(--title-bar-end));
    color: var(--text-light);
    padding: 2px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.title-bar-text {
    font-size: 14px;
    font-weight: bold;
}

.title-bar-controls {
    display: flex;
}

.title-bar-controls button {
    width: 16px;
    height: 16px;
    margin-left: 2px;
    background-color: var(--window-bg);
    border: 1px solid var(--border-light);
    border-right-color: var(--border-dark);
    border-bottom-color: var(--border-dark);
    cursor: pointer;
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    padding: 0;
    transition: background-color 0.2s ease-in-out;
}

.title-bar-controls button:hover {
    background-color: var(--highlight-bg);
}

.title-bar-controls button:active {
    border-style: inset;
}

.window-body {
    padding: 8px;
}

h1 {
    font-size: 20px;
    margin: 0 0 8px;
}

h2 {
    font-size: 16px;
    margin: 12px 0 8px;
}

p {
    font-size: 14px;
    line-height: 1.4;
}

p a, .news-link {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

p a:hover, .news-link:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

/* Tables (Discography, Concerts) */
.discography-table, .concert-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--highlight-bg);
    border: 1px solid var(--border-dark);
    box-shadow: inset 1px 1px 0 var(--border-light), inset -1px -1px 0 var(--shadow-dark);
}

.discography-table th, .discography-table td,
.concert-table th, .concert-table td {
    padding: 6px;
    font-size: 14px;
    border: 1px solid var(--shadow-dark);
    text-align: left;
}

.discography-table th, .concert-table th {
    background: linear-gradient(to bottom right, var(--title-bar-start), #0000c0);
    color: var(--text-light);
    text-shadow: 1px 1px 0 var(--text-dark);
}

.discography-table td a, .concert-table td a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

.discography-table td a:hover, .concert-table td a:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

.discography-table tr:nth-child(even), .concert-table tr:nth-child(even) {
    background-color: #e0e0e0;
}

.discography-table tr:hover, .concert-table tr:hover {
    background-color: #ffffcc;
}

.discography-table .divider, .concert-table .divider {
    background: linear-gradient(to bottom right, var(--shadow-dark), #a0a0a0);
    color: var(--text-light);
    font-weight: bold;
    text-align: center;
    text-shadow: 1px 1px 0 var(--text-dark);
    padding: 4px;
}

/* Taskbar */
.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--taskbar-height);
    background-color: var(--window-bg);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2px;
    box-shadow: inset 0 1px 0 var(--shadow-light), inset 0 -1px 0 var(--shadow-dark);
    z-index: 100;
    animation: flicker 10s infinite;
}

.start-button {
    background: url('assets/win98-logo.png') no-repeat 6px center, linear-gradient(to bottom, #c0c0c0, #e0e0e0);
    background-size: 22px;
    border: 2px outset var(--border-light);
    padding: 1px 8px 1px 34px;
    font-size: 12px;
    cursor: pointer;
    height: calc(var(--taskbar-height) - 8px);
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease-in-out;
}

.start-button:hover {
    background: url('assets/win98-logo.png') no-repeat 6px center, linear-gradient(to bottom, #d0d0d0, #f0f0f0);
    background-size: 22px;
}

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

.start-text {
    font-size: 12px;
    color: var(--text-dark);
}

.menu-dropdown {
    display: none;
    position: absolute;
    bottom: var(--taskbar-height);
    left: 0;
    width: 180px;
    background-color: var(--window-bg);
    border: 1px solid var(--border-light);
    border-right-color: var(--border-dark);
    border-bottom-color: var(--border-dark);
    box-shadow: 2px 2px 0 var(--shadow-dark);
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.1s ease-out, transform 0.1s ease-out;
    z-index: 99;
}

.menu-dropdown.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.menu-dropdown::before {
    content: "Robert Farrugia";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background-color: var(--title-bar-start);
    color: var(--text-light);
    font-size: 9px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-align: center;
    border-right: 1px solid var(--border-dark);
}

.menu-items {
    margin-left: 30px;
    padding: 2px 0;
}

.menu-items a, .menu-items button {
    display: flex;
    align-items: center;
    color: var(--link-color);
    text-decoration: none;
    padding: 3px 6px;
    font-size: 12px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu-items a:hover, .menu-items button:hover {
    background-color: var(--title-bar-start);
    color: var(--text-light);
}

.taskbar-items {
    flex-grow: 1;
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.taskbar-item {
    background-color: var(--window-bg);
    border: 2px outset var(--border-light);
    padding: 2px 8px;
    font-size: 12px;
    color: var(--link-color);
    cursor: pointer;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.taskbar-item:hover {
    background-color: var(--title-bar-start);
    color: var(--text-light);
}

.taskbar-item.active {
    border-style: inset;
    background-color: var(--highlight-bg);
}

.taskbar-clock {
    font-size: 12px;
    padding: 2px 4px;
    background-color: var(--window-bg);
    border: 1px solid var(--shadow-dark);
    border-right-color: var(--border-light);
    border-bottom-color: var(--border-light);
    box-shadow: inset 1px 1px 0 var(--shadow-light);
}

/* Bandcamp Player */
.bandcamp-player {
    margin-top: 20px;
    padding: 10px;
    background-color: var(--highlight-bg);
    border: 1px solid var(--shadow-dark);
    box-shadow: inset 1px 1px 0 var(--border-light);
}

.bandcamp-player iframe {
    width: 100%;
    height: 120px;
    border: 0;
}

.bandcamp-fallback {
    color: #ff0000;
    font-weight: bold;
}

/* Simplified Gallery */
.gallery-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100% - 40px); /* Account for h1 and padding */
    padding: 10px;
}

.gallery-image {
    max-width: 90%; /* Scale relative to window width */
    max-height: 60%; /* Scale relative to window height, leave space for caption/buttons */
    width: auto;
    height: auto;
    object-fit: contain; /* Maintain aspect ratio */
    border: 2px solid var(--border-dark);
    box-shadow: 2px 2px 0 var(--shadow-dark);
    margin-bottom: 10px;
}

.gallery-caption {
    font-size: 14px;
    color: var(--text-dark);
    text-align: center;
    background-color: var(--border-light);
    padding: 5px;
    border: 1px solid var(--shadow-dark);
    width: 80%;
    margin-bottom: 10px;
}

.gallery-controls {
    display: flex;
    gap: 10px;
}

.gallery-controls button {
    background-color: var(--window-bg);
    border: 2px outset var(--border-light);
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.gallery-controls button:hover {
    background-color: var(--highlight-bg);
}

.gallery-controls button:active {
    border-style: inset;
}

/* Social Links */
.social-links {
    margin-top: 20px;
}

.social-btn {
    display: inline-block;
    padding: 5px 10px;
    background-color: var(--window-bg);
    border: 2px outset var(--border-light);
    text-decoration: none;
    color: var(--link-color);
    margin-right: 10px;
    font-size: 14px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.social-btn:hover {
    background-color: var(--highlight-bg);
    color: var(--hover-color);
}

.social-btn:active {
    border-style: inset;
}

/* Songkick Button */
.songkick-btn {
    display: inline-block;
    padding: 5px 10px;
    background-color: var(--window-bg);
    border: 2px outset var(--border-light);
    text-decoration: none;
    color: var(--link-color);
    margin: 10px 0;
    font-size: 14px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.songkick-btn:hover {
    background-color: var(--highlight-bg);
    color: var(--hover-color);
}

.songkick-btn:active {
    border-style: inset;
}

/* News Window */
.news-item {
    margin-bottom: 15px;
}

.news-item h2 {
    font-size: 16px;
    margin: 10px 0 5px;
}

/* Store Image */
.store-image {
    max-width: 200px;
    height: auto;
    border: 2px solid var(--border-dark);
    box-shadow: 2px 2px 0 var(--shadow-dark);
    margin: 10px 0;
}

/* Contact Form */
.contact-form {
    margin-top: 20px;
}

.contact-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
}

.contact-form input, .contact-form textarea {
    width: 100%;
    padding: 5px;
    margin-bottom: 10px;
    border: 1px solid var(--border-dark);
    background-color: var(--border-light);
    font-family: 'VGA', 'MS Sans Serif', Arial, sans-serif;
    font-size: 14px;
}

.contact-form button {
    background-color: var(--window-bg);
    border: 2px outset var(--border-light);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease-in-out;
}

.contact-form button:hover {
    background-color: var(--highlight-bg);
}

.contact-form button:active {
    border-style: inset;
}

/* High Contrast Mode */
.high-contrast {
    background-color: var(--text-dark);
    color: var(--text-light);
}

.high-contrast .desktop {
    background-color: var(--text-dark);
}

.high-contrast .window {
    background-color: var(--text-dark);
    color: var(--text-light);
}

.high-contrast .title-bar {
    background: var(--title-bar-start);
}

.high-contrast .taskbar {
    background-color: var(--text-dark);
}

.high-contrast .start-button,
.high-contrast .taskbar-item,
.high-contrast .social-btn,
.high-contrast .contact-form button,
.high-contrast .songkick-btn {
    background-color: var(--text-dark);
    color: var(--text-light);
    border-color: var(--text-light);
}

.high-contrast .menu-items a, .high-contrast .menu-items button {
    color: var(--text-light);
}

.high-contrast .menu-items a:hover, .high-contrast .menu-items button:hover {
    background-color: var(--title-bar-start);
    color: var(--text-light);
}

.high-contrast .menu-dropdown {
    background-color: var(--text-dark);
}

.high-contrast .bandcamp-player {
    background-color: var(--text-dark);
}

.high-contrast .bandcamp-fallback {
    color: #ff0000;
}

.high-contrast .contact-form input,
.high-contrast .contact-form textarea {
    background-color: var(--text-dark);
    color: var(--text-light);
    border-color: var(--text-light);
}

.high-contrast .discography-table, .high-contrast .concert-table {
    background-color: var(--text-dark);
    color: var(--text-light);
}

.high-contrast .discography-table td, .high-contrast .concert-table td {
    border-color: var(--text-light);
}

.high-contrast .discography-table tr:nth-child(even), .high-contrast .concert-table tr:nth-child(even) {
    background-color: #333333;
}

.high-contrast .discography-table tr:hover, .high-contrast .concert-table tr:hover {
    background-color: #555555;
}

/* Mobile Styles */
@media (max-width: 600px) {
    body {
        image-rendering: pixelated;
        cursor: url('assets/retro-cursor.png'), auto;
    }

    .scanlines {
        background: repeating-linear-gradient(0deg, rgba(0,0,0,0.1), rgba(0,0,0,0.1) 1px, transparent 1px, transparent 2px);
        animation: flicker 3s infinite;
    }

    .taskbar {
        height: 60px;
        padding: 0 8px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: linear-gradient(to bottom, #d0d0d0, #a0a0a0);
        border-top: 3px solid var(--border-light);
        border-bottom: 3px solid var(--border-dark);
        box-shadow: 0 -1px 3px rgba(0,0,0,0.2);
        z-index: 200;
    }

    .start-button {
        width: auto;
        padding: 6px 12px 6px 34px;
        height: calc(60px - 10px);
        font-size: 12px;
        border: 3px outset var(--border-light);
        background: url('assets/win98-logo.png') no-repeat 6px center, linear-gradient(to bottom, #c0c0c0, #e0e0e0);
        background-size: 22px;
        box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
        transition: background-color 0.2s ease-in-out;
    }

    .start-button:hover {
        background: url('assets/win98-logo.png') no-repeat 6px center, linear-gradient(to bottom, #d0d0d0, #f0f0f0);
        background-size: 22px;
    }

    .start-button:active {
        border-style: inset;
        box-shadow: inset 1px 1px 2px rgba(0,0,0,0.3);
    }

    .taskbar-clock {
        font-size: 12px;
        padding: 6px 8px;
        height: calc(60px - 10px);
        display: flex;
        align-items: center;
        border: 3px inset var(--border-dark);
        background: linear-gradient(to bottom, #d0d0d0, #e0e0e0);
        box-shadow: inset 1px 1px 2px var(--shadow-light);
    }

    .taskbar-items {
        display: flex; /* Show taskbar items on mobile */
        overflow-x: auto; /* Allow horizontal scrolling */
        gap: 3px;
        margin-left: 5px;
        flex-grow: 1;
    }

    .taskbar-item {
        font-size: 10px; /* Smaller font for mobile */
        padding: 2px 6px;
        max-width: 100px; /* Compact width */
        height: calc(60px - 14px); /* Fit taskbar height */
        line-height: normal;
        display: flex;
        align-items: center;
    }

    .icon-grid {
        position: fixed;
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
        padding-bottom: 60px;
        z-index: 1;
    }

    .desktop-icon {
        width: 80px;
        margin: 0 auto;
        padding: 3px;
        border: 1px solid transparent;
        transition: border 0.2s ease-in-out;
    }

    .desktop-icon:hover {
        border: 1px dotted var(--text-light);
    }

    .icon-image {
        width: 48px;
        height: 48px;
    }

    .window {
        width: 100%;
        height: calc(100% - 60px);
        top: 0;
        left: 0;
        min-width: 0;
        min-height: 0;
        resize: none;
        border: 3px solid var(--border-light);
        box-shadow: 3px 3px 0 var(--border-dark);
    }

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

    .menu-dropdown {
        position: fixed;
        bottom: 60px; /* Align above taskbar */
        left: 0;
        width: 100%;
        height: 50vh;
        background-color: var(--window-bg);
        border-top: 1px solid var(--border-light);
        box-shadow: 0 -2px 5px rgba(0,0,0,0.3);
        transform: translateY(100%);
        transition: transform 0.3s ease-in-out;
        z-index: 100;
    }

    .menu-dropdown.active {
        transform: translateY(0);
    }

    .menu-items {
        padding: 10px;
        overflow-y: auto;
        height: 100%;
    }

    .menu-items a, .menu-items button {
        padding: 15px;
        font-size: 18px;
        display: block;
        border-bottom: 1px solid var(--shadow-dark);
    }

    .title-bar-text {
        font-size: 14px;
    }

    .title-bar-controls button {
        width: 24px;
        height: 24px;
        font-size: 14px;
        border: 2px outset var(--border-light);
    }

    .contact-form input, .contact-form textarea {
        padding: 10px;
        font-size: 16px;
        border: 2px inset var(--border-dark);
        background-color: #e0e0e0;
    }

    .contact-form button {
        padding: 10px 20px;
        font-size: 16px;
        border: 3px outset var(--border-light);
    }

    .social-btn, .songkick-btn {
        padding: 10px 20px;
        font-size: 16px;
        margin-bottom: 15px;
        border: 3px outset var(--border-light);
        background: linear-gradient(to bottom, #c0c0c0, #a0a0a0);
    }

    .gallery-image {
        max-width: 95%; /* Slightly larger for mobile */
        max-height: 50%; /* Adjusted for smaller screens */
    }

    .gallery-caption {
        width: 90%;
        font-size: 12px;
    }

    .gallery-controls button {
        padding: 8px 15px;
        font-size: 14px;
        border: 3px outset var(--border-light);
    }
}