:root {
    --bg-color: #f0eee9;
    --text-color: #000000;
    --placeholder-color: #9e9e9e;
    --grid-gap: 40px;
}

* {
    box-sizing: border-box;
    margin: 0;
    margin: 0;
    padding: 0;

    /* Hide scrollbar globally */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Hide scrollbar for Chrome/Safari/Opera */
body::-webkit-scrollbar,
html::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Anchor for absolute positioning */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px 60px;
    font-size: 16px;
    letter-spacing: 0.5px;
    position: relative;
    /* For z-index context */
    width: 100%;
}

.bold {
    font-weight: 700;
}

.brand {
    transition: opacity 0.5s ease;
}

#cv-link {
    display: inline-block;
    transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
    z-index: 10;
}

a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

nav {
    position: relative;
}

#back-link {
    position: absolute;
    right: 0;
    top: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

body.cv-active #back-link {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.8s;
    /* Wait for CV slide to finish */
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    /* Ensure it takes full height minus header */
    min-height: 0;
}

.portfolio-slider {
    /* Absolute Centering */
    position: absolute;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;

    width: 680px; /* Viewport for one grid */
    display: flex;
    gap: 80px; /* Gap between grids */
    
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
    
    visibility: visible;
    transition: opacity 0.5s ease 0.3s, visibility 0s 0.3s;
    z-index: 1;
}

.portfolio-slider::-webkit-scrollbar {
    display: none;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 200px);
    grid-template-rows: repeat(2, 200px);
    gap: var(--grid-gap);
    flex-shrink: 0;
    scroll-snap-align: start;
}

.cv-container {
    width: 680px;
    /* Matches Grid Width: (200*3) + (40*2) */
    /* No fixed height so content can flow */

    position: absolute;
    top: 48%;
    left: 50%;

    /* 
       Grid is centered at 48% top, 50% left.
       Grid height is 440px -> half is 220px.
       Grid width is 680px -> half is 340px.
       Grid Top-Left is: top: calc(48% - 220px), left: calc(50% - 340px).
       
       So we position this container's Top-Left exactly there.
    */
    margin-top: -220px;
    margin-left: -340px;

    text-align: left;
    padding: 0;
    /* Align content flush with grid start */

    /* Container no longer scrolls directly, child does */
    overflow: hidden;
    height: 440px;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
    z-index: 5;
}

.cv-scrollable {
    height: 100%;
    overflow-y: auto;
    padding-bottom: 40px;
    /* Space for scroll icon */

    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.cv-scrollable::-webkit-scrollbar {
    display: none;
}

.scroll-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, rgba(240, 238, 233, 0), var(--bg-color));
    pointer-events: none;
    z-index: 6;
}

.scroll-icon {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: #000;
    z-index: 7;
    animation: bounce 2s infinite;
    pointer-events: none;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    40% {
        transform: translateX(-50%) translateY(-10px);
    }

    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

.cv-photo {
    width: 150px;
    height: auto;
    display: block;
    margin-bottom: 30px;
    filter: grayscale(100%);
    opacity: 0.9;
}

/* State Classes for Animation */
body.cv-active .brand {
    opacity: 0;
    pointer-events: none;
}

body.cv-active .portfolio-slider {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0s;
}

body.cv-active #cv-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease 0.3s, visibility 0s 0.3s;
}

/* CV Content Styling */
.cv-section {
    margin-bottom: 40px;
}

.cv-header {
    font-size: 18px;
    font-style: italic;
    font-weight: 700;
    /* Bold as requested */
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    /* Optional subtle separator */
    padding-bottom: 10px;
}

.cv-entry {
    margin-bottom: 25px;
}

.cv-title {
    font-size: 16px;
    /* Increased from 14px */
    font-style: italic;
    font-weight: 700;
    margin-bottom: 2px;
}

.cv-institution {
    font-size: 14px;
    /* Explicitly set smaller than title */
    font-style: italic;
    margin-bottom: 2px;
}

.cv-details {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
    font-style: italic;
}

.cv-list {
    margin-top: 5px;
    padding-left: 15px;
    font-size: 13px;
    list-style-type: none;
    /* Custom bullet or none? using dash */
}

.cv-list li {
    position: relative;
    padding-left: 10px;
    margin-bottom: 5px;
}

.cv-list li::before {
    content: "-";
    position: absolute;
    left: -5px;
}

/* Bio Active State */
#portfolio-label {
    transition: opacity 0.5s ease;
}

body.bio-active #portfolio-label {
    opacity: 0;
}

#bio-link {
    display: inline-block;
    transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1), font-weight 0.5s ease;
    position: relative;
    z-index: 10;
}

body.bio-active #bio-link {
    font-weight: 700;
}

body.bio-active .portfolio-slider {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0s;
}

body.bio-active #bio-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease 0.3s, visibility 0s 0.3s;
}

body.bio-active #back-link {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.5s;
}

/* Hide CV link when Bio is active if desired, or keep it visible. 
   User asked primarily to hide 'PORTFOLIO' text. 
   Keeping 'Curriculum Vitae' visible allows switching? 
   Let's keep it consistent: focus on Bio.
*/
body.bio-active #cv-link {
    opacity: 0;
    pointer-events: none;
}

.grid-item {
    position: relative;
    background-color: var(--placeholder-color);
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Ensure image doesn't spill out */
}

.grid-info {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent; /* Removed dark overlay */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 2;
    color: #ffffff; /* White text */
}

.grid-info h3 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.grid-info p {
    display: none; /* Hide subtitles */
}

.grid-item:hover .grid-info {
    opacity: 0;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensures image covers the square without distortion */
    display: block;
    opacity: 0.7;
    /* Less strong white overlay effect (more visible) */
    filter: grayscale(60%);
}

.grid-item:hover img {
    opacity: 1;
    filter: grayscale(0%);
}

@media (max-width: 768px) {
    header {
        padding: 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        text-align: left;
    }

    nav {
        display: block;
        width: 100%;
        position: relative;
    }

    #back-link {
        position: absolute;
        right: 0;
        top: 0;
        margin-top: 0;
    }

    .portfolio-slider {
        flex-direction: column;
        width: 100%;
        height: 490px; /* 3*150 + 2*20 = exactly 1 grid height */
        overflow-x: hidden;
        overflow-y: auto;
        scroll-snap-type: y mandatory;
        gap: 80px; /* Large gap so next grid is far away */
        align-items: center;
        top: 50%;
    }

    .grid-container {
        grid-template-columns: repeat(2, 150px);
        grid-template-rows: repeat(3, 150px);
        gap: 20px;
        scroll-snap-align: start;
    }

    .cv-container {
        width: 90%;
        left: 50%;
        top: 50%;
        margin-left: 0;
        margin-top: 0;
        transform: translate(-50%, -50%);
        height: 65vh;
    }
}

@media (max-width: 480px) {
    .portfolio-slider {
        height: 450px; /* 3*140 + 2*15 = exactly 1 grid height */
    }
    
    .grid-container {
        grid-template-columns: repeat(2, 140px);
        grid-template-rows: repeat(3, 140px);
        gap: 15px;
    }

    .cv-container {
        height: 60vh;
    }
}

footer {
    padding: 20px;
    text-align: center;
    font-size: 12px;
    color: #b0b0b0;
    /* Light gray for subtlety */
    font-weight: 300;
    margin-top: auto;
    /* Ensures it stays at bottom even if content is short */
}