/* ==========================================================================
   Video games, phase 2: the camera for spectators and quick reactions
   (ui/video-audience.js, ui/video-reactions.js, ui/watch-video.js).

   Everything for the players lives inside the call's dock, which is hidden
   until a call exists; the spectator cameras live in #watch-video-dock, which
   is hidden until a player shows a camera. Without them no rule in this file
   applies and both screens look exactly as before.
   ========================================================================== */

[hidden].video-call__panel,
.video-call__btn--more[hidden],
.video-call__reaction[hidden],
.video-call__audience[hidden],
.watch-video[hidden],
.watch-video__note[hidden] { display: none !important; }

/* ── the button that opens the panel ──────────────────────────────────────── */
.video-call__btn--more { position: relative; }
.video-call__btn--more[aria-expanded="true"] {
    border-color: var(--tp-color-primary, #d2a75e);
    color: var(--tp-color-primary, #d2a75e);
}
/* A small mark while the camera is being shown to spectators. */
.video-call__btn--more[data-audience="true"]::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--tp-color-surface-raised, #232120);
    background: #ff5146;
}

/* ── the viewer count on the live indicator ───────────────────────────────── */
.video-call__audience {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 2px;
    padding-left: 5px;
    border-left: 1px solid rgba(255, 255, 255, .3);
    font-style: normal;
}
.video-call__audience svg { width: 12px; height: 12px; flex: 0 0 12px; }
.video-call__audience b { font-weight: 800; font-variant-numeric: tabular-nums; }
@container (max-width: 169.98px) {
    /* Nothing else is live, but spectators are watching: the count still shows. */
    .video-call__live[data-live="false"][data-audience="true"] { display: inline-flex; }
}

/* ── the panel: reactions, the spectator switch, hide reactions ───────────── */
.video-call__panel {
    position: absolute;
    z-index: 8;
    left: 0;
    right: 0;
    bottom: calc(100% + 6px);
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid var(--tp-color-border-strong, rgba(236, 231, 223, .28));
    border-radius: var(--tp-radius-md, 16px);
    background: var(--tp-color-surface-raised, #232120);
    color: var(--tp-color-text, #ece7df);
    box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5);
    max-height: min(70vh, 420px);
    overflow-y: auto;
}
.video-call__panel-block { display: grid; gap: 4px; padding: 6px 0; }
.video-call__panel-block + .video-call__panel-block { border-top: 1px solid var(--tp-color-border, rgba(236, 231, 223, .16)); }
.video-call__panel-title {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--tp-color-text-muted, #ada69b);
}
.video-call__reactions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.video-call__reaction-btn {
    display: inline-grid;
    place-items: center;
    width: 100%;
    min-width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--tp-color-border-strong, rgba(236, 231, 223, .28));
    border-radius: 12px;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.video-call__reaction-btn:disabled { opacity: .4; cursor: default; }
.video-call__reaction-btn:focus-visible,
.video-call__switch:focus-visible {
    outline: 2px solid var(--tp-color-primary, #d2a75e);
    outline-offset: 2px;
}
@media (hover: hover) {
    .video-call__reaction-btn:not(:disabled):hover { background: color-mix(in srgb, var(--tp-color-primary, #d2a75e) 16%, transparent); }
}

.video-call__switch {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0 2px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
}
.video-call__switch:disabled { opacity: .5; cursor: default; }
.video-call__switch-box {
    position: relative;
    flex: 0 0 38px;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tp-color-text, #ece7df) 28%, transparent);
}
.video-call__switch-box::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.video-call__switch[aria-checked="true"] .video-call__switch-box { background: var(--tp-color-primary, #d2a75e); }
.video-call__switch[aria-checked="true"] .video-call__switch-box::after { transform: translateX(16px); }
@media (prefers-reduced-motion: no-preference) {
    .video-call__switch-box,
    .video-call__switch-box::after { transition: transform 140ms ease-out, background-color 140ms ease-out; }
}
.video-call__hint {
    margin: 0 0 0 48px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--tp-color-text-muted, #ada69b);
}
.video-call__hint:empty { display: none; }

/* ── a reaction floating over a tile ──────────────────────────────────────── */
.video-call__reaction {
    position: absolute;
    z-index: 4;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 12px);
    padding: 4px 10px 4px 8px;
    box-sizing: border-box;
    border-radius: 999px;
    background: rgba(12, 10, 8, .78);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
}
.video-call__reaction-emoji { font-size: 20px; line-height: 1; }
.video-call__reaction-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: no-preference) {
    .video-call__reaction.is-in { animation: video-call-reaction-in 240ms cubic-bezier(.23, 1, .32, 1); }
    @keyframes video-call-reaction-in {
        from { opacity: 0; transform: translate(-50%, 10px) scale(.9); }
        to { opacity: 1; transform: translate(-50%, 0) scale(1); }
    }
}
/* The opponent's tile is the big one: its sentence can be a little larger. */
.video-call__tile--peer .video-call__reaction-emoji { font-size: 24px; }

/* ── the spectator screen ─────────────────────────────────────────────────── */
.watch-video {
    --vc-ink: #14110e;
    --vc-radius: 14px;
    margin: 10px auto 0;
    max-width: 440px;
    color: var(--tp-color-text, #ece7df);
}
.watch-video__tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.watch-video__tile { aspect-ratio: 4 / 3; }
.watch-video__note {
    margin: 10px 2px 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--tp-color-text-muted, #5f594f);
}

/* ── where the panel opens ────────────────────────────────────────────────── */
/* Phone and tablet portrait: above the dock, over the board for a moment. Wide screens and landscape: the dock
   is a column on the right, so the panel opens to the left of it, over the margin the board leaves free. */
@media (min-width: 1100px), (min-width: 600.02px) and (max-width: 1099.98px) and (orientation: landscape) {
    #screen-game.video-call-on .video-call__panel {
        left: auto;
        right: calc(100% + 8px);
        bottom: 0;
        width: 290px;
    }
    #screen-game.video-call-on .video-call__reactions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
