/* =========================================================================
   Project pages — shared layout.
   Each project page sets its own colors in the :root block at its top
   (--p-bg, --p-accent…). Nothing here needs editing to recolor a project.
   ========================================================================= */

@font-face {
    font-family: "Martian Mono";
    src: url("../fonts/martian-mono-latin.woff2") format("woff2");
    font-weight: 100 800;
    font-stretch: 75% 112.5%;
    font-display: swap;
}

@font-face {
    font-family: "Instrument Sans";
    src: url("../fonts/instrument-sans-latin.woff2") format("woff2");
    font-weight: 400 700;
    font-stretch: 75% 100%;
    font-display: swap;
}

:root {
    /* fallbacks, overridden by the page */
    --p-bg: #0b0c0a;
    --p-surface: #111310;
    --p-line: #23271f;
    --p-text: #ecebe4;
    --p-text-dim: #a4a69c;
    --p-text-faint: #6a6e63;
    --p-accent: #44ed15;
    --p-accent-ink: #0b0c0a;

    --f-mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --f-sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --top: 56px;
    --pad-x: clamp(16px, 3.4vw, 56px);
    --ease: cubic-bezier(.65, 0, .35, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    color-scheme: dark;
}

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

html {
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: var(--top);
    background: var(--p-bg);
}

body {
    margin: 0;
    background: var(--p-bg);
    color: var(--p-text);
    font-family: var(--f-sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: clip;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

button {
    font: inherit;
    color: inherit;
}

::selection {
    background: var(--p-accent);
    color: var(--p-accent-ink);
}

:focus-visible {
    outline: 2px solid var(--p-accent);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    left: 12px;
    top: -60px;
    z-index: 1000;
    padding: 10px 14px;
    background: var(--p-accent);
    color: var(--p-accent-ink);
    font-family: var(--f-mono);
    font-size: 13px;
    text-decoration: none;
    transition: top .2s;
}

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

/* ------------------------------------------------------------------ cursor */
.cursor {
    display: none;
}

.has-cursor .cursor {
    display: block;
}

.has-cursor,
.has-cursor * {
    cursor: none !important;
}

/* above everything on the page, but under the console that runs between
   pages (.shell, z-index 900): the console comes down over the cursor too */
.cursor-dot,
.cursor-frame,
.cursor-label {
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s;
}

.cursor.is-visible .cursor-dot,
.cursor.is-visible .cursor-frame {
    opacity: 1;
}

.cursor-dot {
    z-index: 898;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: var(--p-text);
    will-change: transform;
}

.cursor-frame {
    z-index: 897;
    width: 36px;
    height: 36px;
    will-change: transform, width, height;
}

.cursor-frame i {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 0 solid var(--p-text);
    transition: border-color .2s;
}

.cursor-frame .c-tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.cursor-frame .c-tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.cursor-frame .c-bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.cursor-frame .c-br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }

.cursor-frame.on-target i {
    border-color: var(--p-accent);
}

.cursor-label {
    z-index: 899;
    padding: 4px 7px 5px;
    background: var(--p-accent);
    color: var(--p-accent-ink);
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    will-change: transform;
}

.cursor.is-visible .cursor-label.is-on {
    opacity: 1;
}

/* ------------------------------------------------------------------ header */
.p-top {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--top);
    padding: 0 var(--pad-x);
    background: color-mix(in srgb, var(--p-bg) 94%, transparent);
    border-bottom: 1px solid var(--p-line);
}

.p-back {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding: 0 12px 0 8px;
    border: 1px solid var(--p-line);
    font-family: var(--f-mono);
    font-stretch: 87.5%;
    font-size: 12.5px;
    text-decoration: none;
    color: var(--p-text);
    transition: background .2s, color .2s, border-color .2s;
}

.p-back:hover {
    background: var(--p-text);
    color: var(--p-bg);
    border-color: var(--p-text);
}

.p-back svg,
.p-cta svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.p-path {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12px;
    color: var(--p-text-faint);
}

.p-path b {
    font-weight: 500;
    color: var(--p-text);
}

.p-cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 36px;
    margin-left: auto;
    padding: 0 16px;
    background: var(--p-accent);
    color: var(--p-accent-ink);
    font-family: var(--f-mono);
    font-stretch: 87.5%;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .2s, color .2s, transform .5s var(--ease-out);
}

.p-cta:hover {
    background: var(--p-text);
    color: var(--p-bg);
}

/* -------------------------------------------------------------------- hero */
.p-hero {
    padding: clamp(48px, 10vh, 120px) var(--pad-x) clamp(36px, 7vh, 72px);
    border-bottom: 1px solid var(--p-line);
}

.p-title {
    margin: 0;
    font-family: var(--f-mono);
    font-stretch: 112.5%;
    font-weight: 600;
    font-size: clamp(42px, 9.5vw, 150px);
    line-height: .95;
    letter-spacing: -.02em;
    overflow-wrap: anywhere;
}

/* scramble: the real letter keeps its place (and the line breaks of the
   final title), the random glyph is drawn over it from data-g */
.p-title .ch {
    position: relative;
}

.p-title .ch.is-scrambling {
    color: var(--p-accent);
    -webkit-text-fill-color: transparent;
}

.p-title .ch.is-scrambling::after {
    content: attr(data-g);
    content: attr(data-g) / "";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: normal;
    -webkit-text-fill-color: currentColor;
    pointer-events: none;
}

.p-lede {
    max-width: 34em;
    margin: clamp(18px, 3vh, 28px) 0 0;
    font-size: clamp(18px, 1.6vw, 23px);
    line-height: 1.45;
    color: var(--p-text-dim);
}

.p-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12.5px;
    color: var(--p-accent);
}

/* -------------------------------------------------------------------- body */
.p-body {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: start;
}

.p-reader {
    min-width: 0;
    padding: 0 var(--pad-x) clamp(64px, 12vh, 140px);
    border-right: 1px solid var(--p-line);
}

.p-tabs {
    position: sticky;
    top: var(--top);
    z-index: 5;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 calc(var(--pad-x) * -1) clamp(32px, 6vh, 56px);
    padding: 0 var(--pad-x);
    background: var(--p-bg);
    border-bottom: 1px solid var(--p-line);
}

.p-tabs::-webkit-scrollbar {
    display: none;
}

.p-tab {
    position: relative;
    flex: 0 0 auto;
    padding: 14px 18px 13px;
    border-right: 1px solid var(--p-line);
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12.5px;
    color: var(--p-text-faint);
    text-decoration: none;
    transition: color .2s, background .2s;
}

.p-tab:first-child {
    border-left: 1px solid var(--p-line);
}

.p-tab:hover {
    color: var(--p-text);
}

.p-tab.is-active {
    color: var(--p-text);
    background: var(--p-surface);
}

.p-tab.is-active::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: var(--p-accent);
}

.p-doc {
    max-width: 66ch;
    font-size: 17px;
    line-height: 1.72;
    outline: none;
}

.js .p-doc[hidden] {
    display: none;
}

.p-doc.is-entering {
    animation: docIn .42s steps(10, end);
}

@keyframes docIn {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

.p-doc h2 {
    margin: 0 0 1.4em;
    font-family: var(--f-mono);
    font-stretch: 112.5%;
    font-weight: 500;
    font-size: clamp(24px, 2.2vw, 32px);
    line-height: 1.1;
}

.no-js .p-doc + .p-doc {
    margin-top: 4em;
}

.p-doc h3 {
    margin: 2.4em 0 .6em;
    font-family: var(--f-mono);
    font-stretch: 87.5%;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    color: var(--p-text);
}

.p-doc h3::before {
    content: "## ";
    color: var(--p-accent);
}

.p-doc h2 + h3 {
    margin-top: 0;
}

.p-doc p {
    margin: 0 0 1em;
    color: var(--p-text);
}

.p-doc ul {
    margin: 0 0 1.2em;
    padding-left: 1.3em;
}

.p-doc li {
    margin: .55em 0;
    padding-left: .2em;
}

.p-doc li::marker {
    content: "– ";
    color: var(--p-accent);
}

.p-doc b,
.p-doc strong {
    font-weight: 600;
}

.p-doc a {
    color: var(--p-text);
    text-decoration-color: var(--p-accent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

.p-doc a:hover {
    color: var(--p-accent);
}

.p-doc .p-note {
    margin: -1.6em 0 2.2em;
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12px;
    color: var(--p-text-faint);
}

/* ----------------------------------------------------------------- gallery */
.p-gallery {
    position: sticky;
    top: var(--top);
    display: grid;
    gap: clamp(22px, 3vw, 36px);
    max-height: calc(100svh - var(--top));
    overflow-y: auto;
    padding: clamp(28px, 4vw, 48px) var(--pad-x);
    scrollbar-width: thin;
    scrollbar-color: var(--p-line) transparent;
    overscroll-behavior: contain;
}

.p-shot {
    position: relative;
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 0;
    border: 0;
    background: var(--p-surface);
    aspect-ratio: var(--p-shot-ratio, 4 / 3);
}

.p-shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1s var(--ease-out);
}

.p-shot-clip {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.p-shot:hover img {
    transform: scale(1.04);
}

.p-shot-n {
    position: absolute;
    left: 0;
    bottom: -26px;
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 11.5px;
    color: var(--p-text-faint);
}

/* viewfinder corners */
.vf::after {
    content: "";
    position: absolute;
    inset: -10px;
    pointer-events: none;
    --c: var(--p-text-dim);
    --l: 20px;
    --t: 1.5px;
    background:
        linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l) no-repeat,
        linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l) no-repeat;
    transition: inset .6s var(--ease-out);
}

.vf:hover::after {
    inset: -16px;
}

/* --------------------------------------------------------- page entrance */
/* the page prints itself as soon as it is painted, without waiting for any
   script; while the console is still on screen the print waits for it */
.js .p-reveal {
    animation: pReveal .65s cubic-bezier(.16, 1, .3, 1) both;
}

.js .p-reveal.d1 { animation-delay: .15s; }
.js .p-reveal.d2 { animation-delay: .28s; }
.js .p-reveal.d3 { animation-delay: .4s; }

.shell-arrive .p-reveal {
    animation-play-state: paused;
}

@keyframes pReveal {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

/* ------------------------------------------------------------------- shell */
/* the console that runs between pages (javascript/shell.js); inverted green
   high-contrast screen that slides down from top -> bottom into projects,
   and up from bottom -> top back to the home page */
.shell {
    position: fixed;
    inset: 0;
    z-index: 900;
    overflow: hidden;
    padding: clamp(20px, 4vw, 48px);
    background: #44ed15;
    color: #0b0c0a;
    border-top: 2px solid #0b0c0a;
    border-bottom: 2px solid #0b0c0a;
    box-shadow: 0 0 50px rgba(0, 0, 0, .65);
    font-family: var(--f-mono);
    font-stretch: 87.5%;
    font-size: clamp(13px, 1.25vw, 16px);
    line-height: 1.85;
    pointer-events: none;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translate3d(0, -100%, 0);
}

.shell.is-active,
.shell-arrive .shell {
    pointer-events: auto;
}

.shell.at-center {
    transform: translate3d(0, 0%, 0);
}

.shell.at-top {
    transform: translate3d(0, -100%, 0);
}

.shell.at-bottom {
    transform: translate3d(0, 100%, 0);
}

.shell.is-moving {
    transition: transform .54s cubic-bezier(.76, 0, .24, 1);
}

/* hides the page the browser's back/forward button already brought, while
   the console slides down over it (javascript/shell.js) */
.shell-curtain {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: var(--p-bg);
}

.shell[hidden] {
    display: block;
    visibility: hidden;
    pointer-events: none;
    box-shadow: none;
}

.shell-log p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.shell .sh-cmd { color: #0b0c0a; font-weight: 700; }
.shell .sh-out { color: rgba(11, 12, 10, .74); font-weight: 500; }
.shell .sh-ok { color: #0b0c0a; font-weight: 700; }

.shell .is-typing::after,
.shell .shell-log p:last-child::after {
    content: "";
    display: inline-block;
    width: .62em;
    height: 1.15em;
    margin-left: 2px;
    vertical-align: -.2em;
    background: #0b0c0a;
}

.shell .shell-log p:last-child:not(.is-typing)::after {
    animation: shellBlink 1s steps(1) infinite;
}

@keyframes shellFill {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

@keyframes shellClear {
    from { clip-path: inset(0 0 0 0); }
    to { clip-path: inset(100% 0 0 0); }
}

@keyframes shellBlink {
    50% { visibility: hidden; }
}

/* ---------------------------------------------------------------- lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    grid-template-rows: 1fr auto;
    background: color-mix(in srgb, #000 94%, transparent);
    animation: lbIn .28s steps(8, end);
}

.lightbox[hidden] {
    display: none;
}

.lb-stage {
    display: grid;
    place-items: center;
    min-height: 0;
    padding: clamp(16px, 4vw, 56px);
}

.lb-stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    animation: lbImg .36s steps(9, end);
}

.lb-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px var(--pad-x) calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, .12);
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12px;
    color: #cfd0c8;
}

.lb-count {
    margin-right: auto;
}

.lb-btn {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .24);
    background: none;
    color: #fff;
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12px;
}

.lb-btn:hover {
    background: #fff;
    color: #000;
}

@keyframes lbIn {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

@keyframes lbImg {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

/* ------------------------------------------------------------------ footer */
.p-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 26px var(--pad-x) calc(26px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--p-line);
    font-family: var(--f-mono);
    font-stretch: 75%;
    font-size: 12px;
    color: var(--p-text-faint);
}

.p-foot p {
    margin: 0;
}

.p-foot a {
    color: var(--p-text-dim);
    text-decoration: none;
}

.p-foot a:hover {
    color: var(--p-text);
}

/* ------------------------------------------------------------------ mobile */
@media (max-width: 960px) {
    :root {
        --top: 52px;
    }

    .p-path {
        display: none;
    }

    .p-body {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .p-gallery {
        order: -1;
        position: static;
        max-height: none;
        display: flex;
        gap: 14px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 26px var(--pad-x) 40px;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 var(--pad-x);
        border-bottom: 1px solid var(--p-line);
    }

    .p-shot {
        flex: 0 0 82%;
        margin: 10px 0;
        scroll-snap-align: start;
    }

    .p-reader {
        border-right: 0;
    }

    .p-doc {
        font-size: 16.5px;
    }
}

@media (max-width: 520px) {
    .p-back span {
        display: none;
    }

    .p-back {
        padding: 0 8px;
    }

    .p-cta {
        padding: 0 12px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        transition-delay: 0s !important;
    }
}
