/* ========================================
   游神 YÓUSHÉN — 顶塔骨
   The deity fills the room. Title, two sentences and the names sit at the
   bottom left (like the home hero); the performer and the one action sit at
   the bottom right. Plain serif text, no boxes, vermilion only for the
   action and hover.
   ======================================== */

.motion-page {
    --edge: clamp(24px, 4vw, 64px);
    --foot: clamp(32px, 7vh, 72px);
    --nav-height: 72px;
    position: relative;
    height: 100svh;
    min-height: 520px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: var(--nav-height) var(--edge) var(--foot);
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--serif-cn);
}

/* ---- stage ---- */
.motion-stage {
    position: absolute;
    inset: var(--nav-height) 0 0;
}

.motion-stage > canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.motion-page .motion-model-status {
    position: absolute;
    inset: 50% 0 auto;
    margin: 0;
    transform: translateY(-50%);
    background: none;
    text-align: center;
    color: var(--text-faint);
    font-size: 14px;
    letter-spacing: 0.22em;
    pointer-events: none;
}

/* Visitor's own camera: the full frame, uncropped, so you can see yourself
   without stepping far back. Aspect ratio is set from the stream in JS.
   It appears where the performer stood. */
.motion-page .motion-camera {
    position: absolute;
    right: var(--edge);
    bottom: var(--foot);
    width: clamp(220px, 26vw, 420px);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease;
    /* Only the outer edge is feathered, so the whole body stays visible. */
    -webkit-mask-image:
        linear-gradient(to right, transparent, #000 6%, #000 94%, transparent),
        linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
    -webkit-mask-composite: source-in;
    mask-image:
        linear-gradient(to right, transparent, #000 6%, #000 94%, transparent),
        linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
    mask-composite: intersect;
}

.motion-page.is-live .motion-camera {
    opacity: 1;
    visibility: visible;
}

.motion-camera video,
.motion-camera canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scaleX(-1);
}

.motion-camera video {
    filter: brightness(0.92);
}

/* ---- title, text, names ---- */
.motion-intro {
    position: relative;
    z-index: 1;
    width: clamp(196px, 23vw, 320px);
}

.motion-title {
    margin: 0;
    font: 400 clamp(38px, 4.6vw, 68px)/1.15 var(--serif-cn);
    letter-spacing: 0.06em;
}

.motion-text {
    margin: clamp(12px, 2.2vh, 22px) 0 clamp(18px, 4vh, 40px);
    color: var(--text-muted);
    font-size: clamp(12px, 1vw, 14px);
    line-height: 2;
    letter-spacing: 0.04em;
    transition: opacity 0.6s ease;
}

.deity-choices {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 0 clamp(20px, 2.6vw, 44px);
}

.deity-choices button {
    border: 0;
    background: none;
    padding: clamp(3px, 0.7vh, 7px) 0;
    color: var(--text-faint);
    font: 400 clamp(15px, 1.3vw, 19px)/1.6 var(--serif-cn);
    letter-spacing: 0.14em;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s ease;
}

.deity-choices button[aria-pressed="true"] {
    color: var(--text);
}

.deity-choices button:hover {
    color: var(--vermilion);
}

/* ---- English: Latin text needs less tracking and a little more room ---- */
:lang(en) .motion-intro {
    width: clamp(232px, 26vw, 340px);
}

:lang(en) .motion-title {
    font-size: clamp(30px, 3.4vw, 50px);
    letter-spacing: 0.01em;
}

:lang(en) .motion-text {
    line-height: 1.75;
    letter-spacing: 0.01em;
}

:lang(en) .deity-choices {
    gap: 0 clamp(16px, 1.8vw, 28px);
}

:lang(en) .deity-choices button {
    font-size: clamp(13px, 1.05vw, 16px);
    letter-spacing: 0.02em;
}

:lang(en) .motion-enter {
    text-indent: 0.12em;
    letter-spacing: 0.12em;
}

/* ---- performer and action ---- */
.motion-action {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    transition: opacity 0.6s ease;
}

.motion-demo {
    display: block;
    width: clamp(104px, 11vw, 168px);
    aspect-ratio: 4 / 5;
}

.motion-enter {
    border: 0;
    background: none;
    padding: 10px 12px 0;
    /* Trailing letter-spacing would push the word off the figure's axis. */
    text-indent: 0.36em;
    color: var(--vermilion);
    font: 400 clamp(20px, 1.8vw, 26px)/1.5 var(--serif-cn);
    letter-spacing: 0.36em;
    cursor: pointer;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.motion-enter:hover {
    color: var(--text);
}

.motion-page.is-starting .motion-enter {
    opacity: 0.4;
    cursor: progress;
}

.motion-page.is-live .motion-action,
.motion-page.is-live .motion-text {
    opacity: 0;
    visibility: hidden;
}

/* Speaks only when the visitor needs to do something. */
.motion-status {
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    bottom: 12px;
    margin: 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0.12em;
    pointer-events: none;
}

.deity-choices button:focus-visible,
.motion-enter:focus-visible {
    outline: 2px solid var(--vermilion);
    outline-offset: 6px;
}

/* ---- narrow: the deity on top, names and the action stacked below ---- */
@media (max-width: 700px) {
    .motion-page {
        --nav-height: 64px;
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto auto;
        justify-items: center;
        align-items: stretch;
        padding-bottom: 40px;
    }

    .motion-stage {
        position: relative;
        inset: auto;
        justify-self: stretch;
        margin: 0 calc(-1 * var(--edge));
    }

    .motion-page .motion-camera {
        right: var(--edge);
        bottom: 0;
        width: 46vw;
    }

    .motion-intro {
        width: auto;
        padding-top: 12px;
    }

    .motion-title,
    .motion-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .deity-choices {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0 16px;
    }

    .deity-choices button {
        padding: 4px 0;
        font-size: 16px;
    }

    :lang(en) .motion-intro {
        width: auto;
    }

    :lang(en) .deity-choices button {
        font-size: 14px;
    }

    .motion-action {
        position: static;
    }

    .motion-demo {
        position: absolute;
        top: calc(var(--nav-height) + 8px);
        left: var(--edge);
        width: 22vw;
    }
}

@media (prefers-reduced-motion: reduce) {
    .motion-page * {
        transition: none !important;
    }
}
