/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* Colors */
    --bg-color: #000;
    --text-color: #FFF;
    --text-muted: #ccc;
    --window-bg: rgba(20, 20, 20, 0.8);
    --top-bar-bg: rgba(30, 30, 30, 0.5);
    --icon-bg: rgba(255, 255, 255, 0.1);
    --border-color: rgba(255, 255, 255, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.5);

    /* Window Controls */
    --btn-close: #ff5f56;
    --btn-max: #27c93f;

    /* Fonts */
    --font-main: 'VT323', monospace;
    --font-title: 'Press Start 2P', cursive;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: default;
}

/* =========================================
   2. DESKTOP LAYOUT
   ========================================= */
#desktop {
    background-image: url("../images/background.avif");
    background-size: cover;
    background-position: center;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Grainy texture overlay */
#desktop::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUEUgAAADIAAAAyCAMAAAAp4XiGAAAAA1BMVEX///+nxBvIAAAAEElEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
    opacity: 0.08;
    pointer-events: none;
    z-index: 1;
}

#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background: var(--top-bar-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    user-select: none;
}

#top-bar-title {
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.desktop-title {
    font-family: var(--font-title);
    font-size: 1.685rem;
    line-height: 1.8;
    position: absolute;
    top: 48%;
    left: 25%;
    transform: translateY(-50%);
    color: var(--text-color);
    text-shadow: 2px 2px 0px #000000, 3px 3px 0px #3c3c3c;
    z-index: 2;
    text-align: left;
}

/* =========================================
   3. DESKTOP ICONS
   ========================================= */
#desktop-icons {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2.2rem;
    padding: 8px 20px;
    z-index: 5;
    background: var(--icon-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    /* Semantic List Reset */
    list-style: none;
    margin: 0;
}

.desktop-icon {
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.desktop-icon:hover {
    transform: scale(1.15) translateY(-8px);
}

.desktop-icon img {
    height: 64px;
    width: auto;
    object-fit: contain;
}

.desktop-icon p {
    font-size: 14px;
    margin-top: 6px;
    text-shadow: 2px 2px 4px #000;
    opacity: 0;
    transition: opacity 0.2s;
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.desktop-icon:hover p {
    opacity: 1;
}

/* =========================================
   4. WINDOW SYSTEM
   ========================================= */
.window {
    position: absolute;
    width: 640px;
    max-width: 90vw;
    height: 480px;
    max-height: 80vh;
    background: var(--window-bg);
    border: 1px solid #666;
    border-radius: 8px;
    box-shadow: 0 10px 30px var(--shadow-color);
    display: none;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    z-index: 10;
    backdrop-filter: blur(15px);
    animation: open-window 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.window.maximized {
    top: 30px !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% - 30px) !important;
    border-radius: 0;
    border: none;
    resize: none;
    max-width: 100vw;
    max-height: 100vh;
}

.window.image-viewer {
    background: rgba(10, 10, 10, 0.9);
}

.window.image-viewer .window-body {
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.window.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.title-bar {
    background: rgba(50, 50, 50, 0.9);
    padding: 8px 12px;
    cursor: default;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #666;
}

.title-bar-text {
    font-weight: bold;
    color: var(--text-muted);
}

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

.control-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.close-btn {
    background-color: var(--btn-close);
}

.maximize-btn {
    background-color: var(--btn-max);
}

.window-body {
    padding: 20px;
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Scrollbar */
.window-body::-webkit-scrollbar {
    width: 8px;
}

.window-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.window-body::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}

/* =========================================
   5. COMPONENT STYLES
   ========================================= */
.profile-pic-viewer .window-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.profile-pic-viewer img {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #555;
}

#profile-pic {
    cursor: pointer;
    transition: transform 0.2s;
}

#profile-pic:hover {
    transform: scale(1.05);
}

#about-me-content img {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    border: 3px solid #555;
    object-fit: cover;
}

/* Cards & Links */
.project-card,
.repo-card,
.contact-link,
.skill-item,
.cert-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 15px;
    transition: background-color 0.2s, transform 0.2s;
    cursor: pointer;
}

.contact-link,
.skill-item {
    cursor: default;
}

.contact-link[href] {
    cursor: pointer;
}

.project-card:hover,
.repo-card:hover,
.contact-link:hover,
.skill-item:hover,
.cert-item:hover {
    background-color: var(--icon-bg);
    transform: translateY(-3px);
}

.project-gallery img {
    border-radius: 4px;
    border: 1px solid #555;
    cursor: pointer;
    transition: transform 0.2s;
}

.project-gallery img:hover {
    transform: scale(1.05);
}

/* =========================================
   6. ANIMATIONS
   ========================================= */
@keyframes open-window {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.window.closing {
    animation: close-window 0.3s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes close-window {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(0.8);
        opacity: 0;
    }
}

/* =========================================
   7. RESPONSIVE
   ========================================= */
@media (min-width: 769px) {
    #desktop-icons {
        width: 980px;
    }

    #about-me-content .md\:flex-row {
        align-items: center;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .desktop-title {
        left: 65%;
        top: 47%;
        font-size: 2.12rem;
    }
}

@media (max-width: 768px) {
    .desktop-title {
        font-size: 1.125rem;
        left: 5%;
        width: 90%;
        top: 47%;
    }

    #desktop-icons {
        width: 100%;
        bottom: 0;
        border-radius: 0;
        padding: 12px 15px;
        gap: 1.25rem;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .desktop-icon {
        transform: none !important;
    }

    .desktop-icon:hover {
        transform: none !important;
    }

    .desktop-icon img {
        height: 48px;
    }

    .desktop-icon p {
        opacity: 1;
        position: static;
        transform: none;
        background: none;
        text-shadow: none;
        color: #000;
        font-size: 11px;
        margin-top: 4px;
        white-space: nowrap;
        text-shadow: 0px 0px 2px #fff;
        font-weight: bold;
    }
}

/* Desktop wallpaper and grainy texture overlay */
#desktop {
    background-image: url("../images/background.avif");
    background-size: cover;
    background-position: center;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}

#desktop::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUEUgAAADIAAAAyCAMAAAAp4XiGAAAAA1BMVEX///+nxBvIAAAAEElEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
    opacity: 0.08;
    pointer-events: none;
    z-index: 1;
}

/* Top bar styling */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30px;
    background: rgba(30, 30, 30, 0.5);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    user-select: none;
}

#top-bar-title {
    font-family: 'VT323', monospace;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #ccc;
}

.desktop-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.685rem;
    line-height: 1.8;
    position: absolute;
    top: 48%;
    left: 25%;
    transform: translateY(-50%);
    color: #fff;
    text-shadow: 2px 2px 0px #000000, 3px 3px 0px #3c3c3c;
    z-index: 2;
    text-align: left;
}

/* Container for desktop icons */
#desktop-icons {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2.2rem;
    flex-wrap: nowrap;
    padding: 8px 20px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Styling for desktop icons */
.desktop-icon {
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.desktop-icon:hover {
    transform: scale(1.15) translateY(-8px);
}

.desktop-icon img {
    height: 64px;
    width: auto;
    object-fit: contain;
}

.desktop-icon p {
    font-size: 14px;
    margin-top: 6px;
    text-shadow: 2px 2px 4px #000;
    opacity: 0;
    transition: opacity 0.2s;
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.desktop-icon:hover p {
    opacity: 1;
}

/* Generic styling for all interactive windows */
.window {
    position: absolute;
    width: 640px;
    max-width: 90vw;
    height: 480px;
    max-height: 80vh;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid #666;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    z-index: 10;
    backdrop-filter: blur(15px);
    animation: open-window 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.window.maximized {
    top: 30px !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100% - 30px) !important;
    border-radius: 0;
    border: none;
    resize: none;
    max-width: 100vw;
    max-height: 100vh;
}

.window.image-viewer {
    background: rgba(10, 10, 10, 0.9);
}

.window.image-viewer .window-body {
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.window.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.profile-pic-viewer .window-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.profile-pic-viewer img {
    width: 250px;
    height: 250px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #555;
}

/* Keyframe animation for window opening */
@keyframes open-window {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Keyframe animation for window closing */
.window.closing {
    animation: close-window 0.3s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes close-window {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(0.8);
        opacity: 0;
    }
}

/* Window title bar */
.title-bar {
    background: rgba(50, 50, 50, 0.9);
    padding: 8px 12px;
    cursor: default;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #666;
}

.title-bar-text {
    font-weight: bold;
    color: #ccc;
}

/* Mac-style window control buttons */
.title-bar-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.close-btn {
    background-color: #ff5f56;
}

.maximize-btn {
    background-color: #27c93f;
}

/* Window content area */
.window-body {
    padding: 20px;
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1.1rem;
    line-height: 1.6;
}

.window-body a {
    cursor: pointer;
}

/* Custom scrollbar for window content */
.window-body::-webkit-scrollbar {
    width: 8px;
}

.window-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.window-body::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}

/* Specific content styles */
#profile-pic {
    cursor: pointer;
    transition: transform 0.2s;
}

#profile-pic:hover {
    transform: scale(1.05);
}

#about-me-content img {
    width: 128px;
    height: 128px;
    border-radius: 50%;
    border: 3px solid #555;
    object-fit: cover;
}

.project-card,
.repo-card,
.contact-link,
.skill-item,
.cert-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 15px;
    transition: background-color 0.2s, transform 0.2s;
}

.project-card,
.cert-item {
    cursor: pointer;
}

.project-card:hover,
.repo-card:hover,
.contact-link:hover,
.skill-item:hover,
.cert-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
}

.project-gallery img {
    border-radius: 4px;
    border: 1px solid #555;
    cursor: pointer;
    transition: transform 0.2s;
}

.project-gallery img:hover {
    transform: scale(1.05);
}


/* Desktop & Tablet Responsive Styles */
@media (min-width: 769px) {
    #desktop-icons {
        width: 980px;
        /* Wider taskbar for PCs */
    }

    #about-me-content .md\:flex-row {
        align-items: center;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .desktop-title {
        left: 65%;
        top: 47%;
        font-size: 2.12rem;
    }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .desktop-title {
        font-size: 1.125rem;
        left: 5%;
        width: 90%;
        top: 47%;
    }

    #desktop-icons {
        width: 100%;
        bottom: 0;
        border-radius: 0;
        padding: 12px 15px;
        gap: 1.25rem;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #desktop-icons::-webkit-scrollbar {
        height: 4px;
    }

    #desktop-icons::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.2);
    }

    #desktop-icons::-webkit-scrollbar-thumb {
        background-color: #555;
        border-radius: 2px;
    }

    .desktop-icon {
        transform: none !important;
    }

    .desktop-icon:hover {
        transform: none !important;
    }

    .desktop-icon img {
        height: 48px;
    }

    .desktop-icon p {
        opacity: 1;
        position: static;
        transform: none;
        background: none;
        text-shadow: none;
        color: #000;
        font-size: 11px;
        margin-top: 4px;
        white-space: nowrap;
    }
}

/* =========================================
   TRYHACKME BADGE
   ========================================= */
#thm-badge-container {
    position: absolute;
    top: 5%;
    /* Shifted to 5% to match blue rectangle guide */
    left: 52%;
    /* Keep the 52% left shift */
    transform: translateX(-50%);
    width: 35%;
    height: 108px;
    max-width: 420px;
    min-width: 340px;
    z-index: 4;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);

    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 10px;
}

@media (max-width: 768px) {
    #thm-badge-container {
        top: 12%;
        /* Shifted to 12% to match red rectangle guide */
        bottom: auto;
        /* Remove bottom positioning */
        left: 50%;
        /* Center alignment */
        width: 90%;
        /* Resized to fit red rectangle width */
        height: auto;
        min-height: 110px;
        max-width: none;
        min-width: auto;
    }
}