/* global, fonts are loaded in index.html */
:root {
    --bg: #222831;
    --text: darkgray;
    --accent: #ffd369;
    --hover: #ade6e1;
    --light: #eeeeee;
    --mono: 'Roboto Mono', monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg);
    color: var(--text);
}

body.locked {
    overflow: hidden;
}

a {
    color: var(--light);
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

/* header */
.head {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 4rem);
}

.back {
    display: inline-block;
    padding: 0.8rem 0; /* keeps the tap target at least 44px high */
    font-family: var(--mono);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.3s;
}

.back:hover {
    color: var(--hover);
}

.back .icon {
    margin: 0 0.4rem;
}

.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem clamp(1rem, 5vw, 4rem);
    background: rgba(34, 40, 49, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-height: 44px;
}

.brand img {
    display: block;
    width: 36px;
    height: 36px;
    transition: transform 0.3s ease;
}

.brand:hover img {
    transform: scale(1.1);
}

.name {
    font-family: var(--mono);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--light);
}

h1 {
    color: var(--accent);
    font-size: clamp(2.5rem, 7vw, 5.5rem);
    font-weight: 700;
    line-height: 0.9;
    letter-spacing: -0.04em;
    margin: 2.5rem 0 0;
}

.sub {
    margin: 1rem 0 0;
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* contact sheet: a 12 column broken grid, the layout repeats every 7 frames */
.sheet {
    max-width: 1100px;
    margin: 0 auto;
    padding: 5rem clamp(1rem, 5vw, 4rem) 6rem;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    column-gap: clamp(1rem, 3vw, 3rem);
    row-gap: clamp(3rem, 8vw, 7rem);
    align-items: start;
}

.frame:nth-child(7n+1) { grid-column: 1 / span 6; }
.frame:nth-child(7n+2) { grid-column: 9 / span 4; margin-top: 30%; }
.frame:nth-child(7n+3) { grid-column: 3 / span 4; }
.frame:nth-child(7n+4) { grid-column: 8 / span 5; margin-top: -15%; }
.frame:nth-child(7n+5) { grid-column: 4 / span 6; }
.frame:nth-child(7n+6) { grid-column: 1 / span 4; margin-top: 10%; }
.frame:nth-child(7n+7) { grid-column: 6 / span 6; margin-top: 35%; }

/* frames */
.frame {
    margin: 0;
    opacity: 0;
    transform: translateY(2rem);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.frame.seen {
    opacity: 1;
    transform: none;
}

.shot {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: var(--ratio);
    cursor: zoom-in;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.shot picture {
    display: block;
    height: 100%;
    overflow: hidden; /* the zoom stays inside the frame */
    transition: box-shadow 0.5s ease, filter 0.5s ease;
}

.shot img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: var(--fx, 50%) var(--fy, 50%);
    transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* the photos themselves can't be clicked, selected or dragged (no "save image") */
.shot img,
.lb-frame img {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}

.shot:focus-visible {
    outline: none;
}

/* accent line that slides along one edge, each photo has its own edge (see gallery.js) */
.edge {
    position: absolute;
    background: var(--accent);
    pointer-events: none;
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) 0.05s;
}

.edge-top,
.edge-bottom {
    left: 0;
    right: 0;
    height: 2px;
    transform: scaleX(0);
}

.edge-left,
.edge-right {
    top: 0;
    bottom: 0;
    width: 2px;
    transform: scaleY(0);
}

/* the lines run clockwise around the frame */
.edge-top { top: -10px; transform-origin: left; }
.edge-right { right: -10px; transform-origin: top; }
.edge-bottom { bottom: -10px; transform-origin: right; }
.edge-left { left: -10px; transform-origin: bottom; }

.shot:focus-visible .edge {
    transform: none;
}

/* only on devices that really hover, on touch screens the effect would stay after a tap */
@media (hover: hover) {
    /* lifted against the light, the shadow falls in each photo's own direction */
    .shot:hover {
        transform: translate(calc(var(--sx, 0) * -4px), calc(var(--sy, 1) * -4px));
    }

    .shot:hover picture {
        box-shadow: calc(var(--sx, 0) * 1.2rem) calc(var(--sy, 1) * 1.2rem) 2.5rem rgba(0, 0, 0, 0.35);
    }

    /* zooms gently towards each photo's own focus point */
    .shot:hover img {
        transform: scale(1.04);
    }

    .shot:hover .edge {
        transform: none;
    }

    /* spotlight: the other photos step back */
    .sheet:has(.shot:hover) .shot:not(:hover) picture {
        filter: brightness(0.55) saturate(0.7);
    }
}

/* placeholder until the photo file exists */
.frame.missing .shot {
    border: 1px dashed #4a5260;
    background: repeating-linear-gradient(-45deg, transparent 0 12px, rgba(255, 255, 255, 0.025) 12px 24px);
}

.frame.missing .shot img {
    display: none;
}

.frame.missing .shot::after {
    content: "add photo";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #5c6574;
}

.noscript {
    text-align: center;
    font-family: var(--mono);
}

/* footer */
.foot {
    text-align: center;
    padding: 0 1rem 4rem;
}

.legal-links {
    margin: 1.5rem 0 0;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.legal-links a {
    display: inline-block;
    padding: 0.8rem 0.4rem; /* 44px tap target */
    color: var(--text);
    transition: color 0.3s;
}

.legal-links a:hover {
    color: var(--hover);
}

/* about / legal page */
.legal {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem clamp(1rem, 5vw, 4rem) 5rem;
    line-height: 1.65;
}

.legal > * {
    max-width: 680px;
}

.legal .lead {
    font-size: 1.25rem;
    color: var(--light);
}

.legal a {
    color: var(--light);
    border-bottom: 1px solid var(--accent);
    transition: color 0.3s;
}

.legal a:hover {
    color: var(--hover);
}

.legal section {
    margin-top: 3.5rem;
    scroll-margin-top: 5rem; /* below the sticky top bar when jumping to #impressum */
}

.legal h2 {
    color: var(--accent);
    font-size: 1.5rem;
    margin: 0 0 1rem;
}

.legal h2 span {
    color: var(--text);
    font-weight: 400;
}

.legal h3 {
    color: var(--light);
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 2rem 0 0.5rem;
}

.legal .contact {
    white-space: pre-line;
    color: var(--light);
}

.legal .updated {
    margin-top: 2.5rem;
    font-family: var(--mono);
    font-size: 0.8rem;
}

/* lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 4rem 1fr 4rem;
    align-items: center;
    background: rgba(34, 40, 49, 0.97);
}

.lightbox[hidden] {
    display: none;
}

.lb-frame {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}

.lb-frame picture {
    display: contents;
}

.lb-frame img {
    max-width: 100%;
    max-height: 88vh;
    max-height: 88dvh; /* ignores the mobile address bar */
    object-fit: contain;
}

.lb-nav,
.lb-close {
    display: grid;
    place-items: center;
    color: var(--light);
    font-size: 1.5rem;
    height: 4rem;
    transition: color 0.3s, transform 0.3s;
}

.lb-nav:hover,
.lb-close:hover {
    color: var(--hover);
    transform: scale(1.3);
}

.lb-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(34, 40, 49, 0.7); /* stays visible on bright photos */
}

/* media */
@media (max-width: 785px) {
    .sheet {
        display: flex;
        flex-direction: column;
        padding-top: 3rem;
    }

    .frame:nth-child(n) {
        margin-top: 0;
        width: 82%;
    }

    .frame:nth-child(3n+2) {
        align-self: flex-end;
        width: 68%;
    }

    .frame:nth-child(3n) {
        margin-left: 8%;
        width: 92%;
    }

    /* the arrows are hidden on phones (swipe instead), so the photo is the only column */
    .lightbox {
        grid-template-columns: 1fr;
        padding: 0 0.5rem;
    }

    /* leave room above and below the photo for the close button */
    .lb-frame img {
        max-height: calc(100vh - 10rem);
        max-height: calc(100dvh - 10rem);
    }

    .lb-nav {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .frame,
    .shot,
    .shot picture,
    .shot img,
    .edge {
        transition: none;
    }

    .shot:hover,
    .shot:hover img {
        transform: none;
    }

    .frame {
        opacity: 1;
        transform: none;
    }
}
