/* Chat & react. Floating items live in .ri-layer (document coordinates,
   created by the component on <body>); the button sits in each page's
   action row. Shared tokens come from design-tokens.css. */

/* ---- Action-row button: one more tool beside Undo / Resign ---- */
#room-interactions-root { display: contents; }
.ri-talk { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 136px; height: 44px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: 600 15px/1 var(--sans); white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ri-talk:hover { background: rgba(35, 41, 37, .07); }
.ri-talk[aria-expanded="true"] { background: rgba(35, 41, 37, .09); }
.ri-talk[data-state="failed"] { color: var(--danger); }
.ri-talk-icon { display: grid; flex: none; place-items: center; width: 18px; height: 18px; }
.ri-fail-dot { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
.ri-talk:focus-visible, .ri-layer :focus-visible { outline: 3px solid var(--focus-ring); outline-offset: var(--focus-offset, 3px); }

/* ---- Floating items ---- */
.ri-layer { position: absolute; top: 0; right: 0; left: 0; z-index: 60; height: 0; overflow-x: clip; color: var(--ink); font: 14px/1.4 var(--sans); }
.ri-items { position: absolute; top: 0; left: 0; pointer-events: none; }
.ri-item { position: absolute; }
.ri-side.to-left { transform: translate(-100%, -100%); }
.ri-side.to-right { transform: translateY(-100%); }
.ri-over { transform: translateX(-50%); }
.ri-inner { display: block; transform-origin: var(--big-origin, center); transition: transform 380ms cubic-bezier(.3, .7, .3, 1); }
/* The big moment; leaving the class transitions back to normal size. */
.ri-item.is-big .ri-inner { transform: var(--big); }
.ri-item.is-big.is-entering:not(.is-coffee):not(.is-text) .ri-inner { animation: ri-pop-big 340ms cubic-bezier(.2, .7, .3, 1.2) backwards; }
@keyframes ri-pop-big { from { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: var(--big-peak); } to { opacity: 1; transform: var(--big); } }
.ri-sticker { display: block; width: 62px; height: 62px; filter: drop-shadow(0 2px 3px #4a361a33); -webkit-user-drag: none; user-select: none; }
.ri-bubble { display: block; width: max-content; padding: 7px 11px; border: 1px solid var(--invite-line); border-radius: 14px; background: var(--invite-surface); box-shadow: 0 1px 2px #312d2112, 0 6px 16px #312d2118; color: var(--ink); font-size: 14px; line-height: 1.35; text-align: left; }
.ri-bubble > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--ri-bubble-lines, 3); overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.ri-pair-text { padding-block: 4px; }
.ri-item.is-failed .ri-inner { filter: grayscale(.7) opacity(.5); }

.ri-item.is-entering:not(.is-coffee):not(.is-text):not(.has-big) .ri-inner { animation: ri-pop 300ms cubic-bezier(.2, .7, .3, 1.2) both; }
.ri-item.is-entering.is-text .ri-inner { animation: ri-rise 200ms ease-out both; }
.ri-item.is-bump .ri-inner { animation: ri-bump 200ms ease-out both; }
.ri-item.is-ending .ri-inner { animation: ri-fade 320ms ease-in forwards; }
.ri-item.is-leaving .ri-inner { animation: ri-fade 220ms ease-in forwards; }
@keyframes ri-pop { from { opacity: 0; transform: scale(.5) rotate(-8deg); } 60% { opacity: 1; transform: scale(1.08) rotate(3deg); } to { opacity: 1; transform: none; } }
@keyframes ri-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ri-bump { from { opacity: .4; transform: scale(.9); } 60% { opacity: 1; transform: scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes ri-fade { to { opacity: 0; } }

/* ---- Pour a coffee: cup travels, pot appears, pours, vanishes ---- */
.ri-pour { position: relative; display: block; width: 62px; height: 62px; --tilt: -6deg; }
.ri-pour.is-mirror { --tilt: 6deg; }
.ri-cup { position: absolute; inset: 0; filter: drop-shadow(0 2px 3px #4a361a33); animation: ri-travel 900ms cubic-bezier(.45, 0, .3, 1) both; }
.ri-cup img, .ri-pot-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; -webkit-user-drag: none; user-select: none; }
.ri-cup-coffee { transform-origin: 44.3% 47.9%; animation: ri-fill 820ms cubic-bezier(.2, .6, .3, 1) 1740ms both; }
.ri-steam { animation: ri-steam-in 500ms ease-out 3000ms backwards, ri-drift 2.6s ease-in-out 3500ms infinite; }
/* The stream runs from the spout tip (pot.svg manifest) to the coffee. */
.ri-stream { position: absolute; top: 5%; left: 41.5%; width: 5.6%; height: 40%; border-radius: 4px; background: #c08a5a; box-shadow: 0 0 0 1px #786146; clip-path: inset(0 0 100% 0); animation: ri-stream 860ms 1680ms both; }
/* Pot box = 87% of the cup; tilted -42deg about its pivot, the spout tip
   lands above the coffee centre. Mirrored when it pours from the left. */
.ri-pot-wrap { position: absolute; top: -52.2%; left: 37.4%; width: 87%; height: 87%; }
.ri-pour.is-mirror .ri-pot-wrap { left: -35.8%; transform: scaleX(-1); }
.ri-pot { transform-origin: 51.8% 60.5%; opacity: 0; filter: drop-shadow(0 2px 3px #4a361a33); animation: ri-pot 2100ms linear 1000ms both; }
@keyframes ri-travel {
  from { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.7); }
  12% { opacity: 1; }
  50% { transform: translate(calc(var(--dx) / 2), calc(var(--dy) / 2 - 24px)) scale(1) rotate(var(--tilt)); }
  90% { transform: translate(0, 1px) scale(1.04, .95); }
  to { opacity: 1; transform: none; }
}
@keyframes ri-pot {
  from { opacity: 0; transform: translateY(-6px) scale(.6); animation-timing-function: ease-out; }
  14% { opacity: 1; transform: none; }
  20% { transform: rotate(0); }
  32% { transform: rotate(-42deg); }
  78% { transform: rotate(-42deg); animation-timing-function: ease-in-out; }
  88% { opacity: 1; transform: rotate(0); animation-timing-function: ease-in; }
  to { opacity: 0; transform: translateY(-4px) scale(.7); }
}
@keyframes ri-stream { from { clip-path: inset(0 0 100% 0); } 15% { clip-path: inset(0); } 86% { clip-path: inset(0); } to { clip-path: inset(100% 0 0 0); } }
@keyframes ri-fill { from { opacity: 0; transform: scale(.12); } 10% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes ri-steam-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ri-drift { 0%, 100% { opacity: 1; transform: none; } 50% { opacity: .75; transform: translateY(-3px); } }

/* ---- Picker ---- */
.ri-scrim { position: fixed; inset: 0; z-index: 61; background: #2b241614; }
.ri-picker { position: fixed; z-index: 62; display: flex; flex-direction: column; gap: 8px; box-sizing: border-box; padding: 12px 16px 16px; border: 1px solid var(--invite-line); background: var(--invite-surface); box-shadow: var(--invite-shadow); color: var(--ink); font: 15px/1.4 var(--sans); }
.ri-picker.is-sheet { right: 0; bottom: 0; left: 0; max-width: 560px; margin: 0 auto; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 0 0; animation: ri-sheet 220ms cubic-bezier(.2, .65, .3, 1) both; }
.ri-picker.is-popover { width: 360px; border-radius: 18px; transform: translateX(-50%); animation: ri-popover 200ms cubic-bezier(.2, .65, .3, 1) both; }
.ri-picker.is-popover[data-side="below"]::after { top: -7px; bottom: auto; border-width: 1px 0 0 1px; }
.ri-picker.is-popover::after { position: absolute; bottom: -7px; left: 50%; width: 12px; height: 12px; content: ''; border: inherit; border-width: 0 1px 1px 0; background: inherit; transform: translateX(-50%) rotate(45deg); }
@keyframes ri-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ri-popover { from { opacity: 0; transform: translate(-50%, 8px) scale(.98); } to { opacity: 1; transform: translateX(-50%); } }
.ri-head { display: flex; align-items: center; gap: 4px; margin: -4px -6px 0 0; }
.ri-head h2 { flex: 1; margin: 0; font: 540 18px/1.2 var(--serif); }
.ri-back { margin-left: -12px; }
.ri-icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--ink); cursor: pointer; }
.ri-icon-button:hover { background: rgba(35, 41, 37, .07); }
.ri-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
/* Page stylesheets may style every <button> (padding, min sizes); the picker's
   own buttons reset what they rely on so nothing pushes the grid wider. */
.ri-layer .ri-picker, .ri-layer .ri-picker * { box-sizing: border-box; }
.ri-layer .ri-tile, .ri-layer .ri-icon-button, .ri-layer .ri-send { min-width: 0; min-height: 0; margin: 0; padding: 0; }
.ri-layer .ri-gift, .ri-layer .ri-person { min-width: 0; margin: 0; }
/* The coffee row: the invitation card's pale tile fill, no outline. Its cup
   centre sits under the first sticker column (4 columns, 4px gaps). */
.ri-gift { display: flex; align-items: center; gap: 12px; width: 100%; height: 56px; padding: 0 14px 0 calc((100% - 12px) / 8 - 22px); border: 0; border-radius: 12px; background: var(--invite-tile); color: var(--ink); font: 500 15px/1.2 var(--sans); text-align: left; cursor: pointer; }
.ri-gift:hover { background: var(--invite-tile-hover); }
.ri-gift-art { display: grid; flex: none; place-items: center; width: 44px; height: 44px; }
.ri-gift-art img { display: block; width: 44px; height: 44px; filter: drop-shadow(0 1px 2px #4a361a26); transition: transform .12s; -webkit-user-drag: none; }
.ri-gift:active .ri-gift-art img { transform: scale(.92); }
.ri-gift > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-tile { display: grid; place-items: center; height: 72px; border: 0; border-radius: 12px; background: none; cursor: pointer; }
.ri-tile:hover { background: var(--invite-tile); }
.ri-tile img { display: block; width: 64px; max-width: 100%; height: auto; aspect-ratio: 1; filter: drop-shadow(0 2px 3px #4a361a26); transition: transform .12s; -webkit-user-drag: none; }
.ri-tile:active img { transform: scale(.92); }
.ri-compose { display: flex; align-items: center; gap: 6px; height: 52px; box-sizing: border-box; padding: 0 5px 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: #fff; }
.ri-compose:focus-within { border-color: var(--invite-action); box-shadow: 0 0 0 3px #2e5a4722; }
/* The field's green focus border is its focus indicator; no extra (red) ring on the input itself. */
.ri-layer .ri-compose input:focus-visible { outline: none; }
.ri-compose input { flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: none; color: var(--ink); font: 16px var(--sans); }
.ri-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ri-send { display: grid; place-items: center; width: 44px; height: 42px; border: 0; border-radius: 8px; background: var(--invite-action); color: #fff; cursor: pointer; }
.ri-send:disabled { background: #c7d3cb; cursor: default; }
.ri-people { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ri-person { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 96px; padding: 12px 6px; border: 0; border-radius: 12px; background: var(--invite-tile); color: var(--ink); font: 600 15px/1.2 var(--sans); cursor: pointer; }
.ri-person > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-person:hover { background: var(--invite-tile-hover); }
.ri-person-dot { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-size: 17px; font-weight: 600; }
.ri-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .ri-inner, .ri-cup, .ri-cup-coffee, .ri-steam, .ri-picker { animation: none !important; transition: none !important; }
  .ri-item.is-ending .ri-inner, .ri-item.is-leaving .ri-inner { animation: ri-fade 160ms linear forwards !important; }
  .ri-stream, .ri-pot-wrap { display: none; }
}

/* ---- Game over: one-tap reactions inside the page's result card ---- */
#room-interactions-quick:empty { display: none; }
.ri-quick { display: flex; align-items: center; gap: 2px; margin: 0 -6px 0 -8px; padding-top: 10px; border-top: 1px solid var(--line); }
.ri-quick-sticker { display: grid; flex: none; place-items: center; width: 50px; height: 50px; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 12px; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ri-quick-sticker:hover { background: var(--invite-tile); }
.ri-quick-sticker img { display: block; width: 42px; height: 42px; filter: drop-shadow(0 1px 2px #4a361a26); transition: transform .12s; -webkit-user-drag: none; }
.ri-quick-sticker:active img { transform: scale(.92); }
.ri-quick .ri-quick-more { min-width: 0; margin-left: auto; padding: 0 8px; font-size: 14px; }
.ri-quick-sticker:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
@media (max-width: 360px) {
  .ri-quick-sticker { width: 46px; } .ri-quick-sticker img { width: 38px; height: 38px; }
  /* Narrow phones: the more button keeps its icon and 44px target; the label stays for screen readers. */
  .ri-quick .ri-quick-more { width: 44px; padding: 0; }
  .ri-quick .ri-quick-more > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
