/* css/cave-office.css — The Field Office
   A sea-cave workshop toured sideways: vertical scroll swims the diver
   horizontally past six works. Three layers pan at different rates; each
   layer's travel is its own width minus one viewport, so the cave mouth
   composes at the start of the swim and the skylight at the end.

   Sea Glass & Current rules apply: organic radii, borders lit from the
   surface above, mono instrument voice, no uniform rounded boxes. */

:root {
    --cave-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

body.cave-office {
    /* `clip`, not `hidden`: an overflow-hidden body becomes a scroll
       container, and the tour's position:sticky viewport would stick to
       the body (which never scrolls) instead of the window — the whole
       cave would scroll straight off screen. */
    overflow-x: clip;
    background:
        linear-gradient(180deg, #05121f 0%, #04101c 55%, #020910 100%);
}

.cave-main {
    position: relative;
    z-index: 1;
}

/* ===== The tour: a tall page that pans a wide cave =====
   The unitless vars are consumed as vw by the layers and stations, and
   scaled per breakpoint through --kx/--kw so one set of station coords
   serves every screen. */
.cave-tour {
    --strip-w: 562;
    --far-w: 312;
    --near-w: 810;
    --pace: 0.9;
    position: relative;
    height: calc(100vh + (var(--strip-w) - 100) * var(--pace) * 1vw);
}

.cave-viewport {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

@supports (height: 100svh) {
    .cave-viewport {
        height: 100svh;
    }
}

.cave-layer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    will-change: transform;
}

.cave-far {
    width: calc(var(--far-w) * 1vw);
    z-index: 1;
}

.far-wall {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.cave-mid {
    --kx: 1;
    --kw: 1;
    width: calc(var(--strip-w) * 1vw);
    z-index: 2;
}

.cave-near {
    width: calc(var(--near-w) * 1vw);
    z-index: 3;
    pointer-events: none;
}

/* ===== Mid-layer bones: ceiling, floor, guide line ===== */
.cave-ceiling {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 21vh;
}

.cave-floor {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 23vh;
}

.cave-rope {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    animation: ropeDrift 9s ease-in-out infinite alternate;
}

@keyframes ropeDrift {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(0.6vh);
    }
}

/* ===== Near-layer silhouettes ===== */
.near-piece {
    position: absolute;
    bottom: 0;
    left: var(--nx-m, var(--nx, 0));
    width: 34vw;
    height: 74vh;
    filter: blur(1.2px);
    opacity: 0.96;
}

.near-piece.near-top {
    top: 0;
    bottom: auto;
    height: 52vh;
}

.near-frond {
    transform-origin: top center;
    animation: frondSway 8s ease-in-out infinite alternate;
}

.near-frond--late {
    animation-delay: -3.4s;
    animation-duration: 10s;
}

@keyframes frondSway {
    from {
        transform: rotate(-1.6deg);
    }

    to {
        transform: rotate(1.8deg);
    }
}

/* ===== Stations ===== */
.cave-station {
    position: absolute;
    bottom: var(--sb, 7vh);
    left: calc(var(--sx) * var(--kx, 1) * 1vw);
    /* --sw-m lets a media query out-vote the inline --sw seed */
    width: calc(var(--sw-m, var(--sw)) * var(--kw, 1) * 1vw);
    aspect-ratio: var(--sar);
}

.station-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.station-art svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ===== The cave mouth: arrival copy and the sign ===== */
.station-mouth .mouth-copy {
    position: absolute;
    left: 2%;
    top: 4%;
    width: 62%;
    animation: mouthSettle 1.1s ease-out backwards;
}

@keyframes mouthSettle {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cave-over {
    font-family: var(--cave-mono);
    font-size: 0.66rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(159, 212, 255, 0.55);
    margin: 0 0 1rem;
}

.cave-title {
    font-weight: 200;
    font-size: clamp(2.5rem, 5.4vw, 4.4rem);
    line-height: 1.05;
    color: #eaf6ff;
    letter-spacing: 0.02em;
    margin: 0 0 1.1rem;
    text-shadow:
        0 0 34px rgba(90, 180, 240, 0.45),
        0 4px 18px rgba(0, 10, 25, 0.6);
}

.cave-sub {
    font-family: var(--cave-mono);
    font-size: clamp(0.72rem, 1.1vw, 0.85rem);
    letter-spacing: 0.14em;
    color: rgba(200, 230, 255, 0.75);
    margin: 0 0 1.4rem;
}

.cave-brief {
    font-family: var(--cave-mono);
    font-size: 0.64rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(125, 240, 212, 0.6);
    margin: 0 0 2rem;
}

.swim-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--cave-mono);
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(159, 212, 255, 0.8);
    margin: 0;
    animation: swimNudge 2.6s ease-in-out infinite;
}

.swim-hint svg {
    width: 1.15rem;
    height: 1.15rem;
}

@keyframes swimNudge {

    0%,
    100% {
        transform: translateX(0);
        opacity: 0.75;
    }

    50% {
        transform: translateX(9px);
        opacity: 1;
    }
}

.mouth-sign {
    left: auto;
    right: 5%;
    top: auto;
    bottom: 0;
    width: 24%;
    aspect-ratio: 300 / 480;
    position: absolute;
}

/* ===== Interactive items ===== */
.cave-item {
    position: absolute;
    left: var(--ix);
    top: var(--iy);
    width: var(--iw);
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    z-index: 2;
}

.cave-item:focus-visible {
    outline: 2px solid rgba(159, 212, 255, 0.7);
    outline-offset: 9px;
    border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%;
}

.item-art {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 16px 22px rgba(0, 3, 10, 0.5))
        drop-shadow(0 0 22px var(--glow, rgba(70, 165, 255, 0.16)));
    transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), filter 0.45s ease;
}

.cave-item:hover .item-art,
.cave-item:focus-visible .item-art {
    transform: translateY(-6px);
    filter: drop-shadow(0 22px 28px rgba(0, 3, 10, 0.45))
        drop-shadow(0 0 34px var(--glow, rgba(70, 165, 255, 0.3)));
}

.cave-item.visited .item-art {
    filter: drop-shadow(0 16px 22px rgba(0, 3, 10, 0.5))
        drop-shadow(0 0 26px var(--glow, rgba(70, 165, 255, 0.24)));
}

.cave-item.engaged {
    pointer-events: none;
}

/* ===== Item captions (instrument voice, as on the bio dive) ===== */
.item-caption {
    position: absolute;
    /* --cap (a % of the button's height) drops the caption past whatever
       furniture the work sits on; default hangs just under the artwork */
    top: var(--cap, calc(100% + 0.55rem));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.28rem;
    font-family: var(--cave-mono);
    white-space: nowrap;
    pointer-events: none;
}

.item-no {
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    color: rgba(190, 225, 255, 0.5);
}

.item-name {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(224, 241, 255, 0.92);
    padding-bottom: 2px;
    border-bottom: 1px dotted rgba(159, 212, 255, 0.55);
    transition: border-color 0.3s ease;
}

.cave-item:hover .item-name,
.cave-item:focus-visible .item-name {
    border-bottom-style: solid;
    border-bottom-color: rgba(159, 212, 255, 0.85);
}

.item-state {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: rgba(159, 212, 255, 0.55);
}

/* Once a work has been read, the prompt retires — the lit screen or the
   ajar lid says "visited" in-world */
.cave-item.visited .item-state {
    display: none;
}

/* ===== Encounter 01 · the blueprint unpins ===== */
.bp-pin-tr {
    transition: transform 0.5s cubic-bezier(0.5, -0.3, 0.6, 1), opacity 0.5s ease;
}

.bp-curl {
    opacity: 0;
    transform: scale(0.25);
    transform-origin: 396px 26px;
    transition: opacity 0.4s ease 0.25s, transform 0.55s cubic-bezier(0.34, 1.3, 0.5, 1) 0.25s;
}

.bp-lines {
    transition: filter 0.5s ease;
}

.item-blueprint.engaged .bp-pin-tr,
.item-blueprint.visited .bp-pin-tr {
    transform: translate(14px, -30px) rotate(38deg);
    opacity: 0;
}

.item-blueprint.engaged .bp-curl,
.item-blueprint.visited .bp-curl {
    opacity: 1;
    transform: scale(1);
}

.item-blueprint.engaged .bp-lines {
    filter: drop-shadow(0 0 5px rgba(170, 225, 255, 0.9));
}

/* ===== Encounter 02 · the workstation wakes ===== */
.nb-on {
    opacity: 0;
    transition: opacity 0.3s ease 0.18s;
}

.nb-sweep {
    opacity: 0;
}

.nb-led {
    animation: ledBreathe 3.2s ease-in-out infinite;
}

@keyframes ledBreathe {

    0%,
    100% {
        opacity: 0.35;
    }

    50% {
        opacity: 0.95;
    }
}

.item-screen.engaged .nb-on,
.item-screen.visited .nb-on {
    opacity: 1;
}

.item-screen.engaged .nb-sweep {
    animation: nbSweep 0.55s ease-out 0.1s;
}

@keyframes nbSweep {
    0% {
        opacity: 0.9;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(124px);
    }
}

.nb-bar {
    transform-origin: center 118px;
    transform: scaleY(0);
    transition: transform 0.45s cubic-bezier(0.34, 1.3, 0.5, 1);
}

.item-screen.engaged .nb-bar,
.item-screen.visited .nb-bar {
    transform: scaleY(1);
}

.item-screen.engaged .nb-bar:nth-of-type(2),
.item-screen.visited .nb-bar:nth-of-type(2) {
    transition-delay: 0.12s;
}

.item-screen.engaged .nb-bar:nth-of-type(3),
.item-screen.visited .nb-bar:nth-of-type(3) {
    transition-delay: 0.2s;
}

.item-screen.engaged .nb-bar:nth-of-type(4),
.item-screen.visited .nb-bar:nth-of-type(4) {
    transition-delay: 0.28s;
}

.item-screen.visited .nb-led {
    animation: none;
    opacity: 0.9;
    fill: rgba(125, 240, 212, 0.9);
}

/* ===== Encounter 03 · the CRT warms up ===== */
.fd-on {
    opacity: 0;
    transition: opacity 0.35s ease 0.3s;
}

.fd-flash {
    opacity: 0;
    transform-origin: center 122px;
}

.item-screen.engaged .fd-on,
.item-screen.visited .fd-on {
    opacity: 1;
}

.item-screen.engaged .fd-flash {
    animation: fdFlash 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes fdFlash {
    0% {
        opacity: 1;
        transform: scaleY(0.4) scaleX(0.1);
    }

    45% {
        opacity: 1;
        transform: scaleY(0.6) scaleX(1);
    }

    80% {
        opacity: 0.9;
        transform: scaleY(30) scaleX(1);
    }

    100% {
        opacity: 0;
        transform: scaleY(34) scaleX(1);
    }
}

.fd-oval {
    stroke-dasharray: 290;
    stroke-dashoffset: 290;
}

.item-screen.engaged .fd-oval,
.item-screen.visited .fd-oval {
    animation: ovalDraw 0.9s ease-out 0.35s forwards;
}

.item-screen.visited .fd-oval {
    animation-duration: 0.01s;
    animation-delay: 0s;
}

@keyframes ovalDraw {
    to {
        stroke-dashoffset: 0;
    }
}

.fd-cursor {
    animation: cursorBlink 1.1s steps(2, start) infinite;
}

@keyframes cursorBlink {
    to {
        visibility: hidden;
    }
}

/* ===== Encounter 04 · the volume comes off the shelf ===== */
.bk-body {
    transform-origin: 30% 96%;
    transition: transform 0.55s cubic-bezier(0.34, 1.3, 0.5, 1);
}

.item-book.engaged .bk-body {
    transform: translate(-16px, -6px) rotate(-13deg);
}

.item-book.visited .bk-body {
    transform: translate(-8px, -2px) rotate(-5deg);
}

.bk-dot {
    opacity: 0;
}

.item-book.engaged .bk-dot {
    animation: bkLeak 0.9s ease-out forwards;
}

.item-book.engaged .bk-dot:nth-of-type(2) {
    animation-delay: 0.14s;
}

.item-book.engaged .bk-dot:nth-of-type(3) {
    animation-delay: 0.24s;
}

.item-book.engaged .bk-dot:nth-of-type(4) {
    animation-delay: 0.36s;
}

.item-book.engaged .bk-dot:nth-of-type(5) {
    animation-delay: 0.45s;
}

@keyframes bkLeak {
    0% {
        opacity: 0;
        transform: translate(0, 0);
    }

    25% {
        opacity: 0.95;
    }

    100% {
        opacity: 0;
        transform: translate(-26px, -14px);
    }
}

/* ===== Encounter 05 · the lenses light their route ===== */
.ar-hud {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ar-glint {
    animation: glintIdle 4.6s ease-in-out infinite;
}

.ar-glint--late {
    animation-delay: -2.1s;
}

@keyframes glintIdle {

    0%,
    100% {
        opacity: 0.25;
    }

    50% {
        opacity: 0.9;
    }
}

.item-lenses.engaged .ar-hud {
    opacity: 1;
}

.item-lenses.visited .ar-hud {
    opacity: 0.55;
}

.item-lenses.engaged .ar-path {
    animation: arMarch 1.1s linear infinite;
}

@keyframes arMarch {
    from {
        stroke-dashoffset: 0;
    }

    to {
        stroke-dashoffset: -22;
    }
}

.ar-chev path {
    opacity: 0;
}

.item-lenses.engaged .ar-chev path,
.item-lenses.visited .ar-chev path {
    opacity: 1;
    transition: opacity 0.3s ease 0.25s;
}

.item-lenses.engaged .ar-chev path:nth-of-type(2),
.item-lenses.visited .ar-chev path:nth-of-type(2) {
    transition-delay: 0.45s;
}

.item-lenses.engaged .ar-mark {
    animation: markPulse 1.3s ease-in-out infinite;
    transform-origin: 332px 44px;
}

@keyframes markPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

.item-lenses.engaged .ar-glint {
    animation: glintFlash 0.7s ease-out;
}

@keyframes glintFlash {
    0% {
        opacity: 0.3;
        r: 4;
    }

    35% {
        opacity: 1;
        r: 9;
    }

    100% {
        opacity: 0.6;
        r: 5;
    }
}

/* ===== Encounter 06 · the lid comes off the pot ===== */
.gt-lid {
    transition: transform 0.6s cubic-bezier(0.34, 1.3, 0.5, 1);
}

.item-pot.engaged .gt-lid {
    transform: translate(30px, -38px) rotate(10deg);
}

.item-pot.visited .gt-lid {
    transform: translate(20px, -24px) rotate(7deg);
}

.gt-steam {
    opacity: 0;
    transition: opacity 0.4s ease 0.2s;
}

.item-pot.engaged .gt-steam,
.item-pot.visited .gt-steam {
    opacity: 1;
}

.item-pot.engaged .gt-steam path,
.item-pot.visited .gt-steam path {
    animation: steamRise 2.4s ease-in-out infinite;
}

.item-pot.engaged .gt-steam path:nth-of-type(2),
.item-pot.visited .gt-steam path:nth-of-type(2) {
    animation-delay: -0.9s;
}

.item-pot.engaged .gt-steam path:nth-of-type(3),
.item-pot.visited .gt-steam path:nth-of-type(3) {
    animation-delay: -1.6s;
}

@keyframes steamRise {

    0%,
    100% {
        stroke-dashoffset: 0;
        transform: translateY(0);
    }

    50% {
        stroke-dashoffset: -13;
        transform: translateY(-5px);
    }
}

.item-pot.visited .gt-steam {
    opacity: 0.45;
}

.gt-broth {
    transition: stroke 0.5s ease;
}

.item-pot.engaged .gt-broth {
    stroke: rgba(255, 214, 150, 0.9);
}

/* ===== Ambient micro-life (each one deliberate, none of it confetti) ===== */
.dk-lure {
    animation: lurePulse 3.8s ease-in-out infinite;
}

@keyframes lurePulse {

    0%,
    100% {
        opacity: 0.75;
    }

    50% {
        opacity: 1;
    }
}

.dk-fish {
    animation: fishHover 7s ease-in-out infinite alternate;
}

@keyframes fishHover {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(6px, -7px);
    }
}

.fr-school {
    animation: schoolPatrol 26s ease-in-out infinite alternate;
}

@keyframes schoolPatrol {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(-56px, 10px);
    }
}

.gt-hang {
    transform-origin: 450px 120px;
    animation: rackSway 7.5s ease-in-out infinite alternate;
}

@keyframes rackSway {
    from {
        transform: rotate(-0.7deg);
    }

    to {
        transform: rotate(0.9deg);
    }
}

.dt-glow {
    animation: lurePulse 5.2s ease-in-out infinite;
}

/* Line cookies: little lights strung along the guide line, blinking in
   slow sequence toward the next station */
.rope-cookie {
    fill: rgba(125, 240, 212, 0.9);
    animation: cookiePulse 3.6s ease-in-out infinite;
}

.rope-cookies .rope-cookie:nth-of-type(2n) {
    animation-delay: -1.2s;
}

.rope-cookies .rope-cookie:nth-of-type(3n) {
    animation-delay: -2.4s;
}

.rope-cookies .rope-cookie:nth-of-type(4n+1) {
    animation-delay: -0.6s;
}

@keyframes cookiePulse {

    0%,
    100% {
        opacity: 0.45;
    }

    50% {
        opacity: 1;
    }
}

/* The patrolling anglerfish bridging the dark between alcove and bench */
.roam-fish {
    position: absolute;
    left: calc(297 * var(--kx, 1) * 1vw);
    bottom: 46vh;
    width: calc(10 * var(--kw, 1) * 1vw);
    animation: roamPatrol 36s ease-in-out infinite alternate;
}

.roam-fish svg {
    display: block;
    width: 100%;
    height: auto;
}

.roam-lure {
    animation: lurePulse 3s ease-in-out infinite;
}

@keyframes roamPatrol {
    0% {
        transform: translate(0, 0);
    }

    45% {
        transform: translate(3.4vw, -2.2vh);
    }

    100% {
        transform: translate(6vw, 0.8vh);
    }
}

/* Lantern flame: a slow warm sway, never a strobe */
.gt-flame {
    animation: flameSway 4.4s ease-in-out infinite;
}

@keyframes flameSway {

    0%,
    100% {
        opacity: 0.8;
    }

    40% {
        opacity: 1;
    }

    70% {
        opacity: 0.88;
    }
}

/* The openings breathe — distant water light, not static paint */
.fr-mouth {
    animation: openingBreathe 9s ease-in-out infinite;
}

.fr-porthole {
    animation: openingBreathe 11s ease-in-out infinite;
}

.fr-porthole--late {
    animation-delay: -5s;
}

@keyframes openingBreathe {

    0%,
    100% {
        opacity: 0.82;
    }

    50% {
        opacity: 1;
    }
}

/* ===== The skylight ===== */
.skylight-beam {
    position: absolute;
    left: 6%;
    top: -8vh;
    width: 88%;
    height: 82vh;
    background: linear-gradient(to bottom,
            rgba(150, 225, 225, 0.32),
            rgba(120, 200, 210, 0.12) 55%,
            transparent 92%);
    clip-path: polygon(30% 0, 68% 0, 98% 100%, 2% 100%);
    mix-blend-mode: screen;
    transform-origin: top center;
    animation: beamSway 11s ease-in-out infinite alternate;
    pointer-events: none;
}

.skylight-beam::after {
    content: '';
    position: absolute;
    bottom: -6vh;
    left: -8%;
    width: 116%;
    height: 12vh;
    background: radial-gradient(ellipse at center,
            rgba(150, 225, 225, 0.26), transparent 70%);
}

@keyframes beamSway {
    from {
        transform: skewX(-2.2deg);
    }

    to {
        transform: skewX(2.4deg);
    }
}

/* ===== The field log ===== */
.field-log {
    position: absolute;
    left: 8%;
    top: 13%;
    width: 60%;
}

.field-log svg {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 18px 24px rgba(0, 3, 10, 0.5));
    animation: logHang 8s ease-in-out infinite alternate;
    transform-origin: 50% -18%;
}

@keyframes logHang {
    from {
        transform: rotate(-0.8deg);
    }

    to {
        transform: rotate(0.9deg);
    }
}

.log-tick {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    opacity: 0;
}

.log-tick.on {
    opacity: 1;
    animation: chalkTick 0.6s ease-out forwards;
}

@keyframes chalkTick {
    to {
        stroke-dashoffset: 0;
    }
}

.log-complete {
    opacity: 0;
    transition: opacity 1s ease 0.4s;
}

.field-log.complete .log-complete {
    opacity: 1;
}

.field-log.complete svg {
    filter: drop-shadow(0 18px 24px rgba(0, 3, 10, 0.5))
        drop-shadow(0 0 30px rgba(125, 240, 212, 0.25));
}

/* ===== The ruby =====
   Hidden until every artifact is found, then it kindles in the beam.
   Pressing it floods the cave in a red aura and carries the diver home. */
.cave-ruby {
    position: absolute;
    left: 65%;
    bottom: 8%;
    width: 20%;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    z-index: 3;
}

.cave-ruby svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 10px 18px rgba(30, 0, 8, 0.55))
        drop-shadow(0 0 26px rgba(255, 80, 100, 0.35));
    transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.5, 1), filter 0.4s ease;
    animation: rubyBob 5s ease-in-out infinite alternate;
}

.cave-ruby:hover svg,
.cave-ruby:focus-visible svg {
    transform: translateY(-5px);
    filter: drop-shadow(0 14px 22px rgba(30, 0, 8, 0.5))
        drop-shadow(0 0 40px rgba(255, 90, 110, 0.55));
}

.cave-ruby:focus-visible {
    outline: 2px solid rgba(255, 150, 160, 0.75);
    outline-offset: 9px;
    border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%;
}

.cave-ruby .item-name {
    color: rgba(255, 214, 220, 0.95);
    border-bottom-color: rgba(255, 150, 160, 0.6);
}

.cave-ruby .item-state {
    color: rgba(255, 150, 160, 0.7);
}

@keyframes rubyBob {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-7px);
    }
}

.rb-halo {
    animation: lurePulse 3.2s ease-in-out infinite;
}

.rb-spark {
    animation: cookiePulse 2.6s ease-in-out infinite;
}

.rb-spark--late {
    animation-delay: -1.3s;
}

/* Kindling: the appearance when the sixth artifact lands */
.cave-ruby.ruby-in svg {
    animation: rubyKindle 1.2s cubic-bezier(0.34, 1.5, 0.5, 1) backwards,
        rubyBob 5s ease-in-out 1.2s infinite alternate;
}

@keyframes rubyKindle {
    0% {
        opacity: 0;
        transform: scale(0.15);
    }

    60% {
        opacity: 1;
        transform: scale(1.18);
    }

    100% {
        transform: scale(1);
    }
}

/* Taken: the gem flares as the aura swallows the cave */
.cave-ruby.taken svg {
    animation: rubyFlare 0.6s ease-out forwards;
}

@keyframes rubyFlare {
    to {
        transform: scale(1.5);
        opacity: 0.2;
    }
}

/* The blinding glint, grown from the gem's own sparkle:
   a quick exposure kick, a tapered four-point star flare sweeping up
   past the diver, and a bloom that overexposes the screen to white
   with only a rose tinge left at the rim */
.glint-kick {
    position: fixed;
    inset: 0;
    z-index: 499;
    background: #fff;
    opacity: 0;
    mix-blend-mode: screen;
    pointer-events: none;
    animation: glintKick 0.32s ease-out forwards;
}

@keyframes glintKick {
    0% {
        opacity: 0;
    }

    30% {
        opacity: 0.5;
    }

    100% {
        opacity: 0;
    }
}

.glint-bloom {
    position: fixed;
    width: 320vmax;
    height: 320vmax;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.004);
    background: radial-gradient(circle,
            #ffffff 0%,
            #ffffff 26%,
            rgba(255, 228, 234, 0.99) 48%,
            rgba(255, 176, 190, 0.97) 68%,
            rgba(190, 60, 84, 0.95) 88%,
            rgba(110, 10, 28, 0.92) 100%);
    z-index: 500;
    pointer-events: none;
    animation: glintBloom 0.85s cubic-bezier(0.62, 0, 0.8, 1) 0.12s forwards;
}

@keyframes glintBloom {
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

.glint-star {
    position: fixed;
    width: 46vmax;
    height: 46vmax;
    margin: -23vmax 0 0 -23vmax;
    z-index: 501;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.08) rotate(-30deg);
    animation: glintStar 0.9s cubic-bezier(0.5, 0, 0.75, 1) forwards;
}

.glint-star svg {
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 18px rgba(255, 218, 228, 0.95));
}

@keyframes glintStar {
    0% {
        opacity: 0;
        transform: scale(0.08) rotate(-30deg);
    }

    16% {
        opacity: 1;
        transform: scale(1) rotate(-14deg);
    }

    72% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: scale(16) rotate(9deg);
    }
}

/* The survey remembers where the red light lives */
.survey-tick.ruby {
    background: rgba(255, 110, 122, 0.95);
    box-shadow: 0 0 9px rgba(255, 90, 110, 0.8);
}

.log-status {
    margin: 0.8rem 0 0;
    text-align: center;
    font-family: var(--cave-mono);
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(159, 212, 255, 0.6);
}

.ascend-hint {
    position: absolute;
    right: -12%;
    bottom: 36%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--cave-mono);
    font-size: 0.6rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(159, 212, 255, 0.7);
    width: 9rem;
    text-align: center;
    margin: 0;
}

.ascend-hint svg {
    width: 1.2rem;
    height: 1.2rem;
    animation: swimNudgeUp 2.6s ease-in-out infinite;
}

@keyframes swimNudgeUp {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    50% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ===== Ambient dark and the lamp that answers it =====
   The cave keeps its edges dim and its middle lit — artifacts read at
   full size. The lamp is a gentle brightening that follows the pointer;
   the luminescent life (lures, lantern, glow jar, line cookies) plays
   as accent light, not survival gear. */
.cave-vignette {
    position: fixed;
    inset: 0;
    z-index: 39;
    pointer-events: none;
    background:
        radial-gradient(ellipse 130% 110% at 50% 44%,
            transparent 46%,
            rgba(2, 7, 14, 0.42) 78%,
            rgba(1, 4, 9, 0.72) 100%);
}

.cave-lamp {
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    mix-blend-mode: screen;
    background: radial-gradient(circle 30vmax at var(--lx, 58%) var(--ly, 52%),
            rgba(168, 215, 250, 0.13),
            rgba(130, 190, 235, 0.05) 46%,
            transparent 72%);
}

/* ===== Survey instrument (fixed, mono voice) ===== */
.cave-survey {
    position: fixed;
    top: 1.1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--cave-mono);
}

.survey-word {
    font-size: 0.6rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(190, 225, 255, 0.5);
}

.survey-track {
    position: relative;
    width: clamp(150px, 24vw, 300px);
    height: 16px;
}

.survey-track::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(159, 212, 255, 0.45) 7%,
            rgba(159, 212, 255, 0.45) 93%,
            transparent);
}

.survey-tick {
    position: absolute;
    top: 50%;
    width: 4px;
    height: 10px;
    padding: 0;
    transform: translate(-50%, -50%);
    background: rgba(159, 212, 255, 0.55);
    border: none;
    border-radius: 42% 58% 52% 48% / 60% 42% 58% 42%;
    cursor: pointer;
}

.survey-tick:hover,
.survey-tick:focus-visible {
    background: rgba(207, 234, 255, 0.95);
    height: 13px;
}

.survey-tick:focus-visible {
    outline: 1px solid rgba(159, 212, 255, 0.7);
    outline-offset: 3px;
}

.survey-tick.visited {
    background: rgba(125, 240, 212, 0.85);
}

.survey-tick::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.56rem;
    letter-spacing: 0.16em;
    color: rgba(224, 241, 255, 0.9);
    background: rgba(6, 16, 28, 0.85);
    padding: 3px 8px;
    border-radius: 8px 14px 9px 15px / 13px 9px 14px 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.survey-tick:hover::after,
.survey-tick:focus-visible::after {
    opacity: 1;
}

.survey-dot {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 8px;
    height: 8px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 35% 30%,
            rgba(255, 236, 200, 1), rgba(255, 202, 120, 0.85));
    border-radius: 52% 48% 55% 45% / 48% 55% 45% 52%;
    box-shadow: 0 0 10px rgba(255, 214, 150, 0.75);
    pointer-events: none;
}

.survey-here {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: rgba(224, 241, 255, 0.78);
    min-width: 11ch;
}

/* ===== Return bubbles (site nav, top right) ===== */
.cave-return {
    position: fixed;
    top: 1rem;
    right: 1.1rem;
    z-index: 60;
    display: flex;
    gap: 0.6rem;
}

.return-bubble {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: rgba(200, 230, 255, 0.85);
    font-size: 0.9rem;
    text-decoration: none;
    background:
        radial-gradient(circle at 32% 26%, rgba(150, 205, 245, 0.22), rgba(10, 30, 55, 0.42) 64%);
    border: 1px solid;
    border-color: rgba(190, 228, 255, 0.55) rgba(120, 170, 220, 0.25)
        rgba(80, 130, 180, 0.18) rgba(120, 170, 220, 0.25);
    border-radius: 46% 54% 52% 48% / 52% 46% 54% 48%;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    transition: transform 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.return-bubble:hover,
.return-bubble:focus-visible {
    transform: translateY(-3px);
    color: #fff;
    border-top-color: rgba(220, 242, 255, 0.85);
}

.return-bubble:focus-visible {
    outline: 2px solid rgba(159, 212, 255, 0.7);
    outline-offset: 3px;
}

.return-word {
    position: absolute;
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--cave-mono);
    font-size: 0.55rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(200, 230, 255, 0.85);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.return-bubble:hover .return-word,
.return-bubble:focus-visible .return-word {
    opacity: 1;
}

/* ===== Skip link ===== */
.skip-main {
    position: fixed;
    top: -4rem;
    left: 1rem;
    z-index: 200;
    padding: 0.6rem 1.1rem;
    font-family: var(--cave-mono);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    color: #eaf6ff;
    background: rgba(8, 22, 38, 0.95);
    border: 1px solid rgba(159, 212, 255, 0.5);
    border-radius: 14px 22px 15px 24px / 20px 14px 22px 15px;
    transition: top 0.25s ease;
}

.skip-main:focus {
    top: 1rem;
}

/* ===== Surfacing: the exit section ===== */
.cave-exit {
    position: relative;
    z-index: 1;
    min-height: 74vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 5rem;
    background: linear-gradient(180deg,
            rgba(2, 8, 16, 0) 0%,
            rgba(4, 14, 26, 0.55) 40%,
            rgba(2, 8, 16, 0.85) 100%);
}

.cave-exit .ocean-footer {
    text-align: center;
    padding: 3.5rem 0 1.8rem;
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.85rem;
}

/* ===== Responsive scales ===== */
@media (min-width: 701px) and (max-width: 1100px) {
    .cave-tour {
        --strip-w: 700;
        --far-w: 380;
        --near-w: 1010;
    }

    .cave-mid {
        --kx: 1.245;
        --kw: 1.26;
    }
}

@media (max-width: 700px) {
    .cave-tour {
        --strip-w: 1010;
        --far-w: 520;
        --near-w: 1460;
        --pace: 0.85;
    }

    .cave-mid {
        --kx: 1.8;
        --kw: 1.85;
    }

    .station-mouth .mouth-copy {
        /* viewport units, not station % — the mouth station is wider than
           the phone screen and a %-width would run off the right edge */
        width: 76vw;
        top: 2%;
    }

    .cave-title {
        font-size: clamp(2.2rem, 11vw, 3rem);
    }

    /* the cave hugs its furniture closer on a phone */
    .cave-station {
        bottom: var(--sb, 12vh);
    }

    .cave-ceiling {
        height: 26vh;
    }

    .cave-floor {
        height: 26vh;
    }

    /* the first foreground rock waits just off-screen so it can't sit on
       the arrival copy */
    .cave-near .near-piece:nth-child(1) {
        --nx-m: 108vw;
    }

    /* the skylight station grows so its twine still hangs from the rim */
    .cave-station[data-station="skylight"] {
        --sw-m: 62;
    }

    /* survey tucks into the top-left corner, clear of the nav bubbles */
    .cave-survey {
        left: 0.9rem;
        transform: none;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .survey-word {
        display: none;
    }

    .survey-track {
        width: 40vw;
    }

    .survey-here {
        font-size: 0.55rem;
        min-width: 9ch;
    }

    .cave-return {
        top: 0.8rem;
        right: 0.8rem;
        gap: 0.45rem;
    }

    .return-bubble {
        width: 37px;
        height: 37px;
        font-size: 0.8rem;
    }

    .item-name {
        font-size: 0.7rem;
    }

    .ascend-hint {
        right: 2%;
    }
}

/* Short landscape phones: rein the furniture in so it fits under the ceiling */
@media (max-height: 560px) {
    .cave-mid {
        --kw: 0.82;
        --kx: 0.92;
    }

    .cave-tour {
        --strip-w: 520;
    }

    .station-mouth .mouth-copy {
        top: 0;
    }
}

/* ===== Reduced motion: the cave holds still ===== */
@media (prefers-reduced-motion: reduce) {

    .cave-rope,
    .near-frond,
    .near-frond--late,
    .swim-hint,
    .ascend-hint svg,
    .skylight-beam,
    .field-log svg,
    .dk-lure,
    .dk-fish,
    .fr-school,
    .gt-hang,
    .dt-glow,
    .nb-led,
    .ar-glint,
    .roam-fish,
    .roam-lure,
    .gt-flame,
    .fr-mouth,
    .fr-porthole,
    .mouth-copy {
        animation: none;
    }

    /* the cookies stay lit rather than blinking */
    .rope-cookie {
        animation: none;
        opacity: 0.85;
    }

    .cave-ruby svg,
    .cave-ruby.ruby-in svg,
    .rb-halo,
    .rb-spark {
        animation: none;
    }

    .glint-kick,
    .glint-star {
        animation: none;
        opacity: 0;
    }

    .glint-bloom {
        animation: none;
        transform: translate(-50%, -50%) scale(1);
    }

    .item-art,
    .cave-item:hover .item-art,
    .cave-item:focus-visible .item-art {
        transition: none;
        transform: none;
    }

    .bp-pin-tr,
    .bp-curl,
    .bk-body,
    .gt-lid,
    .nb-on,
    .fd-on,
    .ar-hud {
        transition-duration: 0.01s;
    }

    .item-lenses.engaged .ar-path,
    .item-pot.engaged .gt-steam path,
    .item-pot.visited .gt-steam path,
    .item-lenses.engaged .ar-mark,
    .fd-cursor {
        animation: none;
    }

    .item-screen.engaged .fd-oval,
    .item-screen.visited .fd-oval {
        animation: none;
        stroke-dashoffset: 0;
    }

    .log-tick.on {
        animation: none;
        stroke-dashoffset: 0;
    }
}
