:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --noise-opacity: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Galvij', sans-serif;
    font-weight: bold;
    font-size: 18pt;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2vw;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.fade-slow {
    transition: background-color 12s ease-in-out, color 12s ease-in-out;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--noise-opacity);
    transition: opacity 0.2s ease;
    background: url('data:image/svg+xml;utf8,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
}

body.fade-slow::before {
    transition: opacity 12s ease-in-out;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    width: calc(100% + 4vw);
    position: sticky;
    top: 0;
    margin-left: -2vw;
    margin-top: -2vw;
    padding: 2vw 2vw 1rem 2vw;
    background-color: transparent;
    z-index: 1000;
    transition: color 0.2s ease;
}

body.fade-slow .nav-container {
    transition: color 12s ease-in-out;
}

.site-title a {
    text-decoration: none;
    color: inherit;
}

.nav-buttons {
    display: flex;
    gap: 3vw;
}

.nav-item {
    color: inherit;
    text-decoration: none;
    background: none;
    border: none;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.nav-item:hover, .nav-item:focus {
    opacity: 0.5;
}

/* Order control */
.btn-work { order: 1; }
.btn-about { order: 2; }
.btn-invert { order: 3; text-transform: uppercase; }

html.invert {
    --bg-color: #000000;
    --text-color: #ffffff;
}

.content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}

.content-container p {
    text-align: center;
    line-height: 1.2;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.filters-wrapper {
    position: absolute;
    top: 100%;
    left: 0;
    display: flex;
    gap: 1.5rem;
    font-size: inherit;
    margin-top: 0.3rem;
    transition: opacity 0.3s ease;
    cursor: default;
}

.filters-wrapper.hidden {
    opacity: 0;
    pointer-events: none;
}

.filter-btn {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.filter-btn.inactive {
    opacity: 0.3;
}

/* Mobile Styling */
@media (max-width: 768px) {
    .nav-container {
        align-items: flex-start;
    }
    
    .nav-buttons {
        flex-direction: column;
        align-items: flex-end;
        gap: 0;
    }
    
    .nav-item {
        line-height: 1.1;
        padding-bottom: 0.2rem;
    }

    .filters-wrapper {
        position: fixed;
        left: 2vw;
        top: calc(2vw + 40px);
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }

    .filter-btn {
        line-height: 1.1;
        padding-bottom: 0.2rem;
    }
}

/* Works Layout */
.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    width: 100%;
    margin-top: 4rem;
    align-self: flex-start;
}

.work-thumbnail {
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.work-thumbnail.filtered-out {
    display: none;
}

.work-thumbnail-images {
    width: 100%;
    position: relative;
    aspect-ratio: 1 / 1;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Global: prevent image dragging */
img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    user-drag: none;
    user-select: none;
    -webkit-user-select: none;
}

.work-thumbnail img {
    display: block;
}

.work-thumbnail img.base-img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

.work-thumbnail img.fade-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    object-fit: contain;
}

.work-thumbnail:hover .work-thumbnail-images {
    opacity: 0.7;
}

.work-thumbnail-title {
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.work-thumbnail:hover .work-thumbnail-title {
    opacity: 1;
    transition: opacity 0.5s ease 0.3s;
}

.work-full-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 800px;
    margin-top: 2rem;
    gap: 2rem;
    text-align: left;
    align-self: center;
}

.work-image-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.work-image-container {
    position: relative;
    width: 100%;
}

.image-number {
    text-align: center;
    margin-bottom: 0.5rem;
}

.work-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.work-info {
    line-height: 1.4;
    white-space: pre-wrap;
}



.work-image-list img {
    width: 100%;
    height: auto;
    display: block;
}

/* Slower duration for seamless crossfading layout reflows (No blank screen!) */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.8s;
}
