.container, .column-adaptive, .column-single, .column-double, .row, h1, h2, h3, h3 a, h4, p, li, h6, button, .image-single,.image-double, .image-triple, .image-quadruple, .masonry-grid {
    /* outline: 1px solid var(--tertiary-colour); */
}
/* .complete { display: none; } */

/* ----- Variables ----- */
:root {
    /* Grid variables */
    --padding: 40px;
    --spacious-padding: calc(clamp(0px, calc( (30 / 71) * (100vw - 700px) ), 600px) + var(--padding));

    --gutter: calc(var(--padding) / 2);
    --tight-gutter: calc(var(--padding) / 4);
    --column-count: 4; /* Default column count, updated by JS */
    
    /* Colors */
    --background-colour: #ffffff;
    --foreground-colour: #000000;
    --grey-colour: #eaeaea;
    --tertiary-colour: #2d78e1;

    --background-video-filter: invert(0) hue-rotate(0deg);
    /* --inner-shadow: inset 2px 2px 5px 0px rgba(255, 255, 255, 0.56), inset -1px -1px 5px 0px rgba(0, 0, 0, 0.1); */
    --inner-shadow: inset 0 0 10px 10px rgba(246, 218, 33, 1);
    --outer-shadow: 0 0 10px 10px rgba(246, 218, 33, 1);
}
.dark-mode {
    --background-video-filter: invert(1) hue-rotate(180deg);
}

/* ----- Reset ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Apply gradient directly to body */
body {
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

.video-background {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -1;
    object-fit: cover;

    filter: var(--background-video-filter);
}

*::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* ----- Typography ----- */
@font-face {
    font-family: 'YZE';
    src: url('./assets/fonts/YZE.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

h1, h2, h3, h3 a, h4, .h4-link, p, ul, li, h6, button {
    font-family: 'YZE', sans-serif;
    color: var(--foreground-colour);

    font-variant-ligatures: common-ligatures contextual;
    font-feature-settings: "calt" on, "liga" on, "dlig" on;

    padding-left: 2px;
}

h1 {
    /* margin-bottom: var(--gutter);  */
    margin-bottom: var(--tight-gutter);
    margin-top: var(--tight-gutter);

    font-size: 94px; 
    letter-spacing: -0.06em; 
    font-weight: 400; 
    font-style: normal; 
    line-height: normal;
}

h2 {
    /* margin-bottom: var(--gutter);  */
    margin-bottom: var(--tight-gutter);
    margin-top: var(--tight-gutter);

    font-size: 58px; 
    letter-spacing: -0.04em; 
    font-weight: 400; 
    font-style: normal; 
    line-height: normal;
}

h3, h3 a {
    margin-bottom: var(--tight-gutter);
    margin-top: var(--tight-gutter);

    font-size: 36px; 
    line-height: 34px;
    letter-spacing: -0.02em; 
    font-weight: 400; 
    font-style: normal; 
}

h4, .h4-link, button {
    /* margin-bottom: var(--gutter);  */
    margin-bottom: var(--tight-gutter);

    /* margin-top: var(--tight-gutter); */
    /* margin-top: var(--gutter); */

    font-size: 21px; 
    line-height: 20px; 
    font-weight: 400; 
    font-style: normal; 
}

p, li {
    /* margin-bottom: var(--gutter);  */
    margin-bottom: var(--tight-gutter);
    /* margin-bottom: 0px; */

    font-size: 14px; 
    line-height: 15px; 
    letter-spacing: 0.02em; 
    font-weight: 400; 
    font-style: normal; 
}

h6 {
    margin-bottom: var(--gutter); 
    font-size: 10px; 
    line-height: 10px; 
    letter-spacing: 0.02em; 
    font-weight: 400; 
    font-style: normal; 
}

.indent {
    text-indent: var(--gutter);
}

a, a:visited {
    color: var(--foreground-colour);
    text-decoration: underline;
    text-decoration-color: var(--tertiary-colour);
}

button, .read-more {
    border: none;
    width: 100%;
    /* border-radius: var(--tight-gutter); */

    padding-top: var(--tight-gutter);
    padding-bottom: calc(var(--tight-gutter) / 2);
    padding-left: var(--tight-gutter);
    padding-right: var(--tight-gutter);

    margin-top: var(--tight-gutter);
    margin-bottom: var(--gutter);
}
button {
    padding-bottom: var(--tight-gutter);
    background-image: url('./assets/Button.gif');
    background-size: cover;
    background-position: center;
    position: relative;

    overflow: hidden;
}

.read-more {
    background-color: var(--grey-colour);
    
    font-size: 21px;
    line-height: 20px;
}
.read-more p { color: var(--foreground-colour); }
.read-more-toggle { cursor: pointer; }


.right-align { 
    text-align: right; 
    /* margin-top: var(--gutter);  */
}

.annotation {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    overflow-y: auto;
}

.annotation p {
    margin-bottom: 0;
}

.invisible {
    font-size: 6px;
    color: var(--background-colour);
    opacity: 0.1;
}


img, video, .iframe-video {
    position: relative;
    max-width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    /* border-radius: var(--tight-gutter);  */
}
.image-single img, .image-single video, .image-single iframe,
.image-double img, .image-double video, .image-double iframe,
.image-triple img, .image-triple video, .image-triple iframe,
.image-quadruple img, .image-quadruple video, .image-quadruple iframe,
.fullscreen-image img, .fullscreen-image video, .fullscreen-image iframe {
    position: relative;
}

.iframe-video {
    width: 100%;
    height: 500px;
}

button, .read-more, img, video {
    /* border-width: 1px;
    border-style: solid;
    border-image: linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.25) 0%,
      rgba(255, 255, 255, 0.25) 100%
    );
    border-image-slice: 1; */

    filter: drop-shadow(0px 3px 2px rgba(0, 0, 0, 0.3));
    
    border-radius: var(--tight-gutter);
}

.node-img { /* Update existing */
    padding: var(--gutter); /* Use new variable */
    background-color: #191a1c;
}

/* ----- Grid System ----- */
.container {
    padding-left: var(--padding);
    padding-right: var(--padding);
    /* padding-top: var(--padding); */
    display: flex;
    flex-direction: column;
    background-color: transparent; /* Ensure body background is visible */
}

.vertical-central {
    justify-content: center;
    align-items: center;
    /* margin-top: calc(100vw / 30); */
    margin-top: calc(100vw / 60);
}

.spacious {
    padding-left: var(--spacious-padding);
    padding-right: var(--spacious-padding);
}

.row {
    margin-bottom: var(--tight-gutter);
}

.column-single {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.column-double {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gutter);
}

.column-double.left-weighted {
    grid-template-columns: 4fr 1fr;
}
.column-double.right-weighted {
    grid-template-columns: 1fr 2fr;
}

.header {
    width: calc(100vw - (var(--padding) * 2));

    /* Ensure header doesn't overlap content when scrolling */
    position: relative; 
    z-index: 2; /* Keep header above scrolling row */
    margin-bottom: var(--gutter); /* Add some space below header */
}

.column-directory {
    display: grid;
    grid-template-columns: 7fr 1fr;
    gap: var(--gutter);
}

/* Force grid items in column-triple to respect track sizing */
.column-double > *, .column-directory > * {
    min-width: 0;
}

/* Apply process column width specifically to rows within column-adaptive */
.column-adaptive > .row {
    margin-bottom: 0;
    /* width: 500px; */ /* Replaced by CSS variable */
    width: var(--process-column-width, 500px); /* Use variable, fallback to 500px */
    height: 100%;
    flex-shrink: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center; /* Added for horizontal centering */
}

/* ----- Media Styles ----- */
img, video {
    max-width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    /* border-radius: calc(var(--gutter) / 2); */
}
.research {
    opacity: 0.6;
}

.node-img {
    padding: calc(var(--gutter) / 2);
    background-color: #191a1c;
}

.rule-of-thirds {
    border: 1px solid #3063cc;
}

/* ----- Image Grid Styles ----- */
.image-grid {
    margin-bottom: var(--gutter);
    margin-top: var(--tight-gutter);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Common styles for all direct child containers within .image-grid */
.image-grid > [class*="image-"] { /* Catches .image-single, .image-double, .image-triple, .image-quadruple */
    width: 100%;
}

/* Styles for .image-single (and .single if used interchangeably) */
.image-grid .image-single, .image-grid .single {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Styles for .image-double, .image-triple, .image-quadruple */
.image-grid .image-double,
.image-grid .image-triple,
.image-grid .image-quadruple {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.image-grid .image-triple {
    flex-wrap: wrap; /* Specific to triple, for wrapping items */
}

/* --- Image/Video specific styles within image-grid containers --- */

/* Styles for img/video within .image-single (and .single) */
.image-grid .image-single img,
.image-grid .image-single video,
.image-grid .single img,
.image-grid .single video {
    width: 100%;
    height: auto;
}

/* Styles for img/video within .image-double */
.image-grid .image-double img,
.image-grid .image-double video {
    width: calc((100% - 10px) / 2); /* 1 gap of 10px */
    height: auto;
    object-fit: contain;
}

/* Styles for img/video within .image-triple */
.image-grid .image-triple img,
.image-grid .image-triple video {
    width: calc((100% - 2 * 10px) / 3); /* 2 gaps of 10px */
    height: auto;
    object-fit: contain;
    margin-bottom: 0;
}

/* Styles for img/video within .image-quadruple */
/* Assuming quadruple might follow a 2x2 pattern or similar, needs specific width if not 100% like single */
/* For now, it inherits object-fit: contain from a combined rule if we make one, or needs it explicitly */
.image-grid .image-quadruple img,
.image-grid .image-quadruple video {
    /* Example: width: calc((100% - 10px) / 2); if it's a 2x2 with one inter-column gap per row */
    /* Or: width: calc((100% - 3 * 10px) / 4); if it's 4 in a row */
    object-fit: contain;
    margin-bottom: 0; /* if consistent with .image-triple */
}

/* ----- Slider Styles ----- */
.slider-container {
    position: relative;
    width: 100%;
    height: 10px;
    margin-top: -20px;
    margin-bottom: 20px;
}

/* ----- Custom Cursor ----- */
.custom-cursor-area {
    cursor: none;
}

.custom-cursor {
    position: fixed;
    width: 200px;
    height: 200px;
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    display: none;
}

.custom-cursor.tamagotchu { background-image: url('./Unit2/Tamagotchu/Thumbnail.png'); }
.custom-cursor.dissertation { background-image: url('./Unit9/Dissertation/Thumbnail.png'); }
.custom-cursor.unit10 { background-image: url('./Unit10/Thumbnail.png'); }

.custom-cursor.active {
    opacity: 1;
    display: block;
    border-radius: var(--tight-gutter);
}

/* ----- Project Row Hover Effects ----- */
.project-row {
    cursor: none;
    position: relative;
    overflow: hidden;
    width: 100%;
    gap: var(--gutter);
    padding: var(--gutter);
    border-radius: var(--tight-gutter);
}

.project-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(125, 125, 125, 0.05);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.project-row:hover::before {
    opacity: 1;
}

/* ----- Project Grid Layout ----- */
.project-grid {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
    padding-bottom: var(--padding);
}

.project-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 120px 2fr;
    gap: var(--gutter);
    padding: var(--gutter);
    border-radius: var(--tight-gutter);
    transition: background-color 0.2s ease;
}

.project-row:hover {
    background-color: rgba(125, 125, 125, 0.05);
    cursor: pointer;
}

.project-title {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.project-date {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.project-desc {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

/* ----- ADDED STYLES FOR NEW GRID SYSTEM ----- */

/* Base grid container */
.grid-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    position: absolute;
    top: 0;
    left: 0;
    padding-top: var(--padding);
    padding-left: var(--padding);
    padding-right: var(--padding);
    overflow: hidden;
    z-index: 1;
    background-color: transparent; /* Ensure body background is visible */
}

/* Grid container that allows scrolling */
.grid-container-scroll {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    position: absolute;
    top: 0;
    left: 0;
    padding-top: var(--padding);
    padding-left: var(--padding);
    padding-right: var(--padding);
    overflow-y: auto;
    z-index: 1;
    padding-bottom: 100px; /* Extra padding for scrolling */
    background-color: transparent; /* Ensure body background is visible */
}

/* Scrollable section for multiple rows */
.scrollable-section {
    width: 100%;
    overflow-x: auto;
    padding-bottom: var(--gutter);
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.scrollable-section::-webkit-scrollbar {
    display: none;
}

/* Updated .row style for the new grid */
/* NOTE: This is a global .row style, potentially conflicting with older usages */
.column-adaptive {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    /* min-width: 100%; */ /* Let content define width for horizontal scroll */
    column-gap: var(--gutter);
    padding: 0;
    margin: 0; /* Reset margin */
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    flex-grow: 1; /* Allow row to fill available space */
}

.row::-webkit-scrollbar {
    display: none;
}

.column {
    width: calc((100vw - (var(--padding) * 2) - ((var(--column-count) - 1) * var(--gutter))) / var(--column-count));
    min-width: calc((100vw - (var(--padding) * 2) - ((var(--column-count) - 1) * var(--gutter))) / var(--column-count)); /* Prevent shrinking below calculated width */
    max-width: 500px; /* Add a max width? Or keep it purely dynamic? Let's keep it dynamic for now based on --column-count */
    height: 100%;
    background-color: transparent;
    outline: var(--outline-color); /* Use variable */
    overflow-y: auto; /* RE-ENABLED - Let column handle scrolling */
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
    pointer-events: auto !important; /* Ensure interaction */
    padding-bottom: var(--padding);
}

.column::-webkit-scrollbar {
    display: none;
}

.link-box img {
    margin-bottom: -20px;
}

/* Masonry Grid Layout */
.masonry-grid {
    display: block; /* Ensure block context for multi-column */
    columns: var(--column-count);
    column-gap: var(--gutter);
    width: 100%;
    margin-top: 1rem;
    overflow-y: visible;
    min-height: calc(100vh - 120px);
    padding-bottom: 120px; /* Extra padding for scrolling */
}
.masonry-item {
    break-inside: avoid;
    margin-bottom: var(--gutter);
    position: relative;
}
.masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--tight-gutter);
}

.date { /* New class */
    text-align: right;
}
.process-text p { /* New specific style */
    margin-bottom: 0px;
}

/* Updated Slider Styles (added margin-top fix) */
.slider-container {
    position: relative;
    width: 100%;
    height: 10px;
    /* margin-top: -20px; */ /* Removed negative margin, adjust layout if needed */
    margin-bottom: 20px;
    /* background-color: red; */ /* Removed debug background */
}

/* Styles for Fullscreen Media (handled by JS) */
.fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none; /* Initially hidden */
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 9999;
}

.fullscreen-image, .fullscreen-video {
    max-width: calc(100% - var(--padding, 40px) * 2); /* Use var with fallback */
    max-height: calc(100% - var(--padding, 40px) * 2); /* Use var with fallback */
    object-fit: contain;
    cursor: default;
    position: relative; /* Add this */
}
/* ----- END ADDED STYLES ----- */

.column-adaptive > .column {
    background-color: transparent;
}

.column-adaptive > .column iframe {
    background-color: transparent;
}

/* ----- Responsive Design ----- */
@media screen and (max-width: 800px) {

    .vertical-central {
        margin-top: 0;
    }

    /* Stack general double columns vertically */
    .column-double:not(.right-weighted) { /* Apply only if not right-weighted */
        grid-template-columns: 1fr; /* Change to single column layout */
        gap: var(--gutter); /* Maintain vertical gap */
    }

    /* Stack right-weighted columns using flexbox */
    .column-double.right-weighted {
        display: flex;
        flex-direction: column;
        gap: var(--gutter); /* Maintain vertical gap */
    }

    /* Order items within right-weighted columns */
    .column-double.right-weighted > .annotation {
        order: 2; /* Place annotation second */
    }
    .column-double.right-weighted > div:not(.annotation) {
        order: 1; /* Place the media div first */
    }

    .column-double.left-weighted.stubborn {
        grid-template-columns: 2fr 1fr;
    }
    .column-double.right-weighted.stubborn {
        grid-template-columns: 1fr 2fr;
    }

    /* Adapt column-directory layout for small screens */
    .column-directory {
        grid-template-columns: 1fr 3fr; /* 1/4 and 3/4 width */
        row-gap: var(--gutter); /* Add space between rows */
        /* You might want to adjust column-gap too if needed */
        /* column-gap: var(--gutter); */
    }
    .column-directory > *:first-child { /* Target the first item (the <a> tag) */
        grid-column: 1 / -1; /* Make it span all columns (the full width) */
    }
}

.collapsible-content {
    display: none;
}

.collapsible-content.visible {
    display: block;
}

/* ----- Hover Info ----- */
#hover-info {
    position: fixed;
    z-index: 10000; /* Ensure it's on top */
    /* background-color: var(--background-colour, #fff); */
    background-image: url('./assets/Button.gif');
    background-size: cover;
    background-position: center;
    border-radius: var(--tight-gutter, 5px); /* Fallback value */
    padding: var(--tight-gutter, 5px);
    display: flex; /* Changed from block to flex for side-by-side layout */
    flex-direction: column; /* Stack image and caption vertically */
    align-items: center; /* Center items if they don't fill width */
    gap: var(--tight-gutter, 5px);
    pointer-events: none; /* So it doesn't interfere with mouse events on underlying elements */
    max-width: 250px; /* Max width for the entire hover box */
}
#hover-thumbnail {
    max-width: 100%; /* Make thumbnail responsive within the hover-info box */
    height: auto;
    display: block; /* Remove extra space below image */
    border-radius: calc(var(--tight-gutter, 5px) / 2); /* Slightly smaller radius for thumbnail */
}
#hover-caption {
    font-family: 'YZE', sans-serif;
    font-size: 12px; /* Slightly smaller font for caption */
    line-height: 1.3;
    color: var(--foreground-colour, #000);
    margin: 0; /* Reset margin */
    padding: 0; /* Reset padding */
    text-align: left; /* Align caption text to the left */
    width: 100%; /* Ensure caption takes full width of its container part */
}

/* ----- Two Column Media Grid (for Unit9, Unit10, ML pages) ----- */
.two-column-media-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gutter, 20px); /* Use CSS variable with fallback */
    padding-top: var(--gutter, 20px); /* Add some padding at the top */
}

/* New Masonry style for specific 2-column media grids */
.media-masonry-grid-two-col {
    display: block; /* Necessary for multi-column layout */
    columns: 2;
    -webkit-columns: 2;
    -moz-columns: 2;
    column-gap: var(--gutter, 20px);
    padding-top: var(--gutter, 20px);
    width: 100%; /* Ensure it takes full width */
}

.media-grid-item {
    width: 100%;
    position: relative; /* For potential future absolute positioned elements inside */
    break-inside: avoid; /* Crucial for masonry items */
    margin-bottom: var(--gutter, 20px); /* Add bottom margin for spacing between items in a column */
}

.media-grid-item img,
.media-grid-item video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--tight-gutter, 5px); /* Consistent border radius */
    cursor: default; /* Default cursor for items, hover script handles hover display */
}

/* Ensure videos with controls are interactive */
.media-grid-item video[controls] {
    cursor: auto; /* Allow interaction with video controls */
}
