/* ==========================================================================
   KGL Portfolio — page layout & HUD theme
   Monochrome, high-key gray, IBM Plex Mono HUD labels + IBM Plex Sans KR body.
   Game widget styles live in styles.css.
   ========================================================================== */

:root {
    --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --font-sans: 'IBM Plex Sans KR', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;

    --ink: #f4f6fa;
    --ink-dim: rgba(244, 246, 250, .74);
    --ink-faint: rgba(244, 246, 250, .42);
    --line: rgba(255, 255, 255, .16);
    --line-strong: rgba(255, 255, 255, .45);
    --panel: rgba(13, 15, 20, .52);
    --panel-2: rgba(13, 15, 20, .66);
    --accent: #cfe3ff;

    --radius: 4px;
    --ease-out: cubic-bezier(.22, .7, .3, 1);
    --ease-expo: cubic-bezier(.16, 1, .3, 1);
    --hud-pad: clamp(18px, 2.4vw, 40px);
    --text-shadow: 0 1px 2px rgba(0, 0, 0, .35);

    /* Board box — the bright panel in the background video. JS refines these
       from the video's object-fit:cover mapping; the fallbacks keep it centred. */
    --board-width: 90vw;
    --board-height: min(843px, 100dvh);
    --board-left: 5vw;
    --board-top: calc(50% - var(--board-height) / 2);
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow: hidden;
    background: #6f737c;
    color: var(--ink);
    font-family: var(--font-sans);
    font-weight: 300;
}

canvas {
    display: block;
}

::selection {
    background: rgba(244, 246, 250, .85);
    color: #14161b;
}

/* --------------------------------------------------------------------------
   Background: video + scrim + grain
   -------------------------------------------------------------------------- */
#video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    object-fit: cover;
    z-index: -2;
    filter: brightness(.78) contrast(1.08) saturate(.4);
    transition: filter 1s ease;
}

body.section-open #video-background {
    filter: brightness(.6) contrast(1.08) saturate(.3);
}

/* Vignette scrim — darkens when a section opens so panels/text sit forward */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 42%, rgba(18, 20, 26, 0) 38%, rgba(18, 20, 26, .5) 100%);
    transition: opacity 1s ease;
}

body.section-open::after {
    background: radial-gradient(ellipse at 50% 42%, rgba(18, 20, 26, .18) 30%, rgba(18, 20, 26, .62) 100%);
}

#grain {
    position: fixed;
    inset: -50%;
    width: 200%;
    height: 200%;
    z-index: 900;
    pointer-events: none;
    opacity: .07;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    animation: grain 1.4s steps(6) infinite;
}

@keyframes grain {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-3%, 2%); }
    40%  { transform: translate(2%, -4%); }
    60%  { transform: translate(-4%, -1%); }
    80%  { transform: translate(3%, 3%); }
    100% { transform: translate(0, 0); }
}

/* --------------------------------------------------------------------------
   Snow scene — 3D hero (js/ice-scene.js). Covers the video on the home screen
   and fades out when a section opens (the camera has flown into the object by then).
   -------------------------------------------------------------------------- */
#ice-world {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: #2b323d; /* = scene fog colour, so the canvas has no seam while loading */
    opacity: 1;
    transform: none;
    /* long, gentle cross-fade with a hint of push-in so leaving the snow field feels like one continuous dolly */
    transition: opacity 1.3s cubic-bezier(.4, 0, .2, 1), transform 1.3s cubic-bezier(.4, 0, .2, 1);
    will-change: opacity, transform;
}

#ice-world canvas {
    position: absolute;
    inset: 0;
    display: block;
}

/* Vignette + bottom scrim over the scene so the HUD and menu read on the lit snow */
#ice-world::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to top, rgba(18, 20, 26, .62) 0%, rgba(18, 20, 26, .28) 18%, rgba(18, 20, 26, 0) 38%),
        radial-gradient(ellipse at 50% 45%, rgba(18, 20, 26, 0) 40%, rgba(18, 20, 26, .42) 100%);
}

/* Sections keep the 3D world: left is the exhibit, right is the list. */
body.section-open #ice-world {
    opacity: 1;
    transform: none;
    pointer-events: none;
}

body.section-open #ice-world::after {
    background:
        linear-gradient(to right, rgba(18, 20, 26, 0) 0%, rgba(18, 20, 26, .12) 42%, rgba(18, 20, 26, .62) 68%, rgba(18, 20, 26, .82) 100%),
        linear-gradient(to top, rgba(18, 20, 26, .45) 0%, rgba(18, 20, 26, 0) 32%);
}

/* The monogram is the title once the scene runs; the text hero is the no-WebGL fallback */
body.scene-ready #hero-text {
    opacity: 0 !important;
    visibility: hidden;
    transition: opacity .9s ease, visibility 0s linear .9s;
}

body.scene-ready #nav-buttons::before {
    opacity: .5;
}

/* While the camera flies into a hotspot the menu steps aside */
body.scene-focus #nav-buttons {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity .6s ease !important;
}

/* Callouts: "+" anchor, leader line, clickable label — positioned per frame by the scene */
#ice-callouts {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .04em;
    color: var(--ink);
    text-shadow: var(--text-shadow);
}

.ice-callout-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ice-callout-lines line {
    stroke: rgba(244, 246, 250, .7);
    stroke-width: 1;
}

.ice-callout-cross,
.ice-callout-label {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    white-space: nowrap;
    will-change: transform, opacity;
}

.ice-callout-cross {
    color: rgba(244, 246, 250, .9);
}

.ice-callout-label {
    appearance: none;
    background: rgba(13, 15, 20, .38);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 2px;
    padding: 7px 11px 7px 9px;
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    color: var(--ink);
    font: inherit;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-shadow: var(--text-shadow);
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}

.ice-callout-label:hover,
.ice-callout-label:focus-visible,
.ice-callout-label.is-hot {
    background: rgba(244, 246, 250, .92);
    border-color: rgba(244, 246, 250, .92);
    color: #14161b;
    text-shadow: none;
}

.ice-callout-label:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 3px;
}

.ice-callout-idx {
    font-size: .64rem;
    color: var(--ink-dim);
    letter-spacing: .08em;
}

.ice-callout-label:hover .ice-callout-idx,
.ice-callout-label.is-hot .ice-callout-idx {
    color: rgba(20, 22, 27, .6);
}

.ice-callout-sub {
    font-size: .62rem;
    color: var(--ink-faint);
    text-transform: none;
    letter-spacing: .04em;
}

.ice-callout-label:hover .ice-callout-sub,
.ice-callout-label.is-hot .ice-callout-sub {
    color: rgba(20, 22, 27, .55);
}

/* --------------------------------------------------------------------------
   Radio panel — small YouTube player toggled by the radio hotspot
   -------------------------------------------------------------------------- */
#radio-panel {
    position: fixed;
    right: var(--hud-pad);
    bottom: calc(var(--hud-pad) + 64px);
    z-index: 920;
    width: 320px;
    padding: 12px 14px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .04em;
    color: var(--ink);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .45s ease, transform .45s var(--ease-out);
}

#radio-panel.is-on {
    opacity: 1;
    transform: none;
}

#radio-panel p {
    margin: 0;
}

.radio-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.radio-head .hud-label {
    margin-bottom: 0 !important;
}

.radio-close {
    appearance: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: 2px;
    width: 24px;
    height: 24px;
    padding: 0;
    color: var(--ink);
    font: inherit;
    line-height: 1;
    cursor: pointer;
    transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

.radio-close:hover,
.radio-close:focus-visible {
    background: rgba(244, 246, 250, .92);
    border-color: rgba(244, 246, 250, .92);
    color: #14161b;
}

.radio-title {
    margin: 8px 0 10px !important;
    font-family: var(--font-sans);
    font-weight: 400;
    font-size: .84rem;
    letter-spacing: 0;
    line-height: 1.4;
}

.radio-player {
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 2px;
    overflow: hidden;
}

.radio-player iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.radio-note {
    margin-top: 8px !important;
}

/* --------------------------------------------------------------------------
   HUD corners (fixed to viewport, on the "wall" around the board)
   -------------------------------------------------------------------------- */
#hud {
    position: fixed;
    inset: 0;
    z-index: 120;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: .74rem;
    line-height: 1.55;
    letter-spacing: .04em;
    color: var(--ink);
    text-shadow: var(--text-shadow);
}

.hud {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 30ch;
    transition: opacity .6s ease;
}

.hud p {
    margin: 0;
}

.hud-tl { top: var(--hud-pad); left: var(--hud-pad); }
.hud-tr { top: var(--hud-pad); right: var(--hud-pad); text-align: right; align-items: flex-end; }
.hud-bl { bottom: var(--hud-pad); left: var(--hud-pad); }
.hud-br { bottom: var(--hud-pad); right: var(--hud-pad); text-align: right; align-items: flex-end; }

.hud-dim { color: var(--ink-dim); }

/* Stage switcher: the wheel travels too, this is the explicit ‹ › for it */
.hud-tc {
    top: var(--hud-pad);
    left: 50%;
    transform: translateX(-50%);
    max-width: none;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .6s ease, visibility 0s linear .6s;
}

body.scene-ready:not(.section-open):not(.scene-focus) .hud-tc {
    opacity: 1;
    visibility: visible;
    transition: opacity .6s ease;
}

.stage-now {
    display: flex;
    align-items: baseline;
    gap: 10px;
    /* fixed to the longest place name, so ‹ › stay put and can be clicked again and again */
    width: 35ch;
    justify-content: center;
    white-space: nowrap;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.stage-idx {
    font-variant-numeric: tabular-nums;
}

.stage-arrow {
    pointer-events: auto;
    appearance: none;
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    padding: 0 0 2px;
    background: rgba(13, 15, 20, .32);
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink);
    font: 400 1.05rem/1 var(--font-mono);
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background .25s ease, border-color .25s ease, color .25s ease;
}

.stage-arrow:hover,
.stage-arrow:focus-visible {
    background: var(--ink);
    border-color: var(--ink);
    color: #14161b;
}

.hud-label {
    color: var(--ink-dim);
    margin-bottom: 6px !important;
}

.hud-copy {
    color: var(--ink);
    word-break: keep-all;
}

/* Wordmark: hidden on the home screen (the hero carries it), slides in when a section opens */
.hud-brand {
    pointer-events: auto;
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0 0 8px;
    color: var(--ink);
    font: 600 1.15rem/1 var(--font-sans);
    letter-spacing: .34em;
    text-indent: .04em;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .6s ease, transform .6s var(--ease-out), visibility 0s linear .6s;
}

body.section-open .hud-brand {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .6s ease, transform .6s var(--ease-out);
}

/* Manifesto sits on the close button once a section is open; .hud already fades opacity */
body.section-open .hud-tr {
    opacity: 0;
}

.hud-brand:hover {
    color: #fff;
}

#hud-clock {
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Hero (home screen)
   -------------------------------------------------------------------------- */
#hero-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    padding: 60px 90px;
}

/* Soft local haze so the title reads on the bright board */
#hero-text::before {
    content: '';
    position: absolute;
    inset: -20% -10%;
    z-index: -1;
    background: radial-gradient(closest-side, rgba(18, 20, 26, .3), rgba(18, 20, 26, 0));
    pointer-events: none;
}

#hero-text h1 {
    font: 500 clamp(3.2rem, 9vw, 5.4rem)/1 var(--font-mono);
    letter-spacing: .3em;
    text-indent: .3em;
    margin: 0;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}

#hero-text h2 {
    font: 400 clamp(.72rem, 1.4vw, .82rem)/1 var(--font-mono);
    letter-spacing: .58em;
    text-indent: .58em;
    color: rgba(244, 246, 250, .88);
    margin: 18px 0 0;
    text-shadow: var(--text-shadow);
}

/* Menu sits low, above the HUD corner lines, so the objects in the snow stay unobstructed */
#nav-buttons {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--hud-pad) + 60px);
    display: flex;
    justify-content: center;
    gap: clamp(20px, 5vw, 72px);
    z-index: 10;
}

/* Same local haze as the title so the menu reads on the bright board */
#nav-buttons::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(760px, 90vw);
    height: 200px;
    transform: translate(-50%, -50%);
    z-index: -1;
    background: radial-gradient(closest-side, rgba(18, 20, 26, .32), rgba(18, 20, 26, 0));
    pointer-events: none;
}

.nav-btn {
    appearance: none;
    background: none;
    border: 0;
    padding: 10px 4px 12px;
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    color: var(--ink);
    font: 500 .92rem/1 var(--font-mono);
    letter-spacing: .16em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
    cursor: pointer;
    position: relative;
    transition: color .3s ease;
}

.nav-idx {
    font-size: .66rem;
    color: var(--ink-dim);
    letter-spacing: .1em;
}

.nav-btn::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .4s var(--ease-out);
}

.nav-btn:hover::after,
.nav-btn:focus-visible::after {
    transform: scaleX(1);
}

.nav-btn:hover .nav-idx {
    color: var(--ink);
}

/* --------------------------------------------------------------------------
   Section container (sits on the board in the video)
   -------------------------------------------------------------------------- */
.section {
    position: fixed;
    left: auto;
    right: max(16px, 3vw);
    top: var(--board-top);
    width: min(540px, 44vw);
    height: var(--board-height);
    display: none;
    flex-direction: column;
    align-items: stretch;
    z-index: 100;
    padding: 0 8px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    opacity: 0;
    transform: translateY(14px) scale(.985);
    transition: opacity .8s cubic-bezier(.4, 0, .2, 1), transform .8s var(--ease-out);
}

.section::-webkit-scrollbar {
    display: none;
}

.section.active {
    display: flex;
}

.section.is-in {
    opacity: 1;
    transform: none;
}

.section::before {
    content: '';
    position: sticky;
    top: 0;
    display: block;
    height: 0;
    pointer-events: none;
}

.section.active {
    background: linear-gradient(to right, rgba(18, 20, 26, 0), rgba(18, 20, 26, .42) 18%, rgba(18, 20, 26, .55) 100%);
}

.section-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Back / close buttons — sticky so they stay reachable while the section scrolls */
.back-btn {
    position: sticky;
    top: 14px;
    z-index: 5;
    flex: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 -40px;
    padding: 10px 16px 10px 13px;
    /* readable over any part of the scene: a solid dark chip with a bright edge */
    background: rgba(10, 12, 17, .82);
    border: 1px solid rgba(244, 246, 250, .55);
    border-radius: 999px;
    color: #fff;
    font: 500 .78rem/1 var(--font-mono);
    letter-spacing: .14em;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background .25s ease, border-color .25s ease, color .25s ease;
}

.back-btn:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: #14161b;
}

.back-btn > span[aria-hidden] {
    font-size: 1.25em;
    line-height: .8;
}

.home-btn { align-self: flex-end; }
.back-to-categories { align-self: flex-start; }

/* --------------------------------------------------------------------------
   Section header (editorial, left-aligned, with HUD eyebrow + count)
   -------------------------------------------------------------------------- */
.portfolio-header {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 64px 20px 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    column-gap: 24px;
    row-gap: 8px;
    text-align: left;
}

.portfolio-header--sub {
    padding-top: 56px;
}

.hud-eyebrow {
    grid-column: 1 / -1;
    margin: 0;
    font: 400 .7rem/1 var(--font-mono);
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-dim);
    text-shadow: var(--text-shadow);
}

.portfolio-header h2 {
    margin: 0;
    font: 300 clamp(2rem, 4.2vw, 3.3rem)/1.05 var(--font-sans);
    letter-spacing: -.01em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.hud-count {
    margin: 0 0 .5em;
    font: 400 .72rem/1 var(--font-mono);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-dim);
    white-space: nowrap;
    text-shadow: var(--text-shadow);
}

.hud-count:empty {
    display: none;
}

.portfolio-intro {
    grid-column: 1 / -1;
    margin: 10px 0 0;
    max-width: 62ch;
    font: 300 1rem/1.75 var(--font-sans);
    color: var(--ink-dim);
    word-break: keep-all;
    text-shadow: var(--text-shadow);
}

/* --------------------------------------------------------------------------
   Viewfinder brackets (reusable corner marks)
   -------------------------------------------------------------------------- */
@property --c {
    syntax: '<color>';
    inherits: false;
    initial-value: rgba(255, 255, 255, .85);
}

.hud-frame::after,
.project-image::after,
.category-glb-container::after {
    content: '';
    position: absolute;
    inset: 10px;
    pointer-events: none;
    --b: 1px;
    --l: 16px;
    --c: rgba(255, 255, 255, .85);
    background:
        linear-gradient(var(--c), var(--c)) top left / var(--l) var(--b),
        linear-gradient(var(--c), var(--c)) top left / var(--b) var(--l),
        linear-gradient(var(--c), var(--c)) top right / var(--l) var(--b),
        linear-gradient(var(--c), var(--c)) top right / var(--b) var(--l),
        linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--b),
        linear-gradient(var(--c), var(--c)) bottom left / var(--b) var(--l),
        linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--b),
        linear-gradient(var(--c), var(--c)) bottom right / var(--b) var(--l);
    background-repeat: no-repeat;
}

/* --------------------------------------------------------------------------
   Portfolio categories (3D rooms)
   -------------------------------------------------------------------------- */
.category-container {
    width: 100%;
    max-width: none;
    margin: auto;
    padding: 48px 4px 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 10px;
}

.category-item {
    flex: none;
    max-width: none;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    cursor: pointer;
}

.category-glb-container {
    display: none;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 0;
    border-radius: var(--radius);
    transition: transform .6s var(--ease-out);
}

.category-glb-container canvas {
    width: 100% !important;
    height: 100% !important;
    cursor: grab;
}

.category-glb-container canvas:active {
    cursor: grabbing;
}

.category-glb-container::after {
    --c: rgba(255, 255, 255, .55);
    transition: --c .3s, opacity .3s;
}

.category-item:hover .category-glb-container::after {
    --c: rgba(255, 255, 255, .95);
}

.category-item:hover .category-glb-container {
    transform: translateY(-6px);
}

/* index tag + loading readout inside the viewport */
.glb-index,
.glb-loading {
    position: absolute;
    z-index: 2;
    font: 500 .66rem/1 var(--font-mono);
    letter-spacing: .14em;
    color: var(--ink);
    text-shadow: var(--text-shadow);
    pointer-events: none;
}

.glb-index {
    top: 20px;
    left: 22px;
}

.glb-loading {
    left: 22px;
    bottom: 20px;
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
}

.glb-loading:empty {
    display: none;
}

.glb-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 300 1.4rem/1 var(--font-sans);
    letter-spacing: .2em;
    color: var(--ink-dim);
}

.category-info {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    row-gap: 4px;
    column-gap: 12px;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-align: left;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background .3s ease, border-color .3s ease, transform .5s var(--ease-out);
}

.category-item:hover .category-info,
.category-info:focus-visible {
    background: var(--panel-2);
    border-color: var(--line-strong);
}

.category-info h2 {
    margin: 0;
    font: 500 1.1rem/1.2 var(--font-sans);
    letter-spacing: .06em;
    text-transform: uppercase;
}

.category-info p {
    grid-column: 1 / -1;
    margin: 0;
    font: 300 .85rem/1.45 var(--font-sans);
    color: var(--ink-dim);
    word-break: keep-all;
}

.category-info::after {
    content: '→';
    grid-column: 2;
    grid-row: 1;
    font: 400 .9rem/1 var(--font-mono);
    color: var(--ink-dim);
    transition: transform .35s var(--ease-out), color .3s ease;
}

.category-item:hover .category-info::after {
    transform: translateX(5px);
    color: var(--ink);
}

/* --------------------------------------------------------------------------
   Project cards (editorial zig-zag)
   -------------------------------------------------------------------------- */
.portfolio-grid {
    width: 100%;
    max-width: none;
    margin: 20px 0 56px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    counter-reset: project;
}

.project-item {
    position: relative;
    display: flex;
    counter-increment: project;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: background .35s ease, border-color .35s ease, transform .55s var(--ease-out), box-shadow .55s ease;
}

.project-item::before {
    content: counter(project, decimal-leading-zero);
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    padding: 5px 7px;
    font: 500 .62rem/1 var(--font-mono);
    letter-spacing: .14em;
    color: var(--ink-dim);
}

.project-item:hover {
    background: var(--panel-2);
    border-color: var(--line-strong);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}

@media (min-width: 769px) {
    .portfolio-grid .project-item:nth-child(even) {
        flex-direction: row;
    }
}

.project-image {
    position: relative;
    flex: 0 0 46%;
    min-height: 300px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(0, 0, 0, .2);
}

.project-image img,
.project-image video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(.85);
    transition: transform .7s var(--ease-out), filter .5s ease;
}

.project-image:hover img,
.project-image:hover video,
.project-image:focus-visible img,
.project-image:focus-visible video {
    transform: scale(1.03);
    filter: none;
}

.project-image::before {
    content: counter(project, decimal-leading-zero);
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    padding: 6px 8px;
    font: 500 .66rem/1 var(--font-mono);
    letter-spacing: .14em;
    color: var(--ink);
    background: rgba(13, 15, 20, .55);
    border: 1px solid var(--line);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.project-image::after {
    opacity: 0;
    transition: opacity .35s ease;
}

.project-image:hover::after,
.project-image:focus-visible::after {
    opacity: 1;
}

.image-expand-hint {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    padding: 6px 9px;
    font: 400 .66rem/1 var(--font-mono);
    letter-spacing: .1em;
    color: var(--ink);
    background: rgba(13, 15, 20, .55);
    border: 1px solid var(--line);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .3s ease, transform .3s var(--ease-out);
}

.project-image:hover .image-expand-hint,
.project-image:focus-visible .image-expand-hint {
    opacity: 1;
    transform: none;
}

@media (hover: none) {
    .image-expand-hint {
        opacity: 1;
        transform: none;
    }
}

.project-content {
    flex: 1;
    min-width: 0;
    padding: 28px 22px 24px 56px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.project-content h3 {
    margin: 0;
    font: 500 1.45rem/1.3 var(--font-sans);
    letter-spacing: -.01em;
    text-align: left;
    word-break: keep-all;
}

.tech-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    margin: 0;
}

.tech-tags span {
    padding: 6px 8px;
    font: 400 .66rem/1 var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-dim);
    border: 1px solid var(--line);
    border-radius: 2px;
}

.project-description {
    margin: 0;
    font: 300 .97rem/1.78 var(--font-sans);
    color: rgba(244, 246, 250, .82);
    text-align: left;
    word-break: keep-all;
}

.project-description a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--line-strong);
    text-underline-offset: 3px;
    transition: text-decoration-color .3s ease;
}

.project-description a:hover {
    text-decoration-color: var(--ink);
}

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */
.about-container {
    width: 100%;
    max-width: 1200px;
    margin: 28px auto 72px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    text-align: left;
}

.about-panel,
.about-skills,
.about-experience,
.contact-info {
    position: relative;
    padding: 28px 30px 30px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: background .35s ease, border-color .35s ease, transform .55s var(--ease-out);
}

.about-panel:hover,
.about-skills:hover,
.about-experience:hover,
.contact-info:hover {
    background: var(--panel-2);
    border-color: var(--line-strong);
}

.about-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 10px 24px;
}

.about-header h2 {
    margin: 0;
    font: 400 clamp(1.5rem, 2.6vw, 2rem)/1.2 var(--font-sans);
    letter-spacing: -.01em;
}

.about-header-info {
    grid-column: 1 / -1;
    margin: 0;
}

.about-header-info p {
    margin: 0;
    font: 400 .74rem/1.7 var(--font-mono);
    letter-spacing: .06em;
    color: var(--ink-dim);
    word-break: keep-all;
}

.about-tag {
    font: 400 .68rem/1 var(--font-mono);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-dim);
    white-space: nowrap;
    margin-bottom: .4em;
}

.about-content,
.about-bottom-section {
    display: grid;
    gap: 22px;
}

.about-bottom-section {
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
    align-items: start;
}

.about-bottom-section:not(:has(.about-experience)) {
    grid-template-columns: 1fr;
}

.about-skills h3,
.about-experience h3,
.contact-info h3 {
    margin: 0 0 22px;
    font: 400 .7rem/1 var(--font-mono);
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.about-skills h3::before,
.about-experience h3::before,
.contact-info h3::before {
    content: '// ';
}

.skills-category {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.skills-category:last-child {
    padding-bottom: 0;
}

.skills-category h4 {
    margin: 0;
    font: 500 .92rem/1.5 var(--font-sans);
    letter-spacing: .01em;
}

.skills-category p {
    margin: 0;
    font: 300 .92rem/1.7 var(--font-sans);
    color: var(--ink-dim);
}

.experience-item {
    position: relative;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 6px 18px;
    padding: 18px 0 18px 22px;
    border-top: 1px solid var(--line);
}

.experience-item:last-child {
    padding-bottom: 0;
}

.experience-item::before {
    content: '+';
    position: absolute;
    left: 0;
    top: 16px;
    font: 400 .9rem/1 var(--font-mono);
    color: var(--ink-dim);
}

.experience-item .year {
    grid-row: 1 / span 3;
    font: 400 .72rem/1.9 var(--font-mono);
    letter-spacing: .08em;
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
}

.experience-item h4 {
    margin: 0;
    font: 500 1.02rem/1.45 var(--font-sans);
}

.experience-item p {
    margin: 0;
    font: 300 .9rem/1.65 var(--font-sans);
    color: var(--ink-dim);
    word-break: keep-all;
}

.experience-item p:first-of-type {
    color: var(--ink);
    font-weight: 400;
}

.contact-info {
    display: flex;
    flex-direction: column;
}

.contact-detail {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: baseline;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    font: 400 .84rem/1.5 var(--font-mono);
    letter-spacing: .02em;
}

.contact-detail .contact-key {
    font-size: .66rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-dim);
}

.contact-detail a {
    justify-self: start;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    transition: border-color .3s ease;
}

.contact-detail a:hover {
    border-color: var(--ink);
}

.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.hud-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    font: 500 .7rem/1 var(--font-mono);
    letter-spacing: .16em;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    transition: background .25s ease, color .25s ease, border-color .25s ease;
}

.hud-btn:hover,
.hud-btn:focus-visible {
    background: var(--ink);
    border-color: var(--ink);
    color: #14161b;
}

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 11, 14, .94);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease, visibility 0s linear .25s;
}

.image-modal.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity .25s ease;
}

.image-modal img,
.image-modal video {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
    transform: scale(.96);
    transition: transform .3s var(--ease-out);
}

.image-modal.open img,
.image-modal.open video {
    transform: none;
}

.modal-close,
.modal-nav {
    position: absolute;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--line);
    border-radius: 2px;
    color: var(--ink);
    font: 400 .7rem/1 var(--font-mono);
    letter-spacing: .14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.modal-close:hover,
.modal-nav:hover {
    background: rgba(255, 255, 255, .16);
    border-color: var(--line-strong);
}

.modal-close {
    top: 24px;
    right: 24px;
    gap: 8px;
}

.modal-nav {
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
}

.modal-nav[hidden] {
    display: none;
}

.modal-prev { left: 24px; }
.modal-next { right: 24px; }

@media (max-width: 480px) {
    .modal-prev { left: 8px; }
    .modal-next { right: 8px; }
    .modal-close { top: 10px; right: 10px; }
}

/* --------------------------------------------------------------------------
   Focus & reveal
   -------------------------------------------------------------------------- */
.project-image:focus-visible,
.category-info:focus-visible,
.nav-btn:focus-visible,
.back-btn:focus-visible,
.hud-brand:focus-visible,
.modal-close:focus-visible,
.modal-nav:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .85);
    outline-offset: 3px;
}

/* Scroll-in reveal — long rise + clip, like a soft agency list */
.reveal {
    opacity: 0;
    transform: translate3d(0, 52px, 0);
    clip-path: inset(14% 0 0 0);
    filter: blur(4px);
    pointer-events: none;
}

.reveal.is-revealed {
    animation: itemReveal 1.25s var(--ease-expo) both;
    animation-delay: var(--reveal-delay, 0ms);
    pointer-events: auto;
}

@keyframes itemReveal {
    from {
        opacity: 0;
        transform: translate3d(0, 52px, 0);
        clip-path: inset(14% 0 0 0);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: none;
        clip-path: inset(0);
        filter: blur(0);
    }
}


/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .category-container {
        flex-wrap: wrap;
        padding: 60px 12px 30px;
        gap: 22px;
    }

    .category-item {
        flex: 1 1 260px;
        max-width: 420px;
    }

    .category-glb-container {
        min-height: 240px;
    }

    .about-bottom-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --hud-pad: 16px;
    }

    #hud {
        font-size: .64rem;
    }

    .hud {
        max-width: 24ch;
    }

    .hud-tr,
    .hud-br {
        display: none;
    }

    /* top-right corner (the manifesto is hidden here): ‹ › on the first row, index and name under
       them, so it never runs into the top-left block */
    .hud-tc {
        left: auto;
        right: var(--hud-pad);
        transform: none;
        width: 150px;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 6px 8px;
    }

    .stage-now {
        order: 3;
        width: 100%;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        white-space: normal;
        text-align: right;
    }

    .stage-arrow {
        width: 26px;
        height: 26px;
    }

    /* Callouts stay: they are the tap targets for the small objects in the snow */
    #ice-callouts {
        font-size: .66rem;
    }

    .ice-callout-sub {
        display: none;
    }

    .ice-callout-label {
        padding: 8px 10px;
    }

    #radio-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: calc(var(--hud-pad) + 138px);
    }

    body.section-open .hud-bl {
        opacity: 0;
    }

    /* the hint wraps to several lines on phones: the menu sits above it */
    .hud-bl {
        max-width: 62vw;
    }

    #hero-text {
        padding: 40px 30px;
    }

    #nav-buttons {
        bottom: calc(var(--hud-pad) + 96px);
        gap: 18px;
    }

    .nav-btn {
        font-size: .78rem;
        letter-spacing: .12em;
        gap: 7px;
    }

    .section {
        left: 12px;
        right: 12px;
        top: 36vh;
        width: auto;
        height: auto;
        bottom: 12px;
        padding: 0 12px 16px;
    }

    /* Both controls sit right so they never collide with the wordmark corner */
    .back-to-categories {
        align-self: flex-end;
    }

    .portfolio-header {
        padding: 60px 8px 6px;
        grid-template-columns: 1fr;
    }

    .hud-count {
        margin: 0;
        order: 3;
    }

    .portfolio-grid {
        gap: 24px;
        margin-top: 20px;
    }

    .project-item {
        flex-direction: column;
    }

    .project-image {
        flex: none;
        width: 100%;
        min-height: 0;
        aspect-ratio: 16 / 10;
    }

    /* corner index is position:absolute at top:14px; 22px let it sit on the title */
    .project-content {
        padding: 48px 20px 24px;
        gap: 12px;
    }

    .project-content h3 {
        font-size: 1.25rem;
    }

    .about-container {
        padding: 0 8px;
        gap: 14px;
    }

    .about-panel,
    .about-skills,
    .about-experience,
    .contact-info {
        padding: 20px 18px 22px;
    }

    .about-header {
        grid-template-columns: 1fr;
    }

    .skills-category {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .experience-item {
        grid-template-columns: 1fr;
        padding-left: 18px;
    }

    .experience-item .year {
        grid-row: auto;
    }

}

@media (max-height: 640px) {
    #nav-buttons {
        bottom: calc(var(--hud-pad) + 44px);
    }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    #grain {
        animation: none;
    }

    #ice-world {
        transition: none;
        transform: none !important;
    }

    .reveal,
    .reveal.is-revealed {
        opacity: 1 !important;
        transform: none !important;
        clip-path: none !important;
        filter: none !important;
        animation: none !important;
        transition: none !important;
        pointer-events: auto !important;
    }

    .section,
    .image-modal,
    .image-modal img,
    .image-modal video,
    .project-image img,
    .project-image video,
    .project-item,
    .category-item,
    .category-glb-container,
    .hud-brand,
    #video-background {
        transition: none !important;
        animation: none !important;
    }

    .category-item {
        opacity: 1 !important;
        transform: none !important;
    }
}
