@use 'utils/minireset';
@use 'plyr/src/sass/plyr';
@use 'partials/fonts';
@use 'partials/variables' as *;
@use 'partials/animations';

// ----------------------------------------------------------------------------
// GENERALITIES
// ----------------------------------------------------------------------------

// Fonts and colors

body {
    font-family: var(--text-font-family);
    font-size: var(--text-font-size);
    line-height: var(--text-font-size);
    color: var(--jet);
    background-color: var(--white);
}

h1,
h2,
h3 {
    color: var(--black);
}

h1 {
    font-family: var(--logo-font-family);
    font-size: var(--h1-font-size);
    line-height: var(--h1-font-size);
}

h2 {
    font-family: var(--text-font-family);
    font-size: var(--h2-font-size);
    line-height: var(--h2-font-size);
    margin: 0 0 4rem 0;
}

h3 {
    font-family: var(--text-font-family);
    font-size: var(--h3-font-size);
    line-height: var(--h3-font-size);
    margin: 2rem 0 1rem 0;
}

p {
    text-align: justify;
    line-height: var(--text-line-height);
}

strong {
    font-weight: var(--bold-font-weight);
}

em {
    font-style: italic;
}

// Link style

a {
    color: var(--jet);
    text-decoration: underline;
    border-radius: 2px;
    transition: color 200ms ease-in-out;

    &:hover,
    &:focus,
    &:active {
        color: var(--black);
    }

    &:focus-visible {
        outline: 1px dashed var(--black);
        outline-offset: 2px;
        animation: expand-outline 200ms ease-in-out;
    }
}

// General grid layout

body {
    min-height: 100vh;
    overflow-x: hidden;
    display: grid;
    grid:
        'header' var(--header-bar-height)
        'main' 1fr
        'footer' auto
        / 1fr;
}

.body--hidden-overflow-y {
    overflow-y: hidden;
}

header {
    grid-area: header;
}

main {
    grid-area: main;
}

footer {
    grid-area: footer;
}

// ----------------------------------------------------------------------------
// HEADER
// ----------------------------------------------------------------------------

// Header bar

.header-bar {
    width: 100%;
    height: var(--header-bar-height);
    margin: auto;
    padding: var(--header-bar-vertical-padding) Max(var(--header-bar-horizontal-padding), calc((100vw - var(--content-max-width)) / 2 + var(--header-bar-horizontal-padding)));
    background-color: var(--transparent-white);
    border-bottom: 1px solid var(--transparent-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
    transition:
        height 400ms ease-in-out,
        border-bottom 400ms ease-in-out;

    &--fixed {
        position: fixed;
        --header-bar-vertical-padding: 0.5rem;
        --header-bar-height: calc((var(--header-bar-vertical-padding) * 2) + var(--icon-size));
        top: calc(-1 * var(--header-bar-height));
        border-bottom: 1px solid var(--light-gray);
        transition: transform 400ms ease-in-out;
    }

    &--visible {
        transform: translateY(var(--header-bar-height));
    }
}

.header-bar__logo {
    width: max-content;
    transition: transform 400ms ease-in-out;
    transform-origin: left;

    &--small {
        transform: scale(0.8);
    }
}

.header-bar__logo-link {
    text-decoration: none;
}

.header-bar__nav {
    position: relative;
    z-index: 2;
}

.header-bar__nav-button {
    position: relative;
    z-index: 3;
    width: var(--icon-size);
    height: var(--icon-size);
    padding: 0;
    overflow: hidden;
    border: none;
    border-radius: 50%;
    background-color: var(--jet);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition:
        transform 200ms ease-in-out,
        background-color 400ms ease-in-out;

    svg {
        width: 100%;
        height: 100%;
        padding: 10%;
        flex-shrink: 0;
        transition:
            opacity 400ms ease-in-out,
            transform 400ms ease-in-out;
    }

    svg:nth-child(1) {
        fill: var(--white);
        opacity: 1;
    }

    svg:nth-child(2) {
        fill: var(--black);
        opacity: 0;
    }

    &:hover,
    &:active {
        transform: scale(1.1);
    }

    &--custom-focus {
        background-color: var(--white);

        svg {
            transform: translateX(-100%);
        }

        svg:nth-child(1) {
            opacity: 0;
        }

        svg:nth-child(2) {
            opacity: 1;
        }
    }
}

.header-bar__nav-menu {
    position: fixed;
    z-index: 2;
    top: 0;
    left: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    height: 100vh;
    padding: calc(var(--header-bar-height) + 4rem) Max(4rem, calc((100vw - var(--content-max-width)) / 2 + 4rem)) 4rem 4rem;
    background-color: var(--transparent-black);
    color: var(--white);
    overflow-x: hidden;
    overflow-y: auto;
    transition: transform 400ms ease-in-out;

    > li {

        + li {
            border-top: 1px solid var(--spanish-gray);
        }

        li {
            margin: 0 0 0 2rem;
            border-top: 1px solid var(--granite-gray);
        }

        div {
            padding: 1rem 0;
            transform: translateX(100%);
            transition: transform 400ms ease-in-out;

            a,
            span {
                color: var(--light-gray);
            }

            a {
                text-decoration: none;

                &:hover,
                &:focus,
                &:active {
                    color: var(--white);
                }

                &:focus-visible {
                    outline: 1px dashed var(--white);
                }
            }
        }
    }

    .header-bar__nav-item--active {
        list-style: disc outside;

        a {
            color: var(--white);
        }
    }

    &--visible {
        transform: translateX(calc(-1 * 100%));

        @for $i from 1 through 20 {
            .header-bar__nav-item-#{$i} {

                div {
                    transform: translateX(0);
                    transition: transform calc(400ms + $i * 100ms) ease-in-out;
                }
            }
        }
    }
}

.header-bar__nav-overlay {
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--black);
    opacity: 0;
    pointer-events: none;
    will-change: opacity;
    transition: opacity 400ms ease-in-out;

    &--visible {
        opacity: 0.2;
        pointer-events: auto;
        cursor: pointer;
    }
}

@media screen and (min-width: $tablet-media-query) {

    .header-bar__nav-menu {
        min-width: 50vw;
    }
}

@media screen and (min-width: $desktop-media-query) {

    .header-bar__nav-menu {
        min-width: 25vw;
    }
}

// ----------------------------------------------------------------------------
// MAIN
// ----------------------------------------------------------------------------

// Home section

.home-section {
    max-width: var(--content-max-width);
    min-height: var(--home-section-min-height);
    margin: auto;
    padding: var(--home-section-vertical-padding) var(--home-section-horizontal-padding);
    display: flex;
    justify-content: center;
    align-items: center;
}

.home__nav {
    height: 100%;
    display: grid;
    grid:
        'top-left top top-right' var(--home-nav-item-size)
        'left center right' auto
        'bottom-left bottom bottom-right' var(--home-nav-item-size)
        / var(--home-nav-item-size) auto var(--home-nav-item-size);
    place-content: center center;
    gap: var(--home-nav-gap);
    line-height: 0;
}

.home__nav-image {
    grid-area: center;

    img {
        min-width: 12rem;
        max-width: Min(100%, 2500px);
        min-height: 12rem;
        max-height: var(--home-nav-image-max-height);
    }
}

.home__nav--2-items {

    .home__nav-item-1 {
        grid-area: top-left;
        place-self: end end;
        transform:
            rotate(-45deg)
            translateY(var(--home-nav-item-translation));
    }

    .home__nav-item-2 {
        grid-area: top-right;
        place-self: end start;
        transform:
            rotate(45deg)
            translateY(var(--home-nav-item-translation));
    }
}

.home__nav--3-items {

    .home__nav-item-1 {
        grid-area: top-left;
        place-self: end end;
        transform:
            rotate(-45deg)
            translateY(var(--home-nav-item-translation));
    }

    .home__nav-item-2 {
        grid-area: top-right;
        place-self: end start;
        transform:
            rotate(45deg)
            translateY(var(--home-nav-item-translation));
    }

    .home__nav-item-3 {
        grid-area: bottom;
        place-self: start center;
    }
}

.home__nav--4-items {

    .home__nav-item-1 {
        grid-area: top-left;
        place-self: end end;
        transform:
            rotate(-45deg)
            translateY(var(--home-nav-item-translation));
    }

    .home__nav-item-2 {
        grid-area: top-right;
        place-self: end start;
        transform:
            rotate(45deg)
            translateY(var(--home-nav-item-translation));
    }

    .home__nav-item-3 {
        grid-area: bottom-left;
        place-self: start end;
        transform:
            rotate(45deg)
            translateY(calc(var(--home-nav-item-translation) * -1));
    }

    .home__nav-item-4 {
        grid-area: bottom-right;
        place-self: start start;
        transform:
            rotate(-45deg)
            translateY(calc(var(--home-nav-item-translation) * -1));
    }
}

.home__nav-link {
    color: var(--black);
    font-size: var(--h3-font-size);
    text-decoration: none;
    opacity: 0;
    transition: opacity 600ms ease-in-out;

    div {
        opacity: 0;
        transition: opacity 600ms ease-in-out;
    }
}

.home__nav-link--visible {
    opacity: 1;

    div {
        opacity: 1;
    }
}

.home__nav-letter--wave-up {
    animation: wave-up 600ms ease-in-out;
}

.home__nav-letter--wave-down {
    animation: wave-down 600ms ease-in-out;
}

// Gallery & biography sections

.gallery-section,
.biography-section {
    max-width: var(--content-max-width);
    margin: auto;
    padding: var(--generic-section-vertical-padding) var(--generic-section-horizontal-padding);
}

.gallery__title,
.biography__title {
    text-align: center;
}

.gallery__introduction,
.biography__presentation {
    max-width: var(--text-max-width);
    margin: auto;

    h3:nth-child(1) {
        margin: 0 0 1rem 0;
    }

    p {

        + p,
        + ul {
            margin: 1rem 0 0 0;
        }
    }

    ul {
        line-height: var(--text-line-height);

        + ul,
        + p {
            margin: 1rem 0 0 0;
        }

        li {
            position: relative;
            padding: 0 0 0 1rem;
        }

        li + li {
            margin: 1rem 0 0 0;
        }

        li:before {
            content: '•';
            position: absolute;
            top: 0;
            left: 0;
        }
    }
}

.gallery__artwork {
    display: table;
    max-width: Min(1280px, 100%);
    margin: auto;

    + .gallery__artwork {
        margin: 2rem auto 0 auto;
    }

    .gallery__image,
    .gallery__video {
        display: block;
        max-height: 80vh;
    }

    .gallery__video {

        &--full-screen {
            max-height: initial;
        }
    }

    figcaption {
        display: table-caption;
        caption-side: bottom;
        margin: 1rem auto 0 auto;
        font-size: var(--caption-font-size);
        line-height: var(--text-line-height);
    }
}

@media screen and (min-width: $tablet-media-query) {

    .gallery__artwork {

        + .gallery__artwork {
            margin: 3rem auto 0 auto;
        }
    }
}

// Error section

.error-section {
    max-width: var(--content-max-width);
    margin: auto;
    padding: var(--generic-section-vertical-padding) var(--generic-section-horizontal-padding);
}

.error__title {
    text-align: center;
}

.error__message {
    max-width: var(--text-max-width);
    margin: auto;
    text-align: center;
}

.error__button {
    margin: 1rem 0 0 0;
    text-align: center;

    a {
        display: inline-block;
        padding: 0.8rem;
        border-radius: 10px;
        color: var(--white);
        background-color: var(--jet);
        text-decoration: none;
        font-weight: var(--semi-bold-font-weight);
        transition: transform 200ms ease-in-out;

        &:hover,
        &:focus,
        &:active {
            transform: scale(1.1);
        }
    }
}

// ----------------------------------------------------------------------------
// FOOTER
// ----------------------------------------------------------------------------

// Footer bar

.footer-bar {
    max-width: var(--content-max-width);
    height: var(--footer-bar-height);
    margin: auto;
    padding: var(--footer-bar-vertical-padding) var(--footer-bar-horizontal-padding);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-bar__social {
    display: flex;
    align-items: center;

    a {
        width: var(--icon-size);
        height: var(--icon-size);
        border-radius: 50%;
        background-color: var(--jet);
        display: flex;
        justify-content: center;
        align-items: center;
        transition: transform 200ms ease-in-out;

        + a {
            margin: 0 0 0 1rem;
        }

        svg {
            fill: var(--white);
        }


        &:hover,
        &:focus,
        &:active {
            transform: scale(1.1);
        }
    }

    a.footer-bar__instagram-button {

        svg {
            width: 55%;
            height: 55%;
        }
    }

    a.footer-bar__email-button {

        svg {
            width: 70%;
            height: 70%;
        }
    }
}

.footer-bar__copyright {
    font-size: var(--footnote-font-size);
    margin: 1rem 0 0 0;
}

@media screen and (min-width: $tablet-media-query) {

    .footer-bar {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
    }

    .footer-bar__social {
        order: 2;
    }

    .footer-bar__copyright {
        order: 1;
        margin: 0;
    }
}
