/* =====================================================================================================================
 * TURN SIGNAL (js/screens/your-turn-ready.js): whose move it is, on phones, desktops and the TV.
 *
 * Rules this block keeps:
 *  - Nothing here sits over a control. The frame is four bars at the viewport edges with pointer-events none; every
 *    other cue is the screen's own header, map or topic list restyled in place.
 *  - No cue rests on colour alone: "Your turn" is a filled label with a play mark, a frame and moving dots on the
 *    tiles; "Waiting" is a hollow dashed label with an hourglass, no frame and a dim board.
 *  - Photosensitivity (WCAG 2.3.1): nothing flashes. The frame settles once, then its opacity drifts on a 2.4 s cycle.
 *  - prefers-reduced-motion: every cue is static.
 * --turn is the acting player's colour, --turn-ink the text colour that reads on it (set by turnScreenProps).
 * ===================================================================================================================== */

/* Screen readers: one polite line per turn. */
.turn-announcer { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- Your turn: a frame in your colour. The holder has no size, so it covers nothing; the bars hug the edges. ---- */
.turn-frame { position: fixed; top: 0; left: 0; width: 0; height: 0; z-index: 9000; pointer-events: none; --turn-edge: 8px; }
.turn-edge {
    position: fixed; display: block; pointer-events: none;
    background: color-mix(in srgb, var(--turn, #d8ff36) 84%, #fff);
    animation: turn-edge-breathe 2.4s ease-in-out .7s infinite alternate;
}
.turn-edge.is-top { top: 0; left: 0; right: 0; height: var(--turn-edge); transform-origin: 50% 0; animation-name: turn-edge-in-y, turn-edge-breathe; }
.turn-edge.is-bottom { bottom: 0; left: 0; right: 0; height: var(--turn-edge); transform-origin: 50% 100%; animation-name: turn-edge-in-y, turn-edge-breathe; }
.turn-edge.is-left { top: 0; bottom: 0; left: 0; width: var(--turn-edge); transform-origin: 0 50%; animation-name: turn-edge-in-x, turn-edge-breathe; }
.turn-edge.is-right { top: 0; bottom: 0; right: 0; width: var(--turn-edge); transform-origin: 100% 50%; animation-name: turn-edge-in-x, turn-edge-breathe; }
.turn-edge.is-top, .turn-edge.is-bottom, .turn-edge.is-left, .turn-edge.is-right {
    animation-duration: .7s, 2.4s; animation-timing-function: cubic-bezier(.2, .9, .3, 1), ease-in-out;
    animation-delay: 0s, .7s; animation-iteration-count: 1, infinite; animation-direction: normal, alternate; animation-fill-mode: both, none;
}
.turn-frame.is-paused .turn-edge { animation-play-state: paused; }
/* Your pick is in and the server has not moved on yet: the frame goes, the label reads "Locked in". */
body:has(.land-screen.turn-sent) .turn-frame { display: none; }
@media (hover: none) and (pointer: coarse) and (max-width: 932px) { .turn-frame { --turn-edge: 6px; } }
/* The frame arrives thick and settles: it never grows past 24 px, so it stays clear of the map and the topics. */
@keyframes turn-edge-in-y { from { transform: scaleY(3); } to { transform: none; } }
@keyframes turn-edge-in-x { from { transform: scaleX(3); } to { transform: none; } }
@keyframes turn-edge-breathe { from { opacity: 1; } to { opacity: .72; } }

/* ---- The label beside the countdown ---- */
.turn-tag {
    display: inline-flex; align-items: center; gap: 6px; justify-self: center; box-sizing: border-box;
    margin: 0; padding: 5px 18px 5px 13px; border-radius: 999px; border: 2px solid transparent;
    font: 800 19px/1.15 var(--ad-font-display, inherit); letter-spacing: .09em; text-transform: uppercase; white-space: nowrap;
}
.turn-tag svg { flex: none; }
.turn-tag.is-mine { background: var(--turn, #d8ff36); color: var(--turn-ink, #150b24); border-color: #ffffff59; animation: turn-tag-in .42s cubic-bezier(.2, 1.4, .4, 1) both; }
.turn-tag.is-theirs { background: transparent; color: #b9a9d1; border: 2px dashed #6f5c8c; }
.turn-tag.is-sent { background: #2a1d40; color: #d8ff36; border-color: #d8ff3666; }
@keyframes turn-tag-in { from { transform: scale(.6); } to { transform: none; } }
/* The heading is the signal too: it shows from the first frame instead of fading in with the side panel. */
.main-stage .land-screen.screen-enter:is(.turn-mine, .turn-theirs, .turn-sent) > .land-header { animation: none; }
.main-stage .land-screen.turn-theirs > .land-header .stage-title { color: #cdbfe2; }
/* The label rides beside the countdown ring, in the timer's own row: it adds no line, so the map never moves. */
/* after-dark.css pins the timer row to a column with !important; this longer selector turns it back into a row. */
.stage-timer.has-caption.has-turn, .main-stage .land-screen > .stage-timer.has-caption.has-turn { flex-direction: row !important; justify-content: center !important; align-items: flex-start !important; gap: 12px; }
/* The ring stays where it is on every screen; the label is nudged to the ring's middle (ring 43 to 47 px, label 36 px). */
.stage-timer.has-turn .stage-timer-caption { display: flex; align-items: center; margin-top: 5px; font-size: inherit; line-height: 1; }
@media (hover: none) and (pointer: coarse) and (max-width: 932px) {
    .turn-tag { padding: 4px 14px 4px 10px; font-size: 16px; }
    .stage-timer.has-turn .stage-timer-caption { margin-top: 7px; }
    .stage-timer.has-caption.has-turn, .main-stage .land-screen > .stage-timer.has-caption.has-turn { gap: 10px; }
}

/* ---- Your turn: what you can tap is alive ---- */
.land-screen.turn-mine .candy-board .tile.eligible:not(.selected-tile) { animation: turn-ants 1.1s linear infinite; }
@keyframes turn-ants { to { stroke-dashoffset: -20; } }
.topic-screen.turn-mine button.topic-option:not(:disabled) { border-color: var(--ad-lime, #d8ff36); animation: turn-option-glow 1.6s ease-in-out infinite alternate; }
@keyframes turn-option-glow { from { box-shadow: 0 0 0 0 #d8ff3600; } to { box-shadow: 0 0 0 5px #d8ff3640; } }

/* ---- Not your turn: the board is dim, looks off and takes no taps ---- */
.land-screen.turn-theirs .land-map-slot { filter: saturate(.55) brightness(.7); cursor: not-allowed; }
.land-screen.turn-theirs .candy-board .tile, .land-screen.turn-theirs .candy-board .tile.eligible-view { cursor: not-allowed !important; }
.land-screen.turn-theirs .candy-board .tile.eligible-view { stroke: #1a0d2b !important; stroke-dasharray: none !important; }
.topic-screen.turn-theirs .topic-options { cursor: not-allowed; }
.topic-screen.turn-theirs .topic-option { opacity: .6; background: transparent; border: 2px dashed #5b4a78; cursor: not-allowed; }
/* Slow devices drop filters (.perf-lite): fade the board instead. */
.perf-lite .land-screen.turn-theirs .land-map-slot { opacity: .6; }

/* ---- A rival's first-claim celebration that lands on your turn (first-claim-fx.js, .is-compact) ----
   On a phone its 260 px card sat over the heading and could reach the top tiles, and its close button took taps.
   On your turn it is a thumbnail in the free corner left of the countdown, with no button: it ends itself in 3.2 s. */
/* On every device the compact celebration's holder has no size: only the card itself occupies the screen. */
body .first-claim-fx.is-compact { inset: 0 auto auto 0; width: 0; height: 0; }
body .first-claim-fx.is-compact .first-claim-card { position: fixed; }
@media (hover: none) and (pointer: coarse) and (max-width: 932px) {
    body .first-claim-fx.is-compact .first-claim-card { right: auto; left: 12px; top: 12px; width: 76px; border-radius: 14px; }
    body .first-claim-fx.is-compact .first-claim-copy, body .first-claim-fx.is-compact .first-claim-dismiss { display: none; }
}

/* ---- TV: the room sees whose move it is, with their piece, a bar in their colour and a mark on the leaderboard ---- */
.tv-turn-piece { display: inline-block; vertical-align: -.16em; margin-right: .22em; line-height: 0; }
.tv-turn-piece .avatar { width: 1.05em !important; height: 1.05em !important; }
.shared-stage .shared-map-panel.tv-turn h1::after { content: ""; display: block; width: min(42%, 9em); height: .13em; margin: .18em auto 0; border-radius: 99px; background: var(--turn, #d8ff36); }
.shared-score.is-turn { box-shadow: inset 0 0 0 3px var(--player, #d8ff36); }
.shared-score.is-turn .shared-player-name::before { content: "\25B6\00A0"; color: var(--player, #d8ff36); font-size: .8em; }

@media (prefers-reduced-motion: reduce) {
    .turn-edge.is-top, .turn-edge.is-bottom, .turn-edge.is-left, .turn-edge.is-right, .turn-tag.is-mine,
    .land-screen.turn-mine .candy-board .tile.eligible:not(.selected-tile),
    .topic-screen.turn-mine button.topic-option:not(:disabled) { animation: none !important; }
    .topic-screen.turn-mine button.topic-option:not(:disabled) { box-shadow: 0 0 0 3px #d8ff3640; }
}
