/* =========================================================
   SO MUCH FUN — MAIN STYLESHEET
   ========================================================= */


/* =========================================================
   DESIGN VARIABLES
   ========================================================= */

:root {
    /* Shared screen inset for the name and the project rectangle. */
    --screen-inset: 30px;

    /* Project padding on all sides: vw follows viewport width; px sets fixed limits. */
    --project-side-margin-min: 20px;
    --project-side-margin-fluid: 3vw;
    --project-side-margin-max: 48px;
    --project-side-margin-mobile: 16px;
    --project-side-margin: clamp(
        var(--project-side-margin-min),
        var(--project-side-margin-fluid),
        var(--project-side-margin-max)
    );
    --project-row-gap: 24px;

    /* Homepage colours */
    --background-color: #ff4000;
    --text-color: #cef8ff;
    /*--text-color: #cef8ff;*/


    /* Project icon size — desktop */
    --project-min-width: 120px;
    --project-width: 15vw;
    --project-max-width: 260px;


    /* Central title — desktop */
    --title-size: 3vw;
    --title-min-size: 28px;
    --title-max-size: 44px;


    /* Project icon size — mobile */
    --mobile-project-min-width: 100px;
    --mobile-project-width: 32vw;
    --mobile-project-max-width: 180px;


    /* Central title — mobile */
    --mobile-title-size: 6vw;
    --mobile-title-min-size: 22px;
    --mobile-title-max-size: 30px;
}



/* =========================================================
   CUSTOM FONT
   ========================================================= */

@font-face {

    font-family: "Dark Spikes";

    src: url("fonts/Dark Spikes.woff2") format("woff2");

    font-weight: normal;
    font-style: normal;

    font-display: block;
}



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

* {
    box-sizing: border-box;
}


html,
body {

    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;
}


button {
    font: inherit;
}



/* =========================================================
   PAGE
   ========================================================= */

body {

    background-color: var(--background-color);

    overflow: hidden;
}



/* =========================================================
   CENTRAL TITLE / ABOUT LINK
   ========================================================= */

#introduction {

    position: fixed;

    left: var(--screen-inset);
    top: var(--screen-inset);
    right: var(--screen-inset);
    line-height: 1.2;
    pointer-events: none;


    /* Typography */

    font-family: Arial, Helvetica, sans-serif;
    font-weight: normal;

    font-size: clamp(
        var(--title-min-size),
        var(--title-size),
        var(--title-max-size)
    );

    color: var(--text-color);

    text-decoration: none;

    overflow-wrap: break-word;


    /* Keep title above project images */

    z-index: 1000;


}

#about-link {
    color: var(--text-color);
    text-decoration: none;
    pointer-events: auto;
}

#about-text {
    color: #000;
    pointer-events: auto;
}

body.is-about #introduction {
    max-height: calc(100dvh - 2 * var(--screen-inset));
    padding-right: calc(var(--project-side-margin) + 8px);
    text-align: left;
    overflow-y: auto;
    pointer-events: auto;
}

body.is-about #canvas {
    display: none;
}

#back-to-projects:not([hidden]) {
    position: fixed;
    top: var(--screen-inset);
    right: var(--screen-inset);
    color: #000;
    pointer-events: auto;
}



/* =========================================================
   HOMEPAGE CANVAS
   ========================================================= */

#canvas {

    position: relative;

    width: 100vw;
    height: 100vh;

    overflow: hidden;
}



/* =========================================================
   PROJECT ICON CONTAINER
   ========================================================= */

.project {

    position: absolute;
    aspect-ratio: 1;


    /* Responsive project size */

    width: clamp(
        var(--project-min-width),
        var(--project-width),
        var(--project-max-width)
    );


    /*
       Hidden until JavaScript has calculated
       the initial random position.
    */

    opacity: 0;


    cursor: grab;


    user-select: none;
    -webkit-user-select: none;


    touch-action: none;


    text-decoration: none;
}



/* =========================================================
   PROJECT IMAGES
   ========================================================= */

.project img {

    display: block;

    width: 100%;
    height: 100%;
    object-fit: contain;


    pointer-events: none;

    user-select: none;
    -webkit-user-select: none;

    -webkit-user-drag: none;
}



/* =========================================================
   PROJECT WHILE DRAGGING
   ========================================================= */

.project:active {

    cursor: grabbing;
}



/* =========================================================
   PROJECT OVERLAY
   =========================================================

   This layer covers the viewport but remains transparent,
   so the homepage is still visible around the project window.

   JavaScript will add the class:

       .is-open

   when a project is opened.
   ========================================================= */

#project-overlay {

    position: fixed;

    inset: 0;

    z-index: 2000;


    /*
       Hidden by default.
    */

    display: none;


    /*
       Center the project window.
    */

    align-items: center;
    justify-content: center;


    /*
       A transparent overlay means the homepage remains
       visible around the project window.
    */

    background: transparent;
}



/* =========================================================
   OPEN OVERLAY
   ========================================================= */

#project-overlay.is-open {

    display: flex;
}



/* =========================================================
   PROJECT WINDOW
   ========================================================= */

#project-window {

    position: absolute;


    /*
       Follow the name's screen inset on every side, covering
       the name while keeping an equal border around the window.
    */

    inset: var(--screen-inset);


    /*
       Temporary/default project colours.

       JavaScript will later replace these with the colours
       specified inside each project's project.js file.
    */

    background-color: #711FFF;
    color: #FF3224;


    /*
       Keep content inside the rectangle.
    */

    overflow: hidden;
}



/* =========================================================
   PROJECT CONTENT
   ========================================================= */

/* Keep equal clear space on all sides, including while the content scrolls. */
#project-content {
    position: absolute;
    container-type: size;
    inset: var(--project-side-margin) 0;
    padding: 0 var(--project-side-margin);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

#project-content::-webkit-scrollbar {
    display: none;
}

.project-info {
    width: 100%;
    overflow-wrap: anywhere;
}

.project-info > :first-child {
    margin-top: 0;
}

.project-info > :last-child {
    margin-bottom: 0;
}


.project-info h1 {
    white-space: nowrap;

    margin: 0 0 30px 0;
    text-align: center;

    font-family: Arial, Helvetica, sans-serif;

    font-size: clamp(32px, 5vw, 72px);

    font-weight: normal;

    line-height: 0.95;
}


.project-info p {

    max-width: 100%;

    margin: 0 auto 20px;
    text-align: justify;

    font-family: Arial, Helvetica, sans-serif;

    font-size: clamp(15px, 1.2vw, 19px);

    line-height: 1.35;
}



.project-header {
    margin-bottom: 30px;
}

.project-info .project-header > * {
    white-space: nowrap;
    text-align: left;
    margin: 0 0 8px;
    line-height: 1.2;
}

.project-info .project-header > :last-child {
    margin-bottom: 0;
}

/* Editorial layouts are chosen in project data, never from image orientation. */
.project-image-item {
    min-width: 0;
    margin: 0;
}

.project-image--full,
.project-image--medium,
.project-image-row,
.project-video-row {
    margin: 36px 0;
}

.project-image--full {
    width: 100%;
}

.project-image--medium {
    width: 60%;
    margin-inline: auto;
}

.project-image-row,
.project-video-row {
    display: grid;
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: start;
    gap: var(--project-row-gap);
}

.project-page-image {
    display: block;
    /* Fit either the available width or visible height without cropping. */
    width: min(100%, calc(100cqh * var(--image-ratio, 1)));
    height: auto;
    margin-inline: auto;
}

.project-page-video {
    display: block;
    /* Fit the content area's width or visible height, whichever limits first. */
    width: min(100%, calc(100cqh * 16 / 9));
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 36px auto;
    border: 0;
}

.project-video-row .project-page-video {
    min-width: 0;
    width: 100%;
    margin: 0;
}

.project-image-caption {
    margin-top: 10px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.35;
}


/* =========================================================
   OVERLAY BUTTONS — GENERAL
   ========================================================= */

#project-close {

    position: absolute;

    z-index: 10;


    padding: 0;

    border: 0;

    background: transparent;

    color: inherit;


    font-family: Arial, Helvetica, sans-serif;

    font-weight: normal;

    line-height: 1;


    cursor: pointer;


    user-select: none;
    -webkit-user-select: none;
}



/* =========================================================
   CLOSE BUTTON
   ========================================================= */

#project-close {

    top: 0;
    right: 0;
}

#project-close,
#back-to-projects:not([hidden]) {
    width: var(--project-side-margin);
    height: var(--project-side-margin);
    min-width: 0;
    min-height: 0;
    margin: 0;
    appearance: none;
    display: grid;
    place-items: center;
    font-size: 0;
}

/* Symmetric geometry keeps the visible X equally inset from both edges. */
#project-close svg,
#back-to-projects svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    pointer-events: none;
}



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

@media (max-width: 600px) {
    .project-video-slot {
        display: none;
    }

    :root {
        --project-side-margin: var(--project-side-margin-mobile);
    }

    /* Use the same ordered content on mobile, with one image per row. */
    .project-image--medium {
        width: 100%;
    }

    .project-image-row,
    .project-video-row {
        grid-auto-flow: row;
        grid-template-columns: minmax(0, 1fr);
    }



    /* -----------------------------------------------------
       Homepage title
       ----------------------------------------------------- */

    #introduction {

        font-size: clamp(
            var(--mobile-title-min-size),
            var(--mobile-title-size),
            var(--mobile-title-max-size)
        );
    }


    /* -----------------------------------------------------
       Homepage project icons
       ----------------------------------------------------- */

    .project {

        width: clamp(
            var(--mobile-project-min-width),
            var(--mobile-project-width),
            var(--mobile-project-max-width)
        );
    }


    /* -----------------------------------------------------
       Project content
       ----------------------------------------------------- */



    /* -----------------------------------------------------
       Close button
       ----------------------------------------------------- */



    /* -----------------------------------------------------
       Information typography
       ----------------------------------------------------- */

    .project-info h1 {

        font-size: 38px;

        margin-bottom: 25px;
    }


    .project-info p {

        font-size: 15px;

        line-height: 1.35;
    }

}
