:root {
    --colour-bg: #111;
    --colour-text: #eee;
    --colour-border: white;
    --colour-list-link: #bbb;
    --font-main: Trebuchet MS, Arial, sans-serif;
    --font-size-smaller: 0.8rem;
    --max-width: 60rem;
    --mobile-tree-list-height: 40svh;
    --mobile-preview-left-padding: 150px;
    --container-padding: 1.25rem;
    --time-delay-between: 0.7s;
    --time-page-fade: 0.5s;
    --time-desc-fade: 1s;
    --time-tree-fade: 0.8s;
    --bg-img-left-padding: -5rem;
}

/* All pages */

html, body {
    height: 100%;
    margin: 0;
}

html {
    scroll-behavior: smooth;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.page, .photo-large, .photo-below {
    animation: fadeIn var(--time-page-fade) ease-out forwards;
}

body {
    box-sizing: border-box;
    background-color: var(--colour-bg);
    color: var(--colour-text);
    font-family: var(--font-main);
    line-height: 1.35;
}

.page {
    max-width: var(--max-width);
    margin: 0 auto;
    container-type: inline-size;
}

.page.noclick {
    pointer-events: none;
}

.page.fixed {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    inset: 0;
    height: 100svh;
}

.container {
    padding: var(--container-padding);
}

.container.row {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.container.row.centered {
    justify-content: center;
}

.container.row.right {
    justify-content: flex-end;
}

.container.grid {
    display: grid;
}

/* Main page */

.page.main {
    max-width: 80svh;
}

.copyright text {
    fill: var(--colour-text);
    font-family: var(--font-main);
    font-size: 50px;
    cursor: pointer;
}

.copyright:hover text {
    text-decoration: underline;
}

.tree a:not(.copyright) {
    pointer-events: none;
}

.tree #Canopy,
.tree #Trunk {
    transition: filter 1s;
    filter: invert(0);
}

.scene-wrapper {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    width: 98vw;
    padding: 0 var(--container-padding) var(--container-padding) 0;
    container-type: size;
}

.scene {
    position: relative;
    width: min(
        100cqw,
        calc(100cqh * 2140 / 3210)
    );
    aspect-ratio: 2140 / 3210;
    perspective: 1000px;
    perspective-origin: bottom;
}

.title {
    opacity: 0;
    font-size: clamp(1rem, 8.5cqw, 3rem);
    font-weight: bold;
    margin: 1.5rem 0 1.5rem;
    animation: fadeIn var(--time-desc-fade) ease forwards var(--time-delay-between);
}

.desc {
    opacity: 0;
    animation: fadeIn var(--time-desc-fade) ease forwards calc(var(--time-desc-fade) + 2 * var(--time-delay-between));
}

.desc.delay {
    animation-delay: calc(2 * var(--time-desc-fade) + 3 * var(--time-delay-between));
}

.tree.large {
    display: block;
    width: 100%;
    height: 100%;
}

.tree.large .leaf {
    pointer-events: visiblePainted;
    cursor: pointer;
}

.tree.large:has(.leaf:hover) #Canopy,
.tree.large:has(.leaf:hover) #Trunk {
    filter: invert(1);
}

/* Scrolling photo cards */

.scroll-track {
    position: relative;
    pointer-events: none;
    z-index: -1;
}

.scroll-hint {
    position: absolute;
    left: 55%;
    top: 50%;
    font-family: monospace;
    opacity: 0;
    transition: opacity 0.5s ease, transform 1s ease;
}

.scroll-hint.visible {
    opacity: 1;
    transform: translateY(1rem);
}

.photo-spacer, .photo-trigger {
    height: 100svh;
}

.photo-pile{
    position: absolute;
    left: 48%;
    top: 45%;
}

.no-js-message {
    position: absolute;
    left: 48%;
    top: 45%;
    font-family: monospace;
    z-index: 10;
}

.photo-wrapper {
    position: absolute;
    left: 0;
    top: 0;
    transform-style: preserve-3d;
    will-change: transform;
    visibility: hidden;
    pointer-events: none;
}

.photo {
    position: relative;
    display: block;
    pointer-events: auto;
    transition: transform 0.2s ease;
    transform-style: preserve-3d;
    z-index: 3;
}

.photo img, .photo-back {
    display: block;
    outline: 2px solid black;
}

.photo img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    box-sizing: border-box;
    background: var(--colour-border);
    border: min(1cqh, 1.5cqw) solid var(--colour-border);
    opacity: var(--photo-opacity, 0);
}

.photo-back {
    position: absolute;
    inset: 0;
    background: var(--colour-border);
    opacity: var(--back-opacity, 0);
}

.photo:hover {
    transform: scale(1.05);
}

/* Individual photo pages */

.photo-large {
    display: flex;
    justify-content: center;
    width: 100%;
    min-width: 0;
}

.photo-large img {
    display: block;
    padding: var(--container-padding);
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100svh;
    box-sizing: border-box;
}

.photo-below {
    display: grid;
    padding: var(--container-padding);
    max-width: var(--max-width);
    margin: 0 auto;
}

.tree.small {
    grid-area: 1 / 1;
    width: 50%;
}

.tree.small:not(.copyright) * {
    pointer-events: visiblePainted;
    cursor: pointer;
}

.tree.small #Canopy,
.tree.small #Trunk {
    filter: invert(1);
}

.tree.small:has(#Canopy:hover, #Trunk:hover) #Canopy,
.tree.small:has(#Canopy:hover, #Trunk:hover) #Trunk {
    filter: invert(0);
}

.photo-desc {
    grid-area: 1 / 1;
    padding-left: 25%;
    padding-top: 30%;
    z-index: 3;
    text-shadow:
        0 0 0.1em var(--colour-bg),
        0 0 0.2em var(--colour-bg),
        0 0 0.4em var(--colour-bg),
        0 0 0.8em var(--colour-bg);
    pointer-events: none;
}

.photo-title {
    font-size: clamp(1rem, 8cqw, 3rem);
    font-weight: bold;
    margin: 0 0 var(--container-padding);
    line-height: 1.1;
}

.photo-meta {
    font-size: var(--font-size-smaller);
    font-weight: lighter;
    margin: 0 0 var(--container-padding);
}

/* Page with plain list of all photo links */

.static-scene {
    grid-area: 1 / 1;
    position: fixed;
    display: inline-block;
    justify-self: end;
    padding: 0;
    width: min(65cqw, 100svh);
    max-height: calc(100% - 2 * var(--container-padding));
}

.tree.list {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 95svh;
}

.tree.list:not(.copyright) * {
    pointer-events: visiblePainted;
    cursor: pointer;
}

.tree.list:has(#Canopy:hover, #Trunk:hover) #Canopy,
.tree.list:has(#Canopy:hover, #Trunk:hover) #Trunk {
    filter: invert(1);
}

.photos-list {
    grid-area: 1 / 1;
    position: relative;
    display: inline-block;
    margin-top: min(calc(0.15 * var(--max-width)), 15svh);
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    z-index: 2;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: auto;
    transition: margin-top 0.3s ease;
}

.list-icon {
    height: 2rem;
}

.list-title {
    font-size: 2rem;
    font-weight: bold;
    padding-left: 1rem;
}

.list-photos {
    padding: 0 2rem 0;
    list-style: none;
    max-width: 45vw;
}

.list-photos a {
    color: var(--colour-list-link);
    text-decoration: none;
}

.list-photos a:hover {
    text-decoration: underline;
}

.list-photos li {
    position: relative;
    padding-left: 2rem;
}

.list-photos li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 1.5rem;
    height: 1.5rem;
    background: url("photos/leaf.svg") center / contain no-repeat;
}

.photo-previews {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.photo-preview {
    position: absolute;
    left: min(30svh, 47%);
    top: 42%;
    max-width: 53%;
    max-height: 40%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-sizing: border-box;
    border: min(0.7cqh, 1.2cqw) solid var(--colour-border);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.preview-hint {
    position: absolute;
    left: var(--mobile-preview-left-padding);
    top: 50%;
    font-family: monospace;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page:has(.list-photos a:is(:hover, :focus-visible)) .preview-hint{
    opacity: 0;
}

@media (max-width: 700px) {
    .page:has(.photos-list) {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .static-scene::before {
        content: "";
        position: absolute;
        inset: calc(-1 * var(--container-padding)) calc(-1 * var(--container-padding)) 100%;
        background-color: var(--colour-bg);
        pointer-events: none;
    }
    
    .static-scene {
        justify-self: flex-start;
        width: 100%;
        background-color: var(--colour-bg);
        z-index: 1;
    }

    .static-scene::after {
        content: "";
        position: absolute;
        inset: 100% calc(-1 * var(--container-padding)) calc(-2 * var(--container-padding));
        pointer-events: none;
        background: linear-gradient(
            to bottom,
            var(--colour-bg) 0%,
            transparent 100%
        );
    }

    .tree.list {
        display: block;
        width: auto;
        height: auto;
        max-width: 85vw;
        max-height: var(--mobile-tree-list-height);
        z-index: 2;
    }

    .photo-preview {
        left: var(--mobile-preview-left-padding);
        top: 40%;
        max-width: calc(100% - var(--mobile-preview-left-padding) - 2 * var(--container-padding));
        max-height: 50%;
        z-index: 2;
    }

    .preview-hint {
        opacity: 1;
    }

    .photos-list {
        grid-area: 2 / 1;
        margin-top: calc(var(--mobile-tree-list-height) + var(--container-padding));
        z-index: 0;
    }

    .list-photos {
        max-width: 100%;
    }
}
