*, *::before, *::after {
    box-sizing: border-box;
}

:root{
    scroll-behavior: smooth;
    line-height: 1.6rem;

    /* variabelen*/
    --header_background: oklch(0.89 0 0);
    --background: oklch(0.9 0 0);
    --transparant_background: oklch(0.9 0 0 /.9);
    --header_color: oklch(0.4 0 0);

    --text_lightness: 0.22; /* change with main color */
    --main_color: rgb(calc(var(--text_lightness) * 255) calc(var(--text_lightness) * 255) calc(var(--text_lightness) * 255));
    --accent: oklch(0.7 0 0);

    --shadow_color: oklch(0 0 0 / .15);

    --logo_height: 4em;

    color: var(--main_color);
}

/* Add external link icon to all links containing "http" */
a[href*="http"]::after {
    /* from developers.mozilla.org */
    display: inline-block;

    width: 1em;
    height: 1em;

    margin-left: 0.25em;

    vertical-align: text-top;

    /*
      Unicode zero width space as `<content replacement>` to expose the alt text in the a11y tree.
      See: https://bugzilla.mozilla.org/show_bug.cgi?id=1976574
    */
    content: "\200b"  " (external)";
    content: "\200b" / " (external)";

    background-color: currentcolor;

    -webkit-mask-image: url("../img/icons/external-link.svg");

    mask-image: url("../img/icons/external-link.svg");
    -webkit-mask-size: cover;
    mask-size: cover;
}

a.expand{
    padding: 0.5rem;
    margin: 0 -0.5rem;
}

/* Remove icon from visually-hidden links */
a[href*="http"].visually-hidden::after,
a[href*="http"].sr-only::after,
a[href*="http"].screen-reader-only::after,
a[href*="http"][aria-hidden="true"]::after,
a[href*="http"].hidden::after {
    content: none;
    display: none;
}

/* Ensure the icon doesn't get underlined */
a[href*="http"]::after {
    text-decoration: none;
}

/* Prevent the icon from being selectable */
a[href*="http"]::after {
    user-select: none;
}

/* Keep icon with link text when wrapping */
a[href*="http"]::after {
    white-space: nowrap;
}

img {
    width: 100%;
    border-radius: 1em;
}

html {
    background: var(--background);
    color: var(--main_color);
    height: 100%;
    overflow-x: clip;
    #detach-button-host { /* this disables the video tools for opera */
        display: none;
    }
}


.visually-hidden {
    position: relative;
    width: 1px;
    height: 1px;
    margin: -1px;
    border: 0;
    padding: 0;

    white-space: nowrap;
    clip-path: inset(100%);
    clip: rect(0 0 0 0);
    overflow: hidden;
}

h1:not(.visually-hidden), h2:not(.visually-hidden) {
    text-align: center;
}

body {
    font-family: Inter, sans-serif;
    margin: 0;
    line-height: 1.6rem;
    display: flex;
    min-height: 100%;
    flex-direction: column;
    overflow: clip;
    padding: 0;

    a:is(.link){
        padding: 0.8rem;
        margin: 0 -0.8rem;
    }
}

main {
    flex: 1;
    justify-content: flex-start;
    .container > * {
        margin: 4.5em 0;
    }
}

.container {
    max-width: min(80rem,90%);
    margin: auto;
}

.socials {
    ul {
        margin: 0;
        padding: 0 20%;
        display: flex;
        list-style: none;
        gap: 1em;
        width: 100%;
        justify-content: space-evenly;
        li {
            flex-grow: 0;
            position: relative;
        }
        img {
            width: clamp(2em, 4vw, 2.8em);
        }
    }
}


.icon {
    padding: 0;
    margin: 0;
    filter:  invert(1) brightness(var(--text_lightness));
    border-radius: 0;
}

.projects {
    display: flex;
    align-content: center;
    flex-direction: column;
}

.cards {
    margin:  1em 0;
    list-style: none;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-content: stretch;
    align-items: stretch;
    gap: 2rem;
    padding-left: 0;
    container-type: inline-size; /* Enable container queries */
    flex-wrap: wrap;

    h3 {
        font-size:  1.5em;
        margin-top: 0;
    }

    li {
        width: calc(50% - 1rem);
        position: relative;
        display: flex;
        flex-direction: column;
        border-radius: 1em;
        overflow: hidden;
        box-shadow: 0 0 2rem var(--shadow_color);
        background-color: var(--background);
        transition: scale ease-in-out .2s;

        &:hover {
            scale: 104%;
        }

        /* Default stacked layout (for narrow cards) */
        picture {
            order: -1;
            height: clamp(12em, 24vw, 15em);
            flex-shrink: 0;
            overflow: hidden;

            img {
                border-radius: 0;
                width:  100%;
                height: 100%;
                object-fit: cover;
                object-position: center;
            }
        }

        div {
            margin: 1rem;
            display: flex;
            flex-direction: column;
            flex-grow: 1;

            p {
                margin-top: 0;
                color: oklch(0 0 0);
            }

            a {
                margin-top:  auto;
            }
        }
    }

    /* Overlay layout when container is at least 30em wide */
    @container (min-width:  60em) {
        li {
            justify-content: flex-end;
            min-height: 20em;
            aspect-ratio: 5 / 3;
            isolation: isolate;

            picture {
                position: absolute;
                inset: 0;
                z-index: -1;
                order: unset;
                height: auto;
                flex-shrink:  unset;

                img {
                    width: 100%;
                    height: 100%;
                    object-fit: cover;
                    object-position:  center;
                    border-radius: 0;
                }
            }

            div {
                position: relative;
                z-index:  1;
                width: min(calc(60%), 22rem);
                margin: 0;
                padding: 1rem 4em 1rem 1rem;
                flex-grow: unset;
                backdrop-filter: blur(2px);
                background: linear-gradient(
                        to right,
                        var(--transparant_background) 0%,
                        var(--transparant_background) 85%,
                        transparent 100%
                );
                box-sizing: border-box;
            }
        }
    }
}



.overlay-link {
    position: absolute;
    overflow: hidden;
    inset: 0;
    text-indent: 100%;
    white-space: nowrap;
    height: auto;
    z-index: 2;
}

.name {
    font-weight: bold;
    text-decoration: underline;
}

.no-wrap {
    white-space: nowrap;
}

.button {
    position: relative;
    display: flex;
    flex-direction: row;
    gap: 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    padding: 0.5rem;
    border: 2px solid var(--accent);
    background-color: var(--background);
    color: inherit;
    white-space: nowrap;
    text-decoration: none;
    align-items: center;
    justify-content: center;
    transition: ease-in-out background-color .2s, ease-in-out color .2s;
    margin-inline: 1rem;
    width: fit-content;
    >p {
        margin: 0;
    }

    img {
        max-height: 2rem;
        max-width: 2rem;
        aspect-ratio: 1 / 1;
        border-radius: 0;
    }

    &:hover {
        background: var(--accent);

    }
}

.buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;

}

main {
    .title {
        justify-self: center;
        margin: 8em 1em;
        position: relative;

        h1 {
            margin: 1.5rem 1.5rem 2rem;
            font-size: clamp(2em, 10vw, 3em);
        }
        .padded_background {
            background-color: var(--background);
            box-shadow: inset 0 0.3rem 1rem var(--shadow_color);;
            width: fit-content;
            margin: auto;
        }


        .video-background {
            filter: blur(2px);
            opacity: 100%;
            backdrop-filter: unset;
        }
    }
}

/* Per-feature detail sections. Default: image left. Add class "image-right" to flip, omit <picture> for text-only. */
.feature-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2.5rem;
    margin: 3.5em auto;
    scroll-margin-top: 1em;
    max-width: min(65rem, 90%);

    h2, h3 {
        text-align: start;
        margin-top: 0;
    }

    > div {
        flex: 1 1 auto;
        min-width: 0;
    }

    picture {
        flex: 0 0 clamp(15rem, 35%, 22rem);
    }

    > video.media-loop {
        flex: 0 0 clamp(15rem, 35vw, 22rem);
        width: clamp(15rem, 35vw, 22rem);
        max-width: 100%;
    }

    picture img,
    > video.media-loop {
        height: auto;
        display: block;
        border-radius: 1em;
        box-shadow: 0 0 1rem var(--shadow_color);
    }

    picture img {
        width: 100%;
    }

    &.media-large {
        picture {
            flex-basis: clamp(17rem, 38%, 25rem);
        }

        > video.media-loop {
            flex-basis: clamp(17rem, 38vw, 25rem);
            width: clamp(17rem, 38vw, 25rem);
        }
    }

    &.image-right {
        flex-direction: row-reverse;
    }

    @media screen and (max-width: 850px) {
        &, &.image-right {
            flex-direction: column;
            align-items: stretch;
            gap: 1rem;

            > div {
                order: 1;
            }

            picture,
            > video.media-loop {
                order: 2;
                flex-basis: auto;
                align-self: center;
                width: min(100%, 28rem);
            }

            &.media-large {
                picture,
                > video.media-loop {
                    width: min(100%, 32rem);
                }
            }
        }
    }
}

.project-details {
    display: grid;
    grid-template-columns: auto 2px 1fr;
    gap:  0;
    list-style: none;
    padding:  0;
    margin: 0;
    position: relative;

    /* Create the vertical divider spanning all rows */
    &::before {
        content: '';
        grid-column: 2;
        grid-row: 1 / -20;
        background-color: var(--accent);
        width: 2px;
    }

    li {
        display:  contents;
    }

    .label {
        text-align: end;
        grid-column: 1;
        padding-right: 1rem;
        padding-block: 0.5rem;
    }

    .value {
        grid-column: 3;
        padding-left: 1rem;
        padding-block: 0.5rem;
        white-space: pre-line;
    }
}

.project-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5%;
    .right-section {
        display: flex;
        align-items: center;
        min-width: max-content;
        .buttons {
            gap: 0;
            flex-direction: column;
            .button {
                width: 100%;
            }
        }
    }
    @media screen and (max-width: 850px){
        flex-direction: column;
    }
}

.video-background {
    position: absolute;
    top: -14em;
    bottom: -14em;
    left: 50%;
    transform: translateX(-50%) scale(102%);
    width: calc(100vw);
    z-index: -1;
    overflow: hidden;

    /* Fade effect on top and bottom edges (10em each) */
    mask-image: linear-gradient(
            to bottom,
            transparent 0,
            black 8em,
            black calc(100% - 8em),
            transparent 100%
    );

    video, img {
        position: absolute;
        inset: 0;
        pointer-events: none;
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 0;
        /* Cover crops left/right on wide screens, never top/bottom */
        object-position: center center;
    }

    img {
        z-index: 0;
    }

    video {
        z-index: 1;
    }
}

.padded_background {
    background-color: var(--background);
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 1rem;
    border-radius: 1em;
}

@media screen and (max-width: 660px){
    main .cards {
        flex-direction: column;
        justify-content: unset;
        align-content: unset;
        align-items: unset;

        li {
            width: 100%;
        }
    }
}

@media screen and (max-width: 500px){
    main .buttons {
        flex-direction: column;
        gap: 0;
    }
}


header {
    border-radius: 1em;
    overflow: clip;
    margin: 0.5em;
    background-color: var(--header_background);
    color: var(--header_color);
    box-shadow: inset 0 0.3rem 1rem var(--shadow_color);

    .container {
        max-width: unset;
        margin: 0;
    }

    nav {
        display: flex;
        max-width: unset;
        justify-content: space-between;
        align-items: center;
        ul {
            display: flex;
            flex-direction: row;
            align-content: center;
            justify-content: flex-end;
            margin: 0 0 0 0;
            padding: 0 0.5rem;

            list-style: none;
            flex-wrap: nowrap;
            li {
                align-content: center;
                font-size: clamp(1.2em,2.5vw,1.5em);
                a {
                    white-space: nowrap;
                    font-weight: bolder;
                    color: inherit;
                    padding: 0.2rem 0.6rem;
                    margin: 0.2rem;
                    text-decoration: none;
                    transition: background-color .2s ease-in-out;
                    border-radius: 0.2em;

                    &:hover,
                    &:focus-visible {
                        background-color: color-mix(in srgb, var(--header_background), oklch(0.4 0 0) 5%);
                    }
                }
            }
        }
    }
    a:has(img) {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    img {
        height: var(--logo_height);
        width: auto;
        border-radius: 0.5em;
        margin: 0.7em;
        padding: 0;
    }
}


footer {
    background-color: var(--header_background);
    font-size: 0.8em;
    margin-top: auto;
    p {
        margin: 0;
        padding: 0;
    }
    .container {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.3em 1em;
    }
    .credits a {
        color: inherit;
    }
}





@media screen and (max-width: 600px) {
    header nav {
        flex-direction: column;
        ul {
            width: 100%;
            justify-content: space-evenly;
            flex-wrap: nowrap;
            align-content: center;
            justify-items: center;
            padding: 0 0.5rem 0.5rem;

            li a {
                margin: -0.8rem;
                font-size: clamp(0.8rem, 4vw, 1.5em);
            }
        }
    }
}
