/* ==========================================================================
   Works page: the 3D gallery, its HUD, the project index and the fallback dialog.
   Shared tokens, header, buttons and footer live in site.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Gallery shell
   -------------------------------------------------------------------------- */

.gallery {
    position: relative;
    height: 100vh;
    height: 100svh;
    min-height: 520px;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg) 0%, var(--surface-3) 100%);
    isolation: isolate;
}

#gallery-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    touch-action: pan-y;
    cursor: grab;
}

#gallery-canvas.is-dragging {
    cursor: grabbing;
}

#gallery-canvas.is-hovering {
    cursor: pointer;
}

#gallery-canvas:focus-visible {
    box-shadow: inset 0 0 0 2px var(--cyan-ink);
}

/* A whisper of white under the header and a soft edge falloff, so the HUD always has something to sit on. */
.g-vignette {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(245, 247, 250, 0.7) 0, rgba(245, 247, 250, 0) 150px),
        radial-gradient(120% 95% at 50% 46%, rgba(15, 23, 32, 0) 62%, rgba(15, 23, 32, 0.1) 100%);
}

/* --------------------------------------------------------------------------
   Loader
   -------------------------------------------------------------------------- */

.g-loader {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 22px;
    background:
        radial-gradient(46% 40% at 38% 40%, rgba(0, 212, 230, 0.16), transparent 70%),
        radial-gradient(46% 40% at 64% 58%, rgba(123, 108, 255, 0.14), transparent 70%),
        var(--bg);
    transition: opacity 0.9s var(--ease-out), visibility 0.9s, transform 1.1s var(--ease-out);
}

.g-loader.is-done {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.04);
}

.g-loader-mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
}

/* A cyan-to-violet arc orbits the mark */
.g-loader-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(0, 212, 230, 0) 0deg, #00D4E6 150deg, #7B6CFF 300deg, rgba(123, 108, 255, 0) 360deg);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
    animation: g-orbit 1.5s linear infinite;
}

.g-loader-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 128, 143, 0.3));
    animation: g-breathe 2.6s var(--ease) infinite;
}

.g-loader-text {
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.g-loader-bar {
    width: 168px;
    height: 2px;
    border-radius: 2px;
    background: rgba(15, 23, 32, 0.08);
    overflow: hidden;
}

.g-loader-bar span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: var(--grad-bright);
    transform: scaleX(0.04);
    transform-origin: left center;
    transition: transform 0.6s var(--ease-out);
}

@keyframes g-orbit {
    to { transform: rotate(360deg); }
}

@keyframes g-breathe {
    0%, 100% { transform: scale(0.96); }
    50% { transform: scale(1.03); }
}

/* Fallback (no WebGL, or the gallery could not load) */
.g-fallback {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    padding: 120px 24px 40px;
    text-align: center;
    background: var(--bg);
}

.g-fallback .material-symbols-outlined {
    font-size: 44px;
    color: var(--cyan-ink);
}

.g-fallback h2 {
    max-width: 22ch;
    color: var(--ink);
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.g-fallback p {
    margin-bottom: 10px;
    color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   Title card
   -------------------------------------------------------------------------- */

.g-title {
    position: absolute;
    z-index: 11;
    left: max(40px, calc(var(--safe-l) + 20px));
    top: calc(var(--nav-h) + clamp(28px, 6vh, 64px));
    max-width: min(560px, calc(100% - 48px));
    pointer-events: none;
    transition: opacity 0.7s var(--ease-out), transform 0.9s var(--ease-out), visibility 0.7s;
}

/* A pool of soft white behind the words, so they read on any wall */
.g-title::before {
    content: '';
    position: absolute;
    inset: -70px -110px -70px -90px;
    z-index: -1;
    background: radial-gradient(closest-side, rgba(245, 247, 250, 0.9), rgba(245, 247, 250, 0.55) 55%, rgba(245, 247, 250, 0));
}

.g-title h1 {
    margin: 18px 0 16px;
    color: var(--ink);
    font-size: clamp(36px, 5vw, 64px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.g-title-sub {
    max-width: 48ch;
    color: var(--ink-2);
    font-size: clamp(16px, 1.3vw, 18px);
    font-weight: 400;
    line-height: 1.6;
}

/* Each line rises in once the gallery is ready */
.g-title > * {
    opacity: 0;
    transform: translateY(22px);
}

.gallery.is-ready .g-title > * {
    opacity: 1;
    transform: none;
    transition: opacity 1s var(--ease-out), transform 1.2s var(--ease-out);
}

.gallery.is-ready .g-title > :nth-child(1) { transition-delay: 0.35s; }
.gallery.is-ready .g-title > :nth-child(2) { transition-delay: 0.47s; }
.gallery.is-ready .g-title > :nth-child(3) { transition-delay: 0.62s; }

.g-title.is-away {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-14px);
}

/* --------------------------------------------------------------------------
   HUD: joystick and key legend (bottom left)
   -------------------------------------------------------------------------- */

.g-controls {
    position: absolute;
    z-index: 12;
    left: max(40px, calc(var(--safe-l) + 20px));
    bottom: calc(32px + var(--safe-b));
    display: flex;
    align-items: flex-end;
    gap: 14px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.8s var(--ease-out) 0.7s, transform 1s var(--ease-out) 0.7s;
}

.gallery.is-ready .g-controls {
    opacity: 1;
    transform: none;
}

.g-joystick {
    --joy: clamp(104px, 12vmin, 124px);
}

.g-joy-base {
    position: relative;
    width: var(--joy);
    height: var(--joy);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.96), rgba(226, 235, 244, 0.86) 78%);
    box-shadow: 0 0 0 1px rgba(0, 122, 136, 0.28), 0 16px 34px -16px rgba(15, 23, 32, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: grab;
    transition: box-shadow 0.3s var(--ease-out);
}

.g-joy-base.is-active {
    cursor: grabbing;
    box-shadow: 0 0 0 1px rgba(0, 122, 136, 0.55), 0 0 0 7px rgba(0, 191, 208, 0.12), 0 16px 34px -16px rgba(15, 23, 32, 0.45);
}

.g-joy-thumb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 38%;
    height: 38%;
    margin: -19% 0 0 -19%;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    background: radial-gradient(circle at 38% 30%, #7FF1F8, #00A9BA 60%, #5F54E8 130%);
    box-shadow: 0 8px 16px -6px rgba(0, 128, 143, 0.75), inset 0 -3px 6px rgba(15, 23, 32, 0.15);
    will-change: transform;
    pointer-events: none;
    transition: box-shadow 0.25s var(--ease-out);
}

.g-joy-base.is-active .g-joy-thumb {
    box-shadow: 0 0 20px rgba(0, 212, 230, 0.65), inset 0 -3px 6px rgba(15, 23, 32, 0.15);
}

.g-joy-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 4.5px solid transparent;
    opacity: 0.55;
    pointer-events: none;
}

.g-joy-arrow.up { top: 10px; left: 50%; margin-left: -4.5px; border-top: 0; border-bottom-color: var(--cyan-ink); }
.g-joy-arrow.down { bottom: 10px; left: 50%; margin-left: -4.5px; border-bottom: 0; border-top-color: var(--cyan-ink); }
.g-joy-arrow.left { left: 10px; top: 50%; margin-top: -4.5px; border-left: 0; border-right-color: var(--cyan-ink); }
.g-joy-arrow.right { right: 10px; top: 50%; margin-top: -4.5px; border-right: 0; border-left-color: var(--cyan-ink); }

.g-keys {
    display: grid;
    gap: 9px;
    padding: 14px 20px 14px 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-2);
    transition: opacity 0.6s var(--ease);
}

/* Once you have been walking for a while the legend steps back; hover or focus brings it forward again. */
.g-controls.is-quiet .g-keys {
    opacity: 0.5;
}

.g-controls.is-quiet .g-keys:hover {
    opacity: 1;
}

.g-key-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.g-key-row dt {
    display: flex;
    flex: none;
    justify-content: center;
    width: 78px;
}

.g-key-row dd {
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

.g-keypad {
    display: grid;
    grid-template-columns: repeat(3, 24px);
    grid-template-rows: repeat(2, 24px);
    gap: 3px;
}

.g-keypad .k-w { grid-column: 2; grid-row: 1; }
.g-keypad .k-a { grid-column: 1; grid-row: 2; }
.g-keypad .k-s { grid-column: 2; grid-row: 2; }
.g-keypad .k-d { grid-column: 3; grid-row: 2; }

.k-wide {
    padding: 0 9px;
}

body.is-touch .g-keys {
    display: none;
}

/* --------------------------------------------------------------------------
   In-scene prompt: rides under the nearest frame
   -------------------------------------------------------------------------- */

.g-prompt {
    --x: 50vw;
    --y: 50vh;
    position: absolute;
    z-index: 12;
    left: 0;
    top: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: min(300px, calc(100% - 32px));
    min-height: 44px;
    padding: 6px 18px 6px 8px;
    border-radius: var(--r-pill);
    background: rgba(15, 23, 32, 0.9);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(94, 234, 245, 0.35), 0 18px 36px -16px rgba(15, 23, 32, 0.7), 0 0 28px -6px rgba(0, 212, 230, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-align: left;
    translate: var(--x) var(--y);
    transform: translate(-50%, 8px) scale(0.92);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.5s var(--ease-spring);
    will-change: translate, transform;
}

.g-prompt.is-on {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) scale(1);
}

.g-prompt.is-on:hover {
    transform: translate(-50%, -2px) scale(1.03);
}

.g-prompt kbd {
    min-width: 30px;
    height: 30px;
    border-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    border-bottom-width: 1px;
    background: var(--grad-bright);
    color: #06222A;
    font-size: 13px;
    animation: g-key-pulse 1.8s var(--ease) infinite;
}

@keyframes g-key-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(94, 234, 245, 0.55); }
    60% { box-shadow: 0 0 0 9px rgba(94, 234, 245, 0); }
}

.g-prompt-body {
    display: grid;
    min-width: 0;
    line-height: 1.2;
}

.g-prompt-action {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.g-prompt-title {
    overflow: hidden;
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.is-touch .g-prompt {
    padding-left: 18px;
}

body.is-touch .g-prompt kbd {
    display: none;
}

/* Scroll cue (bottom right): the page continues below the gallery */
.g-scrollcue {
    position: absolute;
    z-index: 12;
    right: max(40px, calc(var(--safe-r) + 20px));
    bottom: calc(32px + var(--safe-b));
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px 0 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-2);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.8s var(--ease-out) 0.9s, color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.gallery.is-ready .g-scrollcue {
    opacity: 1;
}

.g-scrollcue:hover {
    border-color: rgba(0, 122, 136, 0.45);
    color: var(--cyan-ink);
}

.g-scrollcue .material-symbols-outlined {
    font-size: 16px;
    animation: g-nudge 2.2s var(--ease) infinite;
}

@keyframes g-nudge {
    0%, 100% { transform: translateY(-2px); }
    50% { transform: translateY(3px); }
}

/* --------------------------------------------------------------------------
   Inspect bar: the camera is at the frame; this is its caption
   -------------------------------------------------------------------------- */

body.is-inspecting .g-controls,
body.is-inspecting .g-scrollcue,
body.is-inspecting .g-prompt,
body.is-inspecting .g-title {
    display: none;
}

.g-inspect {
    position: absolute;
    z-index: 13;
    left: 50%;
    bottom: calc(28px + var(--safe-b));
    display: flex;
    align-items: center;
    gap: 24px;
    width: min(1060px, calc(100% - 32px));
    padding: 20px 20px 20px 28px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--glass-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-3);
    transform: translateX(-50%);
    animation: g-inspect-in 0.7s var(--ease-out) both;
}

/* The accent runs along the top edge of the caption */
.g-inspect::before {
    content: '';
    position: absolute;
    left: 28px;
    right: 28px;
    top: -1px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(0, 212, 230, 0), #00D4E6 20%, #7B6CFF 80%, rgba(123, 108, 255, 0));
}

@keyframes g-inspect-in {
    from { opacity: 0; transform: translate(-50%, 22px); }
}

.g-inspect-info {
    flex: 1;
    min-width: 0;
}

.g-inspect-kicker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.g-inspect-count {
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.12em;
}

.g-inspect-count:not(:empty)::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 1px;
    margin-left: 12px;
    background: var(--line-strong);
    vertical-align: middle;
}

.g-inspect-info h2 {
    margin: 8px 0 3px;
    overflow: hidden;
    color: var(--ink);
    font-size: clamp(20px, 2.2vw, 28px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.g-inspect-meta {
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 500;
}

.g-inspect-about {
    display: -webkit-box;
    max-width: 62ch;
    margin-top: 8px;
    overflow: hidden;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.5;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* The words change with the project: let them settle in each time */
.g-inspect-info.is-swap > * {
    animation: g-swap 0.5s var(--ease-out) both;
}

.g-inspect-info.is-swap > :nth-child(2) { animation-delay: 0.04s; }
.g-inspect-info.is-swap > :nth-child(3) { animation-delay: 0.08s; }
.g-inspect-info.is-swap > :nth-child(4) { animation-delay: 0.12s; }

@keyframes g-swap {
    from { opacity: 0; transform: translateY(8px); }
}

.g-inspect-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 10px;
}

.g-inspect-nav {
    display: flex;
    gap: 6px;
    margin-right: 6px;
}

.g-inspect-close kbd {
    min-width: 0;
    height: 20px;
    margin-left: 2px;
    padding: 0 6px;
    border-bottom-width: 2px;
    font-size: 10px;
}

/* --------------------------------------------------------------------------
   Project index
   -------------------------------------------------------------------------- */

.index {
    max-width: 1440px;
    margin: 0 auto;
    padding: clamp(72px, 10vw, 128px) var(--gutter) clamp(56px, 7vw, 96px);
}

.index-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: clamp(28px, 4vw, 48px);
}

.index-head h2 {
    margin-top: 18px;
    color: var(--ink);
    font-size: clamp(32px, 4.6vw, 64px);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
}

.index-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(340px, 100%);
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink-3);
    transition: border-color 0.2s var(--ease), box-shadow 0.25s var(--ease-out);
}

.index-search:hover {
    border-color: rgba(15, 23, 32, 0.24);
}

.index-search:focus-within {
    border-color: var(--cyan-ink);
    box-shadow: 0 0 0 4px rgba(0, 191, 208, 0.16);
    color: var(--cyan-ink);
}

.index-search input {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    -webkit-appearance: none;
    appearance: none;
}

.index-search input::placeholder {
    color: var(--ink-3);
    opacity: 0.8;
}

.index-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.index-status {
    padding-bottom: 14px;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.index-list {
    border-top: 1px solid var(--line-strong);
}

.index-item {
    position: relative;
    display: grid;
    grid-template-columns: 44px 148px minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
    padding: 22px 16px;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    transition: background 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-radius 0.35s var(--ease-out),
        opacity 0.8s var(--ease-out), transform 0.9s var(--ease-out);
}

.index-item:hover {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: 0 24px 48px -32px rgba(15, 23, 32, 0.45);
}

/* Rows rise in as they scroll into view (set up by main.js; skipped for reduced motion) */
.index-list.is-reveal .index-item {
    opacity: 0;
    transform: translateY(20px);
}

.index-list.is-reveal .index-item.is-in {
    opacity: 1;
    transform: none;
    transition-delay: 0s, 0s, 0s, calc(var(--i, 0) * 60ms), calc(var(--i, 0) * 60ms);
}

.index-num {
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.12em;
    transition: color 0.3s var(--ease);
}

.index-item:hover .index-num {
    color: var(--cyan-ink);
}

.index-thumb {
    display: block;
    width: 148px;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background:
        radial-gradient(90% 100% at 20% 20%, rgba(0, 212, 230, 0.3), transparent 60%),
        radial-gradient(90% 100% at 85% 85%, rgba(123, 108, 255, 0.26), transparent 60%),
        var(--surface-2);
}

.index-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.9s var(--ease-out);
}

.index-item:hover .index-thumb img {
    transform: scale(1.06);
}

.index-item h3 {
    color: var(--ink);
    font-size: clamp(17px, 1.5vw, 21px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.index-meta {
    margin-top: 5px;
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 500;
}

.index-meta .cat {
    color: var(--cyan-ink);
    font-weight: 700;
}

.index-about {
    display: -webkit-box;
    max-width: 68ch;
    margin-top: 8px;
    overflow: hidden;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 1.55;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.index-actions {
    display: flex;
    gap: 8px;
}

.index-back {
    margin-top: 36px;
}

/* --------------------------------------------------------------------------
   Detail dialog (used when the 3D gallery is unavailable)
   -------------------------------------------------------------------------- */

.detail {
    width: min(880px, calc(100vw - 32px));
    max-height: min(88vh, 900px);
    max-height: min(88dvh, 900px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--ink-2);
    box-shadow: 0 40px 100px -40px rgba(15, 23, 32, 0.55);
    overflow: hidden;
}

.detail::backdrop {
    background: rgba(15, 23, 32, 0.38);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.detail[open] {
    animation: g-detail-in 0.5s var(--ease-out);
}

.detail[open]::backdrop {
    animation: g-fade 0.5s var(--ease-out);
}

@keyframes g-detail-in {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
}

@keyframes g-fade {
    from { opacity: 0; }
}

.detail-shell {
    display: flex;
    flex-direction: column;
    max-height: inherit;
}

.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 24px 18px 28px;
    border-bottom: 1px solid var(--line);
}

.detail-head h2 {
    margin: 10px 0 4px;
    color: var(--ink);
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.12;
}

.detail-company {
    color: var(--ink-3);
    font-size: 14px;
}

.detail-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 28px 8px;
}

.detail-media {
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    aspect-ratio: 16 / 9;
}

.detail-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--surface-2);
}

.detail-placeholder {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    height: 100%;
    background:
        radial-gradient(80% 90% at 30% 20%, rgba(0, 212, 230, 0.16), transparent 60%),
        radial-gradient(70% 80% at 80% 90%, rgba(123, 108, 255, 0.14), transparent 60%),
        var(--surface-2);
    color: var(--ink-3);
    font-size: 13px;
}

.detail-placeholder img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    opacity: 0.75;
}

.detail-section h3 {
    margin-bottom: 8px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
}

.detail-section p {
    margin-bottom: 24px;
    color: var(--ink-2);
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-line;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.detail-tags li {
    padding: 7px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    background: var(--bg);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.detail-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.detail-facts div {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--bg);
}

.detail-facts dt {
    margin-bottom: 6px;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.detail-facts dd {
    color: var(--ink);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.detail-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 24px calc(18px + var(--safe-b));
    border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
    .g-controls,
    .g-title {
        left: max(24px, calc(var(--safe-l) + 16px));
    }

    .g-scrollcue {
        right: max(24px, calc(var(--safe-r) + 16px));
    }

    .g-inspect-about {
        -webkit-line-clamp: 1;
    }
}

@media (max-width: 960px) {
    .g-keys {
        display: none;
    }

    .index-item {
        grid-template-columns: 36px 120px minmax(0, 1fr);
        gap: 18px;
    }

    .index-thumb {
        width: 120px;
    }

    .index-actions {
        grid-column: 2 / -1;
    }
}

@media (max-width: 820px) {
    .gallery {
        min-height: 480px;
    }

    .g-title {
        left: calc(20px + var(--safe-l));
        top: calc(var(--nav-h) + 22px);
    }

    .g-title h1 {
        margin: 14px 0 12px;
    }

    /* Thumb on the right for the joystick, cue on the left */
    .g-controls {
        left: auto;
        right: calc(16px + var(--safe-r));
        bottom: calc(20px + var(--safe-b));
    }

    .g-joystick {
        --joy: clamp(108px, 30vmin, 132px);
    }

    .g-scrollcue {
        left: calc(16px + var(--safe-l));
        right: auto;
        bottom: calc(26px + var(--safe-b));
    }

    .g-inspect {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        bottom: calc(12px + var(--safe-b));
        width: calc(100% - 24px);
        padding: 18px 16px 14px;
        border-radius: 20px;
    }

    .g-inspect::before {
        left: 20px;
        right: 20px;
    }

    .g-inspect-about {
        display: none;
    }

    .g-inspect-actions {
        flex-wrap: wrap;
    }

    .g-inspect-nav {
        margin-right: auto;
    }

    .g-inspect-close kbd {
        display: none;
    }

    #inspect-link {
        order: 3;
        flex-basis: 100%;
    }

    .index-item {
        grid-template-columns: 96px minmax(0, 1fr);
        gap: 14px 16px;
        padding: 18px 4px;
    }

    .index-item:hover {
        background: none;
        border-radius: 0;
        box-shadow: none;
    }

    .index-num {
        display: none;
    }

    .index-thumb {
        width: 96px;
        align-self: start;
    }

    .index-actions {
        grid-column: 1 / -1;
    }

    .index-actions .g-btn {
        flex: 1;
    }

    /* Detail opens as a bottom sheet */
    .detail {
        width: 100vw;
        max-width: 100vw;
        max-height: 88dvh;
        margin: auto 0 0;
        border-bottom: 0;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
    }

    .detail[open] {
        animation: g-sheet-in 0.5s var(--ease-out);
    }

    .detail-head {
        padding: 18px 16px 14px 20px;
    }

    .detail-body {
        padding: 18px 20px 4px;
    }

    .detail-foot {
        padding: 12px 16px calc(14px + var(--safe-b));
    }

    .detail-foot .g-btn {
        flex: 1;
        padding: 0 12px;
    }

    .detail-foot #detail-link {
        order: -1;
        flex-basis: 100%;
    }
}

@keyframes g-sheet-in {
    from { opacity: 0; transform: translateY(40px); }
}

@media (max-height: 560px) and (orientation: landscape) {
    .g-joystick {
        --joy: 100px;
    }

    .g-controls,
    .g-scrollcue {
        bottom: calc(14px + var(--safe-b));
    }

    .g-title {
        top: calc(var(--nav-h) + 12px);
    }

    .g-title h1 {
        margin: 8px 0;
        font-size: 30px;
    }

    .g-title-sub {
        display: none;
    }

    .g-inspect {
        flex-direction: row;
        align-items: center;
        padding: 12px 14px 12px 20px;
    }

    .g-inspect-meta {
        display: none;
    }
}


/* Pushing the joystick out to its rim runs (the touch equivalent of Shift) */
.g-joy-base.is-running {
    box-shadow: 0 0 0 1px rgba(95, 84, 232, 0.6), 0 0 0 9px rgba(123, 108, 255, 0.16), 0 16px 34px -16px rgba(15, 23, 32, 0.45);
}

.g-joy-base.is-running .g-joy-thumb {
    box-shadow: 0 0 24px rgba(123, 108, 255, 0.7), inset 0 -3px 6px rgba(15, 23, 32, 0.15);
}
