/* =============================================================
   The Two-Headed Boy - the shelf and everything on it (October 7, 2026)
   Scoped to html.wk .tb-*; the room itself is wunderkammer.css.
   Sections: 0 tokens, 1 the niche and the stage, 2 the picture,
   3 hot spots over the picture, 4 head-up: status and tools,
   5 buttons and paper, 6 the card, 7 the slip, 8 captions,
   9 phases and modes, 10 full screen, 11 no script, 12 the page copy,
   13 responsive, 14 reduced motion
   ============================================================= */

/* ---- 0. tokens ------------------------------------------------------ */
html.wk .tb-niche {
    --tb-paper: #efe4cc;
    --tb-ink: #1d1611;
    --tb-soft: #5a4632;
    --tb-red: #a62b2b;
    --tb-brass: #d4b06a;
    --tb-brass-dim: #8a6a33;
    --tb-bone: #e8dcc2;
    --tb-night: #070504;
    --tb-shadow: 0 10px 28px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ---- 1. the niche and the stage ------------------------------------ */
html.wk .tb-niche { max-width: 1120px; padding: 14px; }
html.wk .tb-niche .wk-label { z-index: 6; top: -44px; right: auto; left: 22px; max-width: 38em; transform: rotate(-0.8deg); }
html.wk .tb-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: calc(100svh - 110px);
    min-height: 460px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    isolation: isolate;
    background: var(--tb-night);
    border: 1px solid #000;
    box-shadow: inset 0 0 0 1px rgba(212, 176, 106, 0.18);
    color: var(--tb-bone);
    font-family: var(--wk-text);
    -webkit-tap-highlight-color: transparent;
    outline: none;
    clip-path: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
html.wk .tb-stage *, html.wk .tb-stage *::before, html.wk .tb-stage *::after { box-sizing: border-box; }

/* ---- 2. the picture --------------------------------------------------- */
html.wk .tb-poster, html.wk .tb-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
html.wk .tb-poster { object-fit: cover; filter: brightness(0.3) saturate(0.7); transition: opacity 1.4s ease; z-index: 0; }
html.wk .tb-canvas {
    z-index: 1;
    opacity: 0;
    transition: opacity 1.4s ease, transform 0.9s cubic-bezier(.3, .1, .2, 1);
    transform-origin: var(--jx, 50%) var(--jy, 50%);
    touch-action: none;
}
html.wk .tb-stage.is-ready .tb-canvas { opacity: 1; }
html.wk .tb-stage.is-ready .tb-poster { opacity: 0; }
/* listening: you lean in */
html.wk .tb-stage.is-listening .tb-canvas { transform: scale(1.04); }

/* ---- 3. hot spots over the picture ------------------------------------ */
html.wk .tb-hot {
    position: absolute;
    z-index: 3;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    cursor: pointer;
    outline: none;
    transition: box-shadow 0.25s;
    touch-action: none;
}
html.wk .tb-hot[hidden] { display: none; }
html.wk .tb-hot:hover, html.wk .tb-hot:focus-visible { box-shadow: 0 0 0 1px rgba(212, 176, 106, 0.5), 0 0 22px rgba(255, 190, 110, 0.16); }
html.wk .tb-hot:focus-visible { box-shadow: 0 0 0 2px var(--tb-brass); }
html.wk .tb-hot-jar { border-radius: 40% 40% 12% 12% / 12% 12% 6% 6%; cursor: crosshair; }
html.wk .tb-hot-jar:hover { box-shadow: none; }
html.wk .tb-hot-jar:focus-visible { box-shadow: 0 0 0 2px var(--tb-brass); }
html.wk .tb-hot-hold[aria-pressed="true"] { box-shadow: 0 0 0 1px rgba(212, 176, 106, 0.7), 0 0 26px rgba(255, 180, 90, 0.35); }
/* the label and the snake jar sit on or beside the big jar: keep them above it */
html.wk .tb-hot[data-hot="label"], html.wk .tb-hot[data-hot="trumpet"] { z-index: 4; }

/* ---- 4. head-up: status and tools ----------------------------------- */
html.wk .tb-hud {
    position: absolute;
    z-index: 6;
    left: 0; right: 0; top: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 0;
    pointer-events: none;
}
html.wk .tb-status {
    margin: 0;
    padding: 4px 2px;
    max-width: 52%;
    font-family: var(--wk-fell-sc);
    font-size: 0.98rem;
    letter-spacing: 0.06em;
    line-height: 1.25;
    color: #d9bd84;
    text-shadow: 0 1px 2px #000, 0 0 10px #000;
}
html.wk .tb-status small { display: block; font-family: var(--wk-text); font-style: italic; letter-spacing: 0.01em; font-size: 0.88rem; color: #bfa77a; }
html.wk .tb-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; pointer-events: auto; }
html.wk .tb-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    min-width: 38px;
    padding: 6px 10px;
    border: 1px solid rgba(212, 176, 106, 0.55);
    border-radius: 2px;
    background: rgba(13, 9, 7, 0.72);
    color: #e6cf98;
    font-family: var(--wk-fell-sc);
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    touch-action: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
html.wk .tb-tool svg { width: 20px; height: 20px; flex: 0 0 auto; }
html.wk .tb-tool:hover { background: rgba(42, 26, 16, 0.92); color: #f3dc9c; border-color: var(--tb-brass); }
html.wk .tb-tool:focus-visible { outline: 2px solid var(--tb-brass); outline-offset: 2px; }
html.wk .tb-tool[aria-pressed="true"]#tb-listen { background: rgba(58, 36, 22, 0.95); color: #fff1c8; border-color: var(--tb-brass); }
html.wk #tb-sound .tb-mute { display: none; }
html.wk #tb-sound[aria-pressed="false"] .tb-mute { display: inline; }
html.wk #tb-sound[aria-pressed="false"] .tb-wave { display: none; }
html.wk .tb-stage:not([data-phase="lit"]) #tb-listen,
html.wk .tb-stage:not([data-phase="lit"]) #tb-shake,
html.wk .tb-stage:not([data-phase="lit"]) #tb-saw-btn { opacity: 0.45; pointer-events: none; }
html.wk .tb-stage.is-saw #tb-saw-btn { background: rgba(58, 36, 22, 0.95); color: #fff1c8; border-color: var(--tb-brass); }

/* ---- 5. buttons and paper -------------------------------------------- */
html.wk .tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    min-height: 44px;
    padding: 0.5em 1.15em 0.45em;
    border: 1px solid var(--tb-brass-dim);
    border-radius: 2px;
    background: linear-gradient(#2e1d12, #1c120b);
    box-shadow: inset 0 0 0 1px rgba(212, 176, 106, 0.25), 0 3px 8px rgba(0, 0, 0, 0.5);
    color: #f1dca6;
    font-family: var(--wk-fell-sc);
    font-size: 1.08rem;
    letter-spacing: 0.05em;
    line-height: 1.1;
    cursor: pointer;
    transition: transform 0.12s, background 0.2s, color 0.2s;
}
html.wk .tb-btn:hover { background: linear-gradient(#3a2416, #22160d); color: #fff1c8; }
html.wk .tb-btn:active { transform: translateY(1px); }
html.wk .tb-btn:focus-visible { outline: 2px solid var(--tb-brass); outline-offset: 3px; }
html.wk .tb-btn[disabled] { opacity: 0.55; cursor: wait; }
html.wk .tb-note, html.wk .tb-slip-body {
    color: var(--tb-ink);
    background: url('/wunderkammer/img/paper.webp'), var(--tb-paper);
}

/* ---- 6. the card propped against the jar ------------------------------- */
html.wk .tb-note {
    position: absolute;
    z-index: 9;
    left: 50%;
    top: 50%;
    width: min(29rem, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow: auto;
    transform: translate(-50%, -50%) rotate(-0.8deg);
    padding: 1.45rem 1.75rem 1.05rem;
    text-align: center;
    box-shadow: var(--tb-shadow);
    clip-path: var(--wk-torn);
}
html.wk .tb-note[hidden] { display: none; }
html.wk .tb-note h2 { margin: 0 0 0.7rem; font-family: var(--wk-fell-sc); font-size: 1.02rem; font-weight: 400; letter-spacing: 0.08em; color: var(--tb-red); }
html.wk .tb-note-hand { margin: 0 0 0.85rem; font-family: var(--wk-fell); font-style: italic; font-size: 1.3rem; line-height: 1.38; text-align: left; color: var(--tb-ink); }
html.wk .tb-note-how { margin: 0 0 1.05rem; font-size: 1.02rem; line-height: 1.45; text-align: left; color: var(--tb-soft); }
html.wk .tb-note-small { margin: 0.7rem 0 0.2rem; font-size: 0.92rem; font-style: italic; color: var(--tb-soft); }
html.wk .tb-loading { margin: 0.8rem auto 0; max-width: 18rem; font-size: 0.9rem; font-style: italic; color: var(--tb-soft); }
html.wk .tb-loading i { display: block; height: 2px; margin-top: 0.35rem; background: rgba(29, 22, 17, 0.15); overflow: hidden; }
html.wk .tb-loading b { display: block; height: 100%; background: var(--tb-red); transform-origin: left center; transform: scaleX(0.02); transition: transform 0.25s linear; }
html.wk .tb-stage.is-ready .tb-loading { display: none; }

/* ---- 7. the slip ----------------------------------------------------- */
html.wk .tb-slip {
    position: absolute;
    z-index: 7;
    right: 16px;
    top: 62px;
    width: min(22rem, 38%);
    max-height: calc(100% - 140px);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}
html.wk .tb-slip[hidden] { display: none; }
html.wk .tb-slip-body {
    position: relative;
    overflow-y: auto;
    min-height: 0;
    padding: 1rem 1.15rem 0.7rem;
    box-shadow: var(--tb-shadow);
    clip-path: var(--wk-torn);
    scrollbar-width: thin;
    scrollbar-color: #8d7247 #e2cf9f;
}
html.wk .tb-slip.is-in .tb-slip-body { animation: tb-slide 0.55s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes tb-slide { from { opacity: 0; transform: translateY(-14px) rotate(-1.2deg); } to { opacity: 1; transform: none; } }
html.wk .tb-slip-kicker { margin: 0; font-family: var(--wk-fell-sc); font-size: 0.86rem; letter-spacing: 0.06em; color: var(--tb-soft); }
html.wk .tb-slip h2 { margin: 0.1rem 0 0.45rem; font-family: var(--wk-fell); font-weight: 400; font-size: 1.42rem; line-height: 1.15; color: var(--tb-red); }
html.wk .tb-slip p.tb-slip-text { margin: 0 0 0.55rem; font-size: 1rem; line-height: 1.45; color: var(--tb-ink); }
html.wk .tb-slip p.tb-slip-small { margin: 0.2rem 0 0.5rem; font-size: 0.9rem; font-style: italic; line-height: 1.4; color: var(--tb-soft); }
html.wk .tb-slip p.tb-slip-small:empty { display: none; }
html.wk .tb-slip blockquote { margin: 0.2rem 0 0.6rem; padding: 0 0 0 0.75rem; border-left: 2px solid rgba(166, 43, 43, 0.55); font-family: var(--wk-fell); font-style: italic; font-size: 1.08rem; line-height: 1.38; }
html.wk .tb-slip a { color: var(--tb-red); text-decoration: underline; text-underline-offset: 3px; }
html.wk .tb-slip a:hover { color: var(--tb-ink); }
html.wk .tb-slip-actions { display: flex; flex-wrap: wrap; gap: 0.4rem 0.55rem; margin: 0.4rem 0 0.5rem; }
html.wk .tb-slip-actions button, html.wk .tb-slip-x {
    min-height: 34px;
    padding: 0.32rem 0.65rem;
    border: 0;
    border-bottom: 1px solid rgba(212, 176, 106, 0.5);
    background: rgba(13, 9, 7, 0.84);
    color: #e6cf98;
    font-family: var(--wk-fell-sc);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    cursor: pointer;
}
html.wk .tb-slip-actions button:hover { color: #fff1c8; border-bottom-color: var(--tb-brass); }
html.wk .tb-slip-actions button[disabled] { opacity: 0.6; cursor: wait; }
html.wk .tb-slip-actions button:focus-visible, html.wk .tb-slip-x:focus-visible { outline: 2px solid var(--tb-red); outline-offset: 2px; }
html.wk .tb-slip-actions .tb-quiet { background: none; color: var(--tb-soft); border-bottom-color: rgba(90, 70, 50, 0.35); font-family: var(--wk-text); font-style: italic; letter-spacing: 0; font-size: 0.95rem; }
html.wk .tb-slip-x {
    display: block;
    margin: 0.3rem 0 0.1rem auto;
    background: none;
    color: var(--tb-soft);
    border-bottom: 1px solid rgba(90, 70, 50, 0.35);
    font-family: var(--wk-text);
    font-style: italic;
    letter-spacing: 0;
    font-size: 0.95rem;
}
html.wk .tb-slip-x:hover { color: var(--tb-red); }

/* ---- 8. captions -------------------------------------------------------- */
html.wk .tb-caption {
    position: absolute;
    z-index: 6;
    left: 18px;
    bottom: 18px;
    max-width: min(30rem, calc(55% - 30px));
    margin: 0;
    padding: 0.55rem 0.8rem 0.5rem;
    background: rgba(13, 9, 7, 0.8);
    border-left: 2px solid rgba(212, 176, 106, 0.6);
    color: var(--tb-bone);
    font-family: var(--wk-text);
    font-size: 1.02rem;
    line-height: 1.38;
    pointer-events: none;
}
html.wk .tb-caption[hidden] { display: none; }
html.wk .tb-caption.is-in { animation: tb-fade 0.45s ease-out both; }
html.wk .tb-caption b { display: block; margin-bottom: 0.1rem; font-family: var(--wk-fell-sc); font-weight: 400; font-size: 0.9rem; letter-spacing: 0.05em; color: #d9bd84; }
html.wk .tb-caption span { font-style: italic; }
@keyframes tb-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
html.wk .tb-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- 9. phases and modes ---------------------------------------------- */
html.wk .tb-stage[data-phase="loading"] .tb-status { opacity: 0.75; }
html.wk .tb-stage.is-saw .tb-hot { pointer-events: none; }
html.wk .tb-stage.is-saw .tb-canvas { cursor: ns-resize; }
html.wk .tb-stage[data-phase="failed"] .tb-note { display: none; }
html.wk .tb-stage[data-phase="failed"] .tb-nojs { display: block; }

/* ---- 10. full screen ---------------------------------------------------- */
html.wk .tb-stage:fullscreen, html.wk .tb-stage.tb-fs-fallback {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    aspect-ratio: auto;
    border: 0;
}
html.wk .tb-stage:-webkit-full-screen { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; border: 0; }
html.wk .tb-stage.tb-fs-fallback { position: fixed; inset: 0; z-index: 10005; }
html.wk .tb-stage::backdrop { background: #000; }

/* ---- 11. no script ------------------------------------------------------ */
html.wk .tb-nojs { display: none; }
html.wk .tb-stage[data-phase="failed"] .tb-nojs {
    position: absolute;
    z-index: 8;
    left: 50%;
    bottom: 22px;
    width: min(32rem, calc(100% - 32px));
    transform: translateX(-50%);
    padding: 0.8rem 1.1rem;
    background: rgba(13, 9, 7, 0.86);
    border: 1px solid rgba(212, 176, 106, 0.5);
    color: var(--tb-bone);
    font-size: 1rem;
    line-height: 1.45;
}
html.wk .tb-nojs p { margin: 0; }

/* the picture without its layers yet: the still at full strength and a note */
html.wk .tb-pending { display: none; }
html.wk .tb-stage[data-phase="pending"] .tb-poster { filter: none; }
html.wk .tb-stage[data-phase="pending"] .tb-note,
html.wk .tb-stage[data-phase="pending"] .tb-hud,
html.wk .tb-stage[data-phase="pending"] .tb-canvas { display: none; }
html.wk .tb-stage[data-phase="pending"] .tb-pending {
    display: block;
    position: absolute;
    z-index: 8;
    left: 18px;
    bottom: 18px;
    width: min(26rem, calc(100% - 36px));
    padding: 0.75rem 1rem 0.7rem;
    color: var(--tb-ink);
    background: url('/wunderkammer/img/paper.webp'), var(--tb-paper);
    box-shadow: var(--tb-shadow);
    clip-path: var(--wk-torn);
    font-size: 1rem;
    line-height: 1.45;
    transform: rotate(-0.6deg);
}
html.wk .tb-pending p { margin: 0; }

/* ---- 12. the page copy -------------------------------------------------- */
html.wk .tb-lead { font-size: 1.12em; }
html.wk .tb-copy h3 { margin-top: 1.4em; }
html.wk .tb-sources li { margin-bottom: 0.55em; }
html.wk .tb-listen-song { margin: 1rem auto 0.4rem; }
html.wk .tb-listen-song iframe {
    display: block;
    width: 100%;
    max-width: 700px;
    height: 120px;
    border: 0;
    background: #efe4cc;
    box-shadow: 0 0 0 1px rgba(29, 22, 17, 0.25), 0 3px 10px rgba(29, 22, 17, 0.18);
}
html.wk .tb-listen-note { margin: 0.5rem 0 0; max-width: 700px; font-size: 0.92em; font-style: italic; color: #5a4632; }

/* ---- 13. responsive -------------------------------------------------------- */
@media (max-width: 900px) {
    html.wk .tb-slip { width: min(21rem, 46%); }
}
@media (max-width: 768px) {
    html.wk .tb-niche { padding: 6px; }
    /* a tall photograph would only show the jar: 4:5 keeps the candle, the jar and the window in */
    html.wk .tb-stage {
        aspect-ratio: auto;
        height: min(calc(100svh - 76px), 128vw);
        max-height: 900px;
        min-height: 420px;
    }
    html.wk .tb-hud { padding: 8px 8px 0; }
    html.wk .tb-status { font-size: 0.86rem; max-width: 46%; }
    html.wk .tb-status small { font-size: 0.8rem; }
    html.wk .tb-tool span { display: none; }
    html.wk .tb-tool { padding: 6px 8px; }
    html.wk .tb-tools { gap: 6px; max-width: 54%; }
    html.wk .tb-note { padding: 1.15rem 1.15rem 0.95rem; }
    html.wk .tb-note-hand { font-size: 1.14rem; }
    html.wk .tb-note-how { font-size: 0.95rem; }
    /* the slip becomes a sheet at the bottom, so the jar stays in sight */
    html.wk .tb-slip { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 52%; }
    html.wk .tb-slip-body { padding: 0.8rem 0.9rem 0.55rem; }
    html.wk .tb-slip h2 { font-size: 1.22rem; }
    html.wk .tb-slip p.tb-slip-text { font-size: 0.95rem; }
    html.wk .tb-caption { left: 8px; right: 8px; bottom: auto; top: 58px; max-width: none; font-size: 0.94rem; }
}
@media (max-width: 768px) and (orientation: landscape) {
    html.wk .tb-stage { height: calc(100svh - 64px); min-height: 320px; }
    html.wk .tb-slip { left: auto; right: 8px; top: 50px; bottom: auto; width: min(20rem, 48%); max-height: calc(100% - 58px); }
    html.wk .tb-caption { top: auto; bottom: 8px; left: 8px; right: auto; max-width: 48%; }
}

/* ---- 14. reduced motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html.wk .tb-slip.is-in .tb-slip-body, html.wk .tb-caption.is-in { animation: none; }
    html.wk .tb-poster, html.wk .tb-canvas { transition: none; }
    html.wk .tb-stage.is-listening .tb-canvas { transform: none; }
}
