/**
 * "On the frame together." (home page bento, #capabilities): review on the
 * board as a 10 s loop, played by js/home.js while it is on screen
 * ([data-loop-scene] gets .is-playing).
 *
 *   0–18 %   two teammates' cursors move over the still
 *   18–25 %  Anna clicks the headlight: a pin and her note
 *   38–40 %  Jonas replies; the frame warms to match the reference
 *   46–56 %  Resolve is pressed: the note closes, the pin is ticked
 *   56–90 %  the board saves as v5
 *   92–100 % it clears and loops
 *
 * The still is te20-04 (16:9, side view) in .rv-shot, a 16:9 box as tall as
 * the frame and pinned left, so the pin and region use the photo's own
 * coordinates (the headlight at 11–20 % across, 47–57 % down) whatever the
 * card's size. The thread floats top right, clear of them. People are round (avatars,
 * the pin); sizes are in cqi of .bento-visual--review. Reduced motion shows
 * the resolved board.
 */

.bento-visual--review {
    flex: 1 1 auto;
    display: flex;
    height: auto;
    min-height: 21rem;
    margin-top: 1.5rem;
    container-type: inline-size;
}

.rv-scene {
    --rv-t: 10s;
    --rv-ok: #43c283;
    --rv-edge: rgba(255, 255, 255, 0.1);
    --rv-text: #dde0e2;
    --rv-muted: #989ea1;
    --rv-anna: #a78bfa;
    --rv-jonas: #60a5fa;

    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #1b1c1d;
    color: var(--rv-text);
    font: 3.4cqi/1.35 'Inter', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.rv-scene b,
.rv-scene em,
.rv-scene i { font-style: normal; font-weight: inherit; }

/* ── Top bar: the board, who is on it, its version ─────────────────────── */

.rv-bar {
    display: flex;
    align-items: center;
    gap: 2.4cqi;
    padding: 3cqi 4cqi;
    border-bottom: 1px solid var(--rv-edge);
}

.rv-title {
    display: flex;
    flex-direction: column;
    margin-right: auto;
    font-size: 3.6cqi;
    font-weight: 600;
    color: #fff;
}

.rv-title b {
    font: 500 2.6cqi/1.3 'JetBrains Mono', ui-monospace, monospace;
    color: var(--rv-muted);
}

.rv-people { display: flex; }

.rv-people > i,
.rv-msg > i,
.rv-pin > i {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 50%;
    font-weight: 700;
    color: #0b1215;
}

.rv-people > i {
    width: 6cqi;
    margin-left: -1.4cqi;
    border: 2px solid #1b1c1d;
    font-size: 2.6cqi;
}

.rv-people > i:nth-child(1) { background: var(--rv-anna); }
.rv-people > i:nth-child(2) { background: var(--rv-jonas); }
.rv-people > i:nth-child(3) { background: #9ca3af; }

/* The version, mono on a hairline; v4 becomes v5 when the note resolves */
.rv-ver {
    display: grid;
    font: 600 2.6cqi/1 'JetBrains Mono', ui-monospace, monospace;
}

.rv-ver > span {
    grid-area: 1 / 1;
    padding: 0.8cqi 1.4cqi;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    color: var(--rv-muted);
}

.rv-ver > span:first-child { animation: rvVerA var(--rv-t) linear infinite; }
.rv-ver > span:last-child { opacity: 0; color: var(--rv-ok); border-color: rgba(67, 194, 131, 0.55); animation: rvVerB var(--rv-t) linear infinite; }

/* ── The still ─────────────────────────────────────────────────────────── */

.rv-frame {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.rv-shot {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    aspect-ratio: 16 / 9;
}

.rv-shot > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    animation: rvWarm var(--rv-t) ease infinite;
}

/* The region the note is about */
.rv-region {
    position: absolute;
    left: 9%;
    top: 44%;
    width: 13%;
    height: 15%;
    border: 1.5px dashed rgba(255, 255, 255, 0.85);
    border-radius: 3px;
    opacity: 0;
    animation: rvRegion var(--rv-t) ease infinite;
}

/* The pin: the author's avatar, ticked once resolved */
.rv-pin {
    position: absolute;
    z-index: 2;
    left: 15.5%;
    top: 44%;
    width: 7cqi;
    margin: -7cqi 0 0 -3.5cqi;
    opacity: 0;
    animation: rvPin var(--rv-t) ease infinite;
}

.rv-pin > i {
    width: 100%;
    border: 2px solid #fff;
    background: var(--rv-anna);
    font-size: 3cqi;
    box-shadow: 0 1cqi 2.4cqi rgba(0, 0, 0, 0.5);
}

.rv-pin::after {
    content: '';
    position: absolute;
    right: -1.2cqi;
    bottom: -0.6cqi;
    width: 3.6cqi;
    height: 3.6cqi;
    border-radius: 50%;
    background: var(--rv-ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.6-5' fill='none' stroke='%2306150d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 70% no-repeat;
    opacity: 0;
    animation: rvTick var(--rv-t) ease infinite;
}

/* The thread, floating beside the pin */
.rv-thread {
    position: absolute;
    z-index: 3;
    right: 4cqi;
    top: 4cqi;
    width: 56cqi;
    display: flex;
    flex-direction: column;
    gap: 2cqi;
    padding: 2.6cqi;
    border: 1px solid var(--rv-edge);
    border-radius: 4px;
    background: #232526;
    box-shadow: 0 2cqi 6cqi rgba(0, 0, 0, 0.55);
    opacity: 0;
    animation: rvThread var(--rv-t) ease infinite;
}

.rv-msg {
    display: grid;
    grid-template-columns: 5cqi minmax(0, 1fr);
    gap: 1.6cqi;
    align-items: start;
    font-size: 2.9cqi;
}

.rv-msg > i { width: 5cqi; font-size: 2.4cqi; background: var(--rv-anna); }
.rv-msg--reply > i { background: var(--rv-jonas); }

.rv-msg > span { display: flex; flex-direction: column; gap: 0.3cqi; }

.rv-msg b { font-weight: 600; color: #fff; }

.rv-msg em {
    margin-left: 0.6cqi;
    font: 500 2.3cqi/1 'JetBrains Mono', ui-monospace, monospace;
    color: var(--rv-muted);
}

.rv-msg--reply {
    padding-top: 2cqi;
    border-top: 1px solid var(--rv-edge);
    opacity: 0;
    animation: rvReply var(--rv-t) ease infinite;
}

.rv-resolve {
    align-self: flex-end;
    padding: 1cqi 2.6cqi;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 3px;
    font-size: 2.8cqi;
    font-weight: 600;
    animation: rvResolve var(--rv-t) linear infinite;
}

/* Live cursors, each with its owner's name */
.rv-cursor {
    position: absolute;
    z-index: 4;
    width: 3.6cqi;
    height: 4.4cqi;
    background: no-repeat center / contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.rv-cursor > em {
    position: absolute;
    left: 3cqi;
    top: 3.6cqi;
    padding: 0.4cqi 1.2cqi;
    border-radius: 3px;
    font-size: 2.4cqi;
    font-weight: 600;
    color: #0b1215;
    white-space: nowrap;
}

.rv-cursor--a {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22'%3E%3Cpath d='M2 1.5v16.2l4.3-4.1 2.9 6.6 2.8-1.2-2.9-6.5H15z' fill='%23a78bfa' stroke='%23111' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
    animation: rvCursorA var(--rv-t) cubic-bezier(0.45, 0, 0.2, 1) infinite;
}

.rv-cursor--a > em { background: var(--rv-anna); }

.rv-cursor--j {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22'%3E%3Cpath d='M2 1.5v16.2l4.3-4.1 2.9 6.6 2.8-1.2-2.9-6.5H15z' fill='%2360a5fa' stroke='%23111' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
    animation: rvCursorJ var(--rv-t) cubic-bezier(0.45, 0, 0.2, 1) infinite;
}

.rv-cursor--j > em { background: var(--rv-jonas); }

.rv-toast {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: 4cqi;
    padding: 1.4cqi 3cqi;
    border: 1px solid rgba(67, 194, 131, 0.5);
    border-radius: 3px;
    background: rgba(16, 24, 20, 0.94);
    font-size: 2.8cqi;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-50%);
    animation: rvToast var(--rv-t) ease infinite;
}

/* ── Timeline ──────────────────────────────────────────────────────────── */

@keyframes rvCursorA {
    0% { left: 62%; top: 86%; opacity: 0; }
    4% { opacity: 1; }
    16%, 22% { left: 28%; top: 43%; }
    34% { left: 40%; top: 72%; }
    46%, 53% { left: 83%; top: 36%; }
    68% { left: 40%; top: 84%; opacity: 1; }
    90% { left: 56%; top: 88%; opacity: 1; }
    96%, 100% { left: 62%; top: 86%; opacity: 0; }
}

@keyframes rvCursorJ {
    0% { left: 18%; top: 82%; opacity: 0; }
    4% { opacity: 1; }
    24% { left: 30%; top: 76%; }
    36%, 41% { left: 70%; top: 44%; }
    60% { left: 14%; top: 78%; opacity: 1; }
    90% { left: 22%; top: 84%; opacity: 1; }
    96%, 100% { left: 18%; top: 82%; opacity: 0; }
}

@keyframes rvRegion {
    0%, 18% { opacity: 0; }
    21%, 54% { opacity: 1; }
    57%, 100% { opacity: 0; }
}

@keyframes rvPin {
    0%, 18% { opacity: 0; translate: 0 3px; }
    21%, 92% { opacity: 1; translate: 0 0; }
    97%, 100% { opacity: 0; translate: 0 0; }
}

@keyframes rvTick {
    0%, 55% { opacity: 0; }
    58%, 92% { opacity: 1; }
    97%, 100% { opacity: 0; }
}

@keyframes rvThread {
    0%, 22% { opacity: 0; translate: 0 3px; }
    25%, 54% { opacity: 1; translate: 0 0; }
    57%, 100% { opacity: 0; translate: 0 0; }
}

@keyframes rvReply {
    0%, 37% { opacity: 0; }
    40%, 100% { opacity: 1; }
}

@keyframes rvResolve {
    0%, 42% { opacity: 0.45; transform: none; }
    45% { opacity: 1; }
    52% { transform: none; }
    53% { transform: scale(0.96); }
    54%, 100% { opacity: 1; transform: none; }
}

/* The frame warms to match the reference once Jonas has answered. */
@keyframes rvWarm {
    0%, 42% { filter: saturate(0.82) hue-rotate(-12deg) brightness(0.97); }
    50%, 93% { filter: none; }
    100% { filter: saturate(0.82) hue-rotate(-12deg) brightness(0.97); }
}

@keyframes rvVerA {
    0%, 56% { opacity: 1; }
    58%, 95% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes rvVerB {
    0%, 56% { opacity: 0; }
    58%, 93% { opacity: 1; }
    97%, 100% { opacity: 0; }
}

@keyframes rvToast {
    0%, 57% { opacity: 0; translate: 0 3px; }
    61%, 88% { opacity: 1; translate: 0 0; }
    92%, 100% { opacity: 0; translate: 0 0; }
}

/* Plays only while on screen (js/home.js adds .is-playing). */
.rv-scene:not(.is-playing) *,
.rv-scene:not(.is-playing) *::before,
.rv-scene:not(.is-playing) *::after { animation-play-state: paused; }

/* ── Reduced motion: the resolved board ────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .rv-scene *,
    .rv-scene *::before,
    .rv-scene *::after { animation: none !important; }
    .rv-pin, .rv-pin::after, .rv-ver > span:last-child { opacity: 1; }
    .rv-ver > span:first-child, .rv-cursor { opacity: 0; }
}
