/* !! Normalize transitions */
/* !! Normalize sizing */

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

html {
    -webkit-text-size-adjust: 100%;
    font-size: 8px;
}

body {
    font-size: 2rem;
    line-height: 1.25;
    margin: 0;
    font-family: 'Instrument Sans', Helvetica, sans-serif;
    font-weight: 500;
    color: #000;
}

::selection {
    background-color: #000;
    color: #fff;
}

p {
    margin: 0;
    pointer-events: auto;
}

em {
    font-style: normal;
    color:hsl(0 0 70);
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

textarea, input {
    padding: 1rem;
    border-radius: 0;
    font-size: 2rem;
    font-family: inherit;
    min-height: 4rem;
    margin-bottom: 1rem;
    border: none;

    &:active, &:focus {
        outline: none;
    }
}

textarea {
    resize: none;
    height: 30rem;

    &:active, &:focus {
        border: 1px solid hsl(0 0 70);
    }
}

input:active, input:focus {
        border-bottom: 1px solid hsl(0 0 70);
}

label {
    color: hsl(0 0 50);
}


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

.page-slider-viewport {
    position: relative;
    width: 100vw;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
}

.page-slider {
    display: flex;
    width: calc(200vw - 4rem); /* home (100vw-4rem) + nav (4rem) + work (100vw-4rem) */
    min-height: 100%;
    transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
    will-change: transform;
}

.page {
    flex: 0 0 calc(100vw - 4rem);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

canvas#life {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: block;
    z-index: 0;
    pointer-events: none;
    image-rendering: pixelated;
}

.home {
    padding: 2rem;
    max-width: 64rem;
    user-select: text;
    pointer-events: none;
}

.contacts {
    display: grid;
    margin-top: 3rem;
    margin-bottom: 48rem;
    pointer-events: auto;
}

.contact {
    flex: 1 0 auto;
    padding: 3rem 2rem;
    background-color: hsl(0 0 90);
}

.contact-tab {
    width: fit-content;
    height: 4rem;
    padding-inline: 1rem;
    background-color: hsl(0 0 90);
    display: flex;
    align-items: center;
}

.work-cases {
    display: flex;
    flex-direction: column;
}

.work-case {
    padding: 2rem;
    
    & > :is(img, video, .dither-video) {
        display: block;
        width: calc(100% + 2rem);
        height: auto;
        margin-top: 2rem;
        margin-right: -2rem;
        margin-bottom: -2rem;
    }
}

.copyright {
    position: absolute;
    bottom: 2rem;
    width: calc(100vw - 8rem);
}

.signature {
    position: absolute;
    bottom: 0;
    right: -1rem;
    height: 11rem;
}

/* VIDEO DITHERING ==================================================================================================== */

.dither-video-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 500ms ease;
}

.dither-video {
    position: relative;
    overflow: hidden;

    & > video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        opacity: 0;
        pointer-events: none;
        transition: opacity 500ms ease;

        &.dither-video-fallback {
            position: static;
            opacity: 1;
            pointer-events: auto;
        }
    }

    &.dither-video--suppress-transition :is(.dither-video-canvas, > video) {
        transition: none;
    }

    &:not(.dither-video--ready) {
        & .dither-video-canvas {
            opacity: 0;
            pointer-events: none;
        }

        & > video {
            opacity: 1;
        }
    }

    &.dither-video--disabled {
        & .dither-video-canvas {
            opacity: 0;
            pointer-events: none;
        }

        & > video {
            opacity: 1;
        }
    }
}

/* NAV BAR ==================================================================================================== */

.nav-bar {
    flex: 0 0 4rem;
    width: 4rem;
    height: 100dvh;
    position: sticky;
    top: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    transition: height 0.1s ease-out;
}

.nav-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100lvh;
    background: linear-gradient(to bottom, transparent 0, transparent 8rem, hsl(0 0 90) 8rem);
    z-index: -1;
}

.nav-bar-home {
    height: 4rem;
    width: 4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 7px;
    position: relative;
}

.home-icon-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.nav-bar-case {
    writing-mode: vertical-rl;
    padding-inline: 1rem;
    padding-block: 5px;
}

.nav-bar-contact {
    background-color: hsl(0 0 90);
    writing-mode: vertical-rl;
    padding-inline: 1rem;
    padding-block: 5px;
    padding-bottom: 2.5rem;

    .btn-text-white-wrapper {
        display: none;
    }
}


/* TOOL TIP ==================================================================================================== */

#tool-tip {
    position: fixed;
    top: 0;
    right: 0;
    width: 5.5rem;
    height: 5.5rem;
    display: none;
    opacity: 0;
    transition: opacity 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
    user-select: none;
    pointer-events: none;
    z-index: 25;
    cursor: help;

    &.tool-tip--active {
        opacity: 1;
        pointer-events: auto;
        transition: opacity 0.32s ease 320ms;
    }

    &::before,
    &::after {
        position: absolute;
        inset: 0;
        display: flex;
        pointer-events: none;
        transition: opacity 0.18s ease;
        text-align: right;
        white-space: pre;
        flex-direction: column;
        align-items: flex-end;
    }

    &::before {
        content: '?';
        opacity: 1;
        color: #000;
        padding-top: 1.5rem;
        padding-right: 2rem;
    }

    &::after {
        content: 'grab to move\Ascroll to zoom';
        opacity: 0;
        color: hsl(0 0 70);
        padding-top: 3rem;
        padding-right: 4rem;
    }

    &:hover::after {
        opacity: 1;
    }
}




#desktop-case-preview,
#case-description {
    display: none;
}


/* DESKTOP LAYOUT ==================================================================================================== */




@media (min-width: 1024px) {

    textarea {
        border: 1px solid hsl(0 0 70);

        &:active, &:focus {
            border-color: #000;
        }
    }

    input {
        border-bottom: 1px solid hsl(0 0 70);

        &:active, &:focus {
            border-bottom-color: #000;
        }
    }

    .page-slider-viewport, .page {
        overflow: hidden;
    }

    .page-slider {
        width: 100vw;
        height: calc(100dvh - 4rem);
        min-height: 0;
        will-change: auto;
    }

    .page {
        flex: 0 0 100vw;
        height: 100%;
        min-height: 0;
    }

    .page-work, .contact-tab, .copyright {
        display: none;
    }

    #tool-tip {
        display: flex;
    }

    #desktop-case-preview {
        display: block;
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 20;

        & .viewport-dither-canvas {
            position: absolute;
            inset: 0;
            display: block;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }

        & .desktop-case-preview-hitarea {
            position: absolute;
            transform: translate(-50%, -50%);
            pointer-events: auto;
            cursor: grab;
            touch-action: none;

            &.desktop-case-preview-hitarea--dragging {
                cursor: grabbing;
            }
        }
    }

    #case-description {
        display: block;
        position: fixed;
        bottom: 6rem;
        padding-left: 1rem;
        max-width: 64rem;
        pointer-events: auto;
        user-select: text;
        z-index: 13;
        transition: opacity 0.32s ease;
    }

    #case-description.desc-fade-out {
        opacity: 0;
    }


    /* NAV BAR & CONTACT FORM ==================================================================================================== */

    .nav-bar {
        flex-direction: row;
        align-items: stretch;
        position: fixed;
        bottom: 0;
        top: auto;
        width: 100%;
        height: 4rem;
        z-index: 10;
    
        & > [data-expand] {
            flex-grow: 0;
            flex-shrink: 0;
            flex-basis: var(--collapsed-basis, auto);
            display: flex;
            align-items: center;
            writing-mode: horizontal-tb;
            transition: flex-grow 0.32s cubic-bezier(0.2, 0.9, 0.2, 1),
                        flex-shrink 0.32s cubic-bezier(0.2, 0.9, 0.2, 1),
                        flex-basis 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
        }
    
        &[data-expanded="none"] > [data-expand] {
            transition: flex-grow 0.56s cubic-bezier(0.25, 0.7, 0.2, 1),
                        flex-shrink 0.56s cubic-bezier(0.25, 0.7, 0.2, 1),
                        flex-basis 0.56s cubic-bezier(0.25, 0.7, 0.2, 1);
        }
    }

    .nav-bar-home {
        cursor: pointer;
    }

    .nav-bar-home--idle {
        cursor: default;
        pointer-events: none;
    }

    .nav-bar-contact {
        flex: 0 0 84.5px;
        width: 84.5px;
        padding-inline: 0;
        padding-block: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        overflow: hidden;
        background-color: hsl(0 0 80);
        writing-mode: horizontal-tb;
        transition: background-color 0.2s ease, color 0.2s ease,
                    flex-grow 0.32s cubic-bezier(0.2, 0.9, 0.2, 1),
                    flex-shrink 0.32s cubic-bezier(0.2, 0.9, 0.2, 1),
                    flex-basis 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
    
        &::before {
            content: '';
            position: absolute;
            inset: 0;
            background-color: #000;
            opacity: 0;
            transform: translateX(0);
            transition: opacity 0.2s ease, transform 0.2s ease;
            z-index: 3;
        }
    
        & .btn-text {
            position: relative;
            z-index: 2;
            color: #000;
            transition: opacity 0.5s ease;
    
            &.fade-out { opacity: 0; }
        }
    
        & .btn-text-white-wrapper {
            position: absolute;
            inset: 0;
            overflow: hidden;
            z-index: 4;
            pointer-events: none;
            transform: translateX(0);
            transition: transform 0.2s ease;
            opacity: 0;
            display: block;
        }
    
        & .btn-text-white {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            transform: translateX(0);
            transition: transform 0.2s ease;
        }
    
        &.dc-sending {
            cursor: not-allowed;
            color: #fff;
    
            &::before, & .btn-text-white-wrapper {
                opacity: 1;
                transform: translateX(0);
                transition: none;
            }
    
            & .btn-text-white { transform: translateX(0); }
    
            &.dc-animating {
                &::before {
                    animation: send-slide-1 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards,
                               send-slide-2 0.7s cubic-bezier(0.85, 0, 0.15, 1) 0.3s forwards;
                }
    
                & .btn-text-white-wrapper {
                    animation: send-slide-1 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards,
                               send-slide-2 0.7s cubic-bezier(0.85, 0, 0.15, 1) 0.3s forwards;
                }
    
                & .btn-text-white {
                    animation: send-slide-1-inverse 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards,
                               send-slide-2-inverse 0.7s cubic-bezier(0.85, 0, 0.15, 1) 0.3s forwards;
                    transition: none;
                }
            }
        }
    
        &.dc-sent {
            cursor: not-allowed;
            color: #000;
            background-color: rgb(105, 255, 105);
            transition: background-color 0.5s ease;
    
            &.dc-sent-fade { background-color: hsl(0 0 80); }
    
            & .btn-text-white-wrapper { opacity: 1; }
            & .btn-text-white { transform: translateX(0); }
    
            &:not(.dc-sending) {
                &::before { opacity: 1; transform: translateX(100%); }
                & .btn-text-white-wrapper { transform: translateX(100%); }
                & .btn-text-white { transform: translateX(-100%); }
            }
        }
    
        &.dc-resetting {
            &::before, & .btn-text-white-wrapper, & .btn-text-white { transition: none; }
        }
    }

    .contact {
        position: fixed;
        right: 2rem;
        bottom: calc(4rem + 2rem);
        width: 40rem;
        background-color: transparent;
        padding: 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.32s cubic-bezier(0.2, 0.9, 0.2, 1);
        z-index: 13;
    
        &.contact--open {
            opacity: 1;
            pointer-events: auto;
        }
    
        & :is(textarea, input) {
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            background-color: transparent;
            font-weight: 500;
        }
    
        & textarea {
            height: 40rem;
            margin-bottom: 0;
        }
    
        & #send-btn {
            display: none;
        }
    }

}