@import url("https://api.fontshare.com/v2/css?f[]=satoshi@400,500,700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap");

:root {
    /* Site. Dark on purpose: the 1px gaps need contrast against mostly light artworks. */
    --ink: #0d0d0c;
    --ink-2: #171716;
    --smoke: #ecebe6;
    --smoke-dim: #8f8d87;
    /* Marker: the amber from the 2022 sketches. Light enough to carry dark text. */
    --mark: #f7b32b;        /* fills under dark text, 10.6:1 */
    --mark-text: #f7b32b;   /* amber type on the dark background, 10.6:1 */
    --on-mark: #0d0d0c;
    --gutter: clamp(16px, 2.6vw, 40px);
    --nav-h: 60px;
    --font-sans: "Satoshi", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    /* z-index scale */
    --z-tile-focus: 1;
    --z-nav: 10;
    --z-caption: 20;
    --z-skip: 30;

    color-scheme: dark;
}

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

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

body {
    margin: 0;
    background: var(--ink);
    color: var(--smoke);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

:focus-visible {
    outline: 1px solid var(--mark-text);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -100px;
    z-index: var(--z-skip);
    padding: 8px 12px;
    background: var(--mark);
    color: var(--on-mark);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
}

/* ------------------------------------------------------------------ */
/* Index                                                               */
/* ------------------------------------------------------------------ */

.nav {
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;
    height: var(--nav-h);
    padding: 0 var(--gutter);
    background: rgb(13 13 12 / 0.78);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    font-size: 14px;
}

.nav-meta {
    display: flex;
    align-items: center;
    gap: 28px;
    color: var(--smoke-dim);
}

.nav-count {
    font-family: var(--font-mono);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.nav-link {
    color: var(--smoke);
    text-decoration: none;
    transition: color 0.3s ease;
}

.nav-link span {
    display: inline-block;
    transition: transform 0.5s var(--ease-out);
}

.nav-link:hover {
    color: var(--mark-text);
}

.nav-link:hover span {
    transform: translate(2px, -2px);
}

.hero {
    display: grid;
    gap: clamp(16px, 2vw, 28px);
    padding: clamp(40px, 6vw, 88px) var(--gutter) clamp(32px, 4.4vw, 60px);
}

.hero h1 {
    margin: 0 0 0 -0.03em;
    font-size: clamp(56px, 8vw, 96px);
    font-weight: 500;
    line-height: 0.92;
    letter-spacing: -0.04em;
}

/* The page's one resting use of the marker (DESIGN.md, The Marker Rule) */
.hero h1 span {
    color: var(--mark-text);
}

.hero p {
    max-width: 34ch;
    margin: 0;
    color: var(--smoke-dim);
    font-size: clamp(18px, 1.6vw, 22px);
    line-height: 1.4;
    text-wrap: pretty;
}

.hero p strong {
    color: var(--smoke);
    font-weight: 500;
}

.grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (max-width: 1280px) { .grid { --cols: 3; } }
@media (max-width: 900px)  { .grid { --cols: 2; } }
@media (max-width: 560px)  { .grid { --cols: 1; } }

.grid > li {
    opacity: 0;
    transform: translateY(18px);
    transition:
        opacity 0.9s var(--ease-out),
        transform 1.1s var(--ease-out);
}

.grid > li.is-in {
    opacity: 1;
    transform: none;
}

.tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--ink-2);
    text-decoration: none;
    isolation: isolate;
}

.tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform:
        translate3d(var(--tx, 0), var(--ty, 0), 0)
        scale(var(--s, 1.001));
    transition:
        opacity 0.9s var(--ease-out),
        transform 1.4s var(--ease-out),
        filter 0.8s ease;
    will-change: transform;
}

.tile img.is-loaded {
    opacity: 1;
}

.tile:active img {
    --s: 1.02;
    transition-duration: 0.2s;
}

/* is-active / has-active are set by index.html from the pointer position, so they
   follow the cursor through scrolling where :hover lags. */
@media (hover: hover) {
    .tile.is-active img,
    .tile:focus-visible img {
        --s: 1.045;
    }

    .grid.has-active .tile:not(.is-active) img {
        filter: brightness(0.78) saturate(0.85);
    }
}

.tile:focus-visible {
    outline-offset: -1px;
    z-index: var(--z-tile-focus);
}

/* Keyboard and touch: caption pinned to the tile instead of following the cursor */
.tile-label {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: none;
}

.tile:focus-visible .tile-label {
    display: block;
}

@media (hover: none) {
    .tile-label {
        display: block;
    }

    .tile-label .caption-prompt {
        display: none;
    }
}

.tile.is-unavailable {
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--ink-2);
    color: var(--smoke-dim);
    text-align: center;
}

.tile.is-unavailable .unavailable-day {
    position: absolute;
    top: 14px;
    left: 14px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.tile.is-unavailable p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.tile.is-missing::after {
    content: "Preview missing";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--smoke-dim);
    font-size: 13px;
}

/* Caption chip, shared by the cursor caption and the pinned label */
.caption {
    display: flex;
    align-items: baseline;
    gap: 10px;
    max-width: min(340px, calc(100vw - 32px));
    padding: 7px 11px 8px;
    background: var(--mark);
    color: var(--on-mark);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
}

.caption-day {
    flex: none;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.caption-prompt {
    overflow: hidden;
    text-overflow: ellipsis;
}

.cursor-caption {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-caption);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.cursor-caption.is-on {
    opacity: 1;
}

.cursor-caption .caption {
    transform: scale(0.94);
    transform-origin: top left;
    transition: transform 0.45s var(--ease-out);
}

.cursor-caption.is-on .caption {
    transform: none;
}

/* Text swap when the cursor moves to another tile */
.cursor-caption .caption.is-swap > span {
    animation: caption-swap 0.34s var(--ease-out) both;
}

.cursor-caption .caption.is-swap > .caption-prompt {
    animation-delay: 0.03s;
}

@keyframes caption-swap {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
}

.colophon {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 32px var(--gutter) 48px;
    color: var(--smoke-dim);
    font-size: 14px;
}

.colophon a {
    text-decoration: none;
    transition: color 0.3s ease;
}

.colophon a:hover {
    color: var(--mark-text);
}

@media (max-width: 560px) {
    .nav-count {
        display: none;
    }
}

/* ------------------------------------------------------------------ */
/* Sketch viewer                                                       */
/* ------------------------------------------------------------------ */

body.viewer {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.bar {
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    height: var(--nav-h);
    padding: 0 var(--gutter);
    background: var(--ink);
    font-size: 14px;
}

.bar a {
    color: var(--smoke-dim);
    text-decoration: none;
    transition: color 0.3s ease;
}

.bar a[href]:hover {
    color: var(--smoke);
}

.bar a:not([href]) {
    visibility: hidden;
}

.bar a span {
    display: inline-block;
    transition: transform 0.5s var(--ease-out);
}

.bar-home:hover span,
#bar-prev[href]:hover span {
    transform: translateX(-3px);
}

#bar-next[href]:hover span {
    transform: translateX(3px);
}

.bar-home {
    font-weight: 500;
}

.bar-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0;
    min-width: 0;
    max-width: 60ch;
}

.bar-day {
    color: var(--mark-text);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
}

.bar-prompt {
    overflow: hidden;
    color: var(--smoke);
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bar-nav {
    display: flex;
    justify-content: flex-end;
    gap: 24px;
}

body.viewer > main {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* Live sketch: the day folder's own index.html, embedded */
.sketch-frame {
    flex: 1;
    width: 100%;
    min-height: calc(100dvh - var(--nav-h));
    border: 0;
    background: var(--ink);
}

/* Export-only days */
.stills {
    width: 100%;
    padding: 8px var(--gutter) var(--gutter);
}

.stills-note {
    margin: 0 0 20px;
    color: var(--smoke-dim);
    font-size: 14px;
}

.stills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.stills-grid img {
    display: block;
    width: 100%;
    height: auto;
    background: var(--ink-2);
}

.stills-grid li:first-child {
    grid-column: 1 / -1;
}

.stills-grid li:first-child img {
    max-height: calc(100dvh - var(--nav-h) - 80px);
    object-fit: contain;
}

.unavailable {
    flex: 1;
    display: grid;
    place-content: center;
    gap: 12px;
    padding: var(--gutter);
    text-align: center;
}

.unavailable h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 64px);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.04em;
}

.unavailable p {
    margin: 0;
    color: var(--smoke-dim);
}

.unavailable a {
    color: var(--smoke);
    text-underline-offset: 3px;
}

@media (max-width: 640px) {
    .bar {
        grid-template-columns: 1fr auto;
        height: auto;
        padding-block: 12px;
    }

    .bar-title {
        grid-row: 2;
        grid-column: 1 / -1;
    }
}

/* ?capture: artwork only, filling a 4:5 window for thumbnails */
html.capture .bar {
    display: none !important;
}

html.capture body.viewer > main {
    position: fixed;
    inset: 0;
}

html.capture .sketch-frame {
    min-height: 100vh;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .grid > li {
        opacity: 1;
        transform: none;
    }
}
