/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme Colors */
:root {
    --bg-color: #e0e0d7;
    --text-color: #292927;
    --border-color: #292927;
    --window-bg: #fff;
}

body.dark-mode {
    --bg-color: #292927;
    --text-color: #e0e0d7;
    --border-color: #e0e0d7;
    --window-bg: #1a1a18;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: Arial, sans-serif;
    font-size: 10pt;
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Pile Container */
#pile {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Base Window Style */
.window {
    position: absolute;
    border: 1px solid var(--border-color);
    background: var(--window-bg);
    cursor: grab;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.window:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Close Button */
.window-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    font-size: 10px;
    line-height: 14px;
    text-align: center;
    cursor: pointer;
    z-index: 1;
    color: var(--text-color);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.window-close:hover {
    background: var(--text-color);
    color: var(--bg-color);
}

/* Image Windows */
.window-image {
    transform-origin: center;
}

.window-image img {
    display: block;
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;

    /* Full saturation */
    filter: none;
    transition: filter 0.1s ease;
}

/* Active window - full color and dynamic size (instant scale) */
.window-image.active {
    /* Transform applied dynamically via JavaScript */
    /* border-width applied dynamically via JavaScript */
}

.window-image.active img {
    filter: none;
}

/* Counter-scale close button on active windows to keep original size */
.window-image.active .window-close {
    /* Transform applied dynamically via JavaScript */
    transform-origin: top right;
}

/* Link Card Windows */
.window-link {
    padding: 12px 28px 12px 12px;
    min-width: 120px;
    max-width: 250px;
    font-size: 11px;
    color: var(--text-color);
}

.window-link-title {
    margin-bottom: 4px;
}

.window-link-year {
    opacity: 0.6;
    font-size: 10px;
}

/* Fixed Header */
.header {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-name {
    display: inline-block;
    font-size: 10pt;
    line-height: 1.2;
    color: var(--text-color);
    text-decoration: none;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.header-name:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

.header-cv {
    display: inline-block;
    font-size: 10pt;
    line-height: 1.2;
    color: var(--text-color);
    text-decoration: none;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.header-cv:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 10pt;
    line-height: 1.2;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.dark-mode-toggle:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Links Only Toggle */
.links-toggle {
    position: fixed;
    top: 20px;
    right: 68px;
    z-index: 10000;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 10pt;
    line-height: 1.2;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.links-toggle:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
}

.links-toggle.active {
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    #pile {
        min-height: 100vh;
        padding-bottom: 100px;
    }

    /* Larger touch targets for close button - positioned inside window */
    .window-close {
        width: 36px;
        height: 36px;
        font-size: 20px;
        line-height: 34px;
        top: 4px;
        right: 4px;
    }

    /* Constrain images on mobile */
    .window-image img {
        max-width: 160px;
        max-height: 160px;
    }

    /* Larger link cards for better tap targets */
    .window-link {
        min-width: 140px;
        padding: 14px 44px 14px 14px;
        font-size: 13px;
    }

    .window-link-title {
        font-size: 13px;
    }

    .window-link-year {
        font-size: 11px;
    }

    /* Header adjustments */
    .header {
        top: 10px;
        left: 10px;
        gap: 8px;
    }

    .header-name,
    .header-cv {
        padding: 10px 12px;
        font-size: 9pt;
    }

    /* Toggle buttons - larger touch targets */
    .dark-mode-toggle,
    .links-toggle {
        padding: 10px 12px;
        font-size: 9pt;
    }

    .dark-mode-toggle {
        top: 10px;
        right: 10px;
    }

    .links-toggle {
        top: 10px;
        right: 58px;
    }
}

/* Very small screens */
@media screen and (max-width: 400px) {
    .window-image img {
        max-width: 130px;
        max-height: 130px;
    }

    .header {
        flex-wrap: wrap;
        max-width: 45%;
    }

    .header-name,
    .header-cv {
        padding: 8px 10px;
        font-size: 8pt;
    }
}
