/* =================================
   GLOBAL DESIGN CONTROLS
================================= */

:root {
    /* Typography */
    --font-nimbus: nimbus-sans-condensed, sans-serif;
    --font-plantin: plantin, serif;
    --font-neue: neue-haas-grotesk-display, sans-serif;

    --font-size-body: 15px;
    --font-size-heading: 16px;
    --font-size-title: 16px;
    --font-size-caption: 13px;
    --font-size-nav: 15px;

    /* Spacing */
    --space-small: 12px;
    --space-medium: 24px;
    --space-large: 48px;
    --space-huge: 100px;
    --below-profile: 120px;

    /* Layout */
    --page-width: 100%;
    --page-padding: 0px;
    --project-gap: 24px;
    --left-spill: 60px;
    --left-spill-negative: -60px;
    --carousel-image-ht: calc(100vh - 240px);
    --caption-offset-multiplier: 1;
    --title-bar-height: 21px;

    /* Colours */
    --filmmaking-color: hsl(11, 80%, 53%);
    --graphics-color: hsl(72, 80%, 43%);
    --fabrication-color: hsl(207, 80%, 53%);
    --yellow: yellow;

    --border-color: #222;
    --background-color: white;
}

/* =================================
   RESET
================================= */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html, body {
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: var(--font-nimbus);
    font-size: var(--font-size-body);
    background: var(--background-color);
    color: black;
}

h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    font-family: var(--font-neue);
    font-size: var(--font-size-heading);
    margin: 3px;
    letter-spacing: 3%;
    text-transform: uppercase;
    line-height: 1;
}

h2 {
    font-family: var(--font-nimbus);
    font-size: var(--font-size-body);
    font-weight: normal;
    padding-top: 3px;
    margin: 3px;
}

p {
    line-height: 1;
    margin: 3px;
}

a {
    color: inherit;
    text-decoration: none;
}

body:has(.category-section[open]) .profile {
    display: none;
}

/* =================================
   PROFILE HEADER
================================= */

.bg-video {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    background: black;
}

.sound-toggle {
    position: fixed;
    right: var(--space-medium);
    bottom: var(--space-medium);
    z-index: 1;
    /* above the video and page content */
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: var(--font-size-caption);
    color: white;
    /* readable over the video, change to suit */
    cursor: pointer;
}

.profile {
    max-width: var(--page-width);
    margin: auto;
    padding: var(--page-padding);
    margin-bottom: var(--below-profile);
    margin-left: var(--left-spill);

    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-image {
    height: 120px;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    margin-top: var(--space-huge);
    margin-left: var(--left-spill-negative);
}

.profile-image img {
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-text {
    max-width: 100%;
    color: white;
}

.profile-text p {
    max-width: 1200px;
    font-size: var(--font-size-body);
    font-family: var(--font-nimbus);
}

/* =================================
   CATEGORY NAVIGATION
================================= */

.category-nav {
    max-width: var(--page-width);
    margin: auto;
    padding: 0 var(--page-padding);

    display: flex;
    flex-direction: column;
}

.category-nav a,
.category-heading {
    display: block;
    padding: 0px var(--left-spill);
    color: var(--yellow);
    font-size: var(--font-size-nav);
    font-family: var(--font-nimbus);
    letter-spacing: 3%;
}

.filmmaking,
.graphics,
.fabrication {
    background: transparent;
}


/* =================================
   MAIN CONTENT
================================= */

main {
    max-width: var(--page-width);
    margin: auto;
    padding: 0 var(--page-padding);
}

.category-section {
    margin-bottom: 0px;
}

.category-heading.filmmaking:hover {
    background-color: var(--filmmaking-color);
    color: white;
    cursor: pointer;
    text-decoration: none;
}

.category-heading.graphics:hover {
    background-color: var(--graphics-color);
    color: white;
    cursor: pointer;
    text-decoration: none;
}

.category-heading.fabrication:hover {
    background-color: var(--fabrication-color);
    color: white;
    cursor: pointer;
    text-decoration: none;
}

.category-section[open] .category-heading.filmmaking {
    background-color: var(--filmmaking-color);
    color: white;
    text-decoration: none;
}

.category-section[open] .category-heading.graphics {
    background-color: var(--graphics-color);
    color: white;
    text-decoration: none;
}

.category-section[open] .category-heading.fabrication {
    background-color: var(--fabrication-color);
    color: white;
    text-decoration: none;
}

.category-container {
    display: flex;
    flex-direction: column;
}

/* Hide profile when a category is open */

body:has(.category-section[open]) .profile {
    display: none;
}

body:has(.category-section[open]) .bg-video {
    display: none;
}

body:has(.category-section[open]) .sound-toggle {
    display: none;
}

body:has(.category-section[open]) .category-heading.filmmaking {
    background-color: var(--filmmaking-color);
    color: white;
    text-decoration: none;
}

body:has(.category-section[open]) .category-heading.graphics {
    background-color: var(--graphics-color);
    color: white;
    text-decoration: none;
}

body:has(.category-section[open]) .category-heading.fabrication {
    background-color: var(--fabrication-color);
    color: white;
    text-decoration: none;
}

/* Fill viewport when a category is open */

body:has(.category-section[open]) main {
    min-height: 100vh;
}

body:has(.category-section[open]) .category-container {
    min-height: 100vh;
}

/* Push categories below the open category down */

.category-section[open]~.category-section:first-of-type {
    margin-top: auto;
}

/* filmmaking OPEN */

.category-container:has(#filmmaking[open]) #graphics {
    margin-top: auto;
}

/* GRAPHICS OPEN */

.category-container:has(#graphics[open]) #fabrication {
    margin-top: auto;
}

/* =================================
    PROJECT PAGES
================================= */

.project {
    display: grid;
    grid-template-columns: minmax(0, 70%) 30%;
}

.project-description {
    margin-right: clamp(40px, 8vw, 120px);
    margin-top: var(--space-small);
    margin-left: var(--space-medium);
    display: flex;
    flex-direction: column;
    position: relative;
}

.project-description h1 {
    margin-bottom: -5px;
}

.project-description h1.copy-link {
    cursor: pointer;
}

.project-description h1:hover {
    color:blue;
}

.project-description p {
    margin-top: var(--space-medium);
    font-family: var(--font-plantin);
    font-size: var(--font-size-body);
    line-height: 1.2;
    text-align: justify;
    text-justify: inter-word;
}

.project-text p + p {
    margin-top: var(--space-small);
}

.project-text a,
.carousel-caption a {
    color: blue;
    font-family: var(--font-nimbus);
    text-transform: uppercase;

}

/* Honour every Shift+Enter line break, however many in a row */
.project-text p,
.carousel-caption p {
    white-space: pre-line;
}

/* Give empty paragraphs (repeated Enter) a visible blank line */
.project-text p:empty::before,
.carousel-caption p:empty::before {
    content: '\00a0';
}

@media (min-width: 601px) and (min-height: 501px) {

    .project-description {
        /* ends just above the footer row */
        height: calc(var(--carousel-image-ht) - var(--space-large));
    }

    .project-description > .project-text {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: rgba(128, 128, 128, 0.7) transparent;
    }
}

@media (max-width: 1100px) {
    .project-description > .project-text p {
        text-align: left;
    }
}

.project-footer {
    position: absolute;
    top: calc(var(--carousel-image-ht) - var(--space-medium) - 7px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
}

.project-description .carousel-controls {
    margin-top: auto;
}

.carousel,
.carousel-track {
    min-width: 0;
    max-width: 100%;
}

.carousel-slide {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.carousel-slide img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: var(--carousel-image-ht);
}

/* Unloaded images: reserve the final size and show the blurred preview */
.carousel-slide img:not(.is-loaded) {
    aspect-ratio: var(--ar);
    width: min(var(--w), 100%, calc(var(--carousel-image-ht) * var(--ar)));
    height: auto;
    background: var(--lqip) center / 100% 100% no-repeat;
    image-rendering: pixelated;
}

.carousel-caption {
    position: absolute;
    top: calc(var(--carousel-image-ht) + (var(--space-medium) * var(--caption-offset-multiplier)));
    left: var(--left-spill);
    margin-top: var(--space-medium);
    font-size: var(--font-size-body);
    column-width: 180px;
    column-gap: calc(1.5 * var(--space-small));
    column-fill: balance;
    widows: 3;
    max-height: 120px;

    word-spacing: 10%;
}

.carousel-controls {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 15px;
    margin: 3px;
    font-family: var(--font-nimbus);
    font-size: var(--font-size-body);
}

.carousel-controls button {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.carousel-count {
    min-width: 3ch;
    text-align: center;
}

#mobile {
    display: none;
}

@media (min-width: 601px) and (min-height: 501px) {

    .project {
        position: relative;                 /* captions are now measured from here */
        min-height: calc(100vh - var(--space-medium) + 4px);   /* next project starts below the fold */
    }

    .carousel-caption {
        top: var(--carousel-image-ht);      /* directly below the image, no multiplier */
        margin-top: var(--space-medium);    /* the gap under the image */
    }
}

/* =================================
   MOBILE
================================= */

@media (max-width: 600px), (max-height: 500px) {

    :root {
        --left-spill: 24px;
        --left-spill-negative: -24px;
    }

    .profile-image {
        height: 80px;
        margin-top: calc(40vh - 80px);
    }

    /* Mobile filmmaking carousel */

    .project {
        display: flex;
        flex-direction: column;
    }

    .project-description {
        margin-right: var(--space-medium);
        margin-left: var(--space-medium);
        margin-top: calc(var(--space-medium) + 4px);
        padding-bottom: var(--space-medium);
        display: flex;
        flex-direction: column;
    }

    .project-footer {
        justify-content: right;
    }

    .carousel {
        overflow-x: auto;
        overflow-y: hidden;
        max-width: none;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
    }

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

    .carousel-track {
        display: flex;
        width: max-content;
        /* track grows to fit all the slides */
        max-width: none;
        /* cancels the desktop cap */
    }

    .carousel-slide {
        display: block !important;
        flex: 0 0 auto;
        min-width: auto;
        /* cancels the desktop min-width: 0 */
        max-width: none;
        /* cancels the desktop cap */
    }

    .carousel-slide img {
        display: block;
        height: calc(100vh - 200px);
        /* spaces around the minus sign */
        width: auto;
        max-width: none;
        max-height: none;
    }

    /* Unloaded images in the scrolling mobile strip: height is fixed, width follows */
    .carousel-slide img:not(.is-loaded) {
        width: auto;
        height: calc(100vh - 200px);
        max-width: none;
    }

    .carousel-count {
        display: none;
    }

    .carousel-controls {
        display: none;
    }

    .carousel-caption {
        display: none;
    }

    .carousel-slide img {
        cursor: pointer;
    }

    /* Caption mode: one slide, fitted to the screen width */

    .project.caption-open .carousel {
        overflow: hidden;
        /* no scrolling while open */
    }

    .project.caption-open .carousel-track {
        display: block;
        /* not a flex row, so it sizes to its content */
        width: 100%;
    }

    .project.caption-open .carousel-slide {
        display: none !important;
        /* hide every slide... */
    }

    .project.caption-open .carousel-slide.is-open {
        display: block !important;
        /* ...except the tapped one */
        width: 100%;
        height: auto;
        /* slide is only as tall as image + caption */
    }

    .project.caption-open .carousel-slide img {
        width: 100%;
        height: auto;
        /* cancels calc(100vh - 120px) */
        max-height: none;
    }

    /* The caption replaces the description, directly under the image */

    .project.caption-open .carousel-caption {
        position: static;
        /* cancels the desktop position: absolute */
        top: auto;
        left: auto;
        display: block;
        margin: 0 var(--space-large) 0 var(--space-medium);
        padding-top: var(--space-large);
        padding-bottom: var(--space-medium);
        column-width: auto;
        max-height: none;
        color: black;
        text-align: justify;
        line-height: 1.1;
    }

    .project.caption-open .carousel {
        touch-action: pan-y;
    }

    /* The project is the reference point for the counter */
    .project.caption-open {
        position: relative;
    }

    /* Description moves above the carousel and shrinks to just the title */
    .project.caption-open .project-description {
        order: -1;
        /* .project is a flex column on mobile */
        margin: 0;
        padding: 0;
    }

    .project.caption-open .project-description> :not(h1) {
        display: none;
        /* hides the year/duration line, text and footer */
    }

    /* Title bar */
    .project.caption-open .project-description h1 {
        margin: 0;
        padding: 3px calc(var(--space-large) + 9ch) 3px var(--space-large);
        min-height: var(--title-bar-height);
        line-height: 1;
        background-color: black;
        color: white;
        font-family: var(--font-nimbus);
        font-size: var(--font-size-body);
        font-weight: normal;
        text-transform: uppercase;
        overflow-wrap: break-word;
    }

    /* Counter sits at the right end of the same bar */
    .project.caption-open .carousel-count#mobile {
        display: block;
        position: absolute;
        top: 3px;
        right: var(--space-large);
        height: var(--title-bar-height);
        line-height: 1;
        color: white;
        z-index: 1;
    }

    /* While one project is in caption mode, hide its siblings in the same category */
    details:has(.project.caption-open) .project:not(.caption-open) {
        display: none;
    }
}