/* Ruin It. Every rule here is scoped under .g-ruin so it cannot leak into another game.
   Colours and the headline font come from the theme variables in style.css, so the pirate, western
   and space themes restyle these screens without any rules of their own. */

/* ---------- TV ---------- */
/* One shape for every screen with the picture on it: the picture on the left, as large as the screen
   allows, and a column of text on the right. Sizes are in vh so nothing can reach the player strip. */
.tv .g-ruin.ru-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3vw; align-items: center; width: 100%; max-width: 172vh; text-align: left; }
.tv .g-ruin .ru-frame { width: min(46vw, 70vh); }
/* "wide": the player strip is hidden (nobody has anything to tick off), so the picture can be taller. */
.tv .g-ruin.wide .ru-frame { width: min(50vw, 82vh); }
.tv .g-ruin .ru-side { min-width: 0; display: flex; flex-direction: column; gap: 1.6vh; }
.tv .g-ruin .ru-side h1 { font-size: 7vh; line-height: 1; color: var(--lime); text-shadow: 0.05em 0.05em 0 var(--pink); text-transform: uppercase; overflow-wrap: anywhere; }
.tv .g-ruin .ru-side h2 { font-size: 4.4vh; line-height: 1.1; color: var(--yellow); }
.tv .g-ruin .ru-side .how { font-size: 3.6vh; line-height: 1.25; }
.tv .g-ruin .ru-side .how b { color: var(--yellow); }
.tv .g-ruin .ru-stat { font-size: 3.2vh; font-weight: 700; color: var(--yellow); min-height: 1.3em; }

/* The changes so far. Two lines each at most, so five of them always fit beside the picture. */
.tv .g-ruin .ru-strip { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8vh; }
.tv .g-ruin .ru-strip li { background: var(--panel-2); border: 0.3vh solid var(--line); border-radius: 1.4vh; padding: 0.8vh 1.1vw; font-size: 2.4vh; font-weight: 600; line-height: 1.2; }
.tv .g-ruin .ru-strip li span, .tv .g-ruin .ru-opts li span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.tv .g-ruin .ru-strip b, .tv .g-ruin .ru-opts b { color: var(--yellow); }
.tv .g-ruin .ru-strip i, .tv .g-ruin .ru-opts i { font-style: normal; color: var(--muted); }
.tv .g-ruin .ru-strip li.hot { border-color: var(--lime); background: color-mix(in srgb, var(--lime) 18%, var(--panel-2)); }

/* What is being voted on. The list has a fixed height and its rows share it, so twelve fit as well as
   two. --n (the number of rows, set in ruin.tv.js) gives --pitch, about the height of one row, and
   the type follows it: two lines a row up to six rows, then one line a row ("many"), sized so that
   a full 60 characters still fits across the column on a 16:9 screen. */
.tv .g-ruin .ru-opts { list-style: none; margin: 0; padding: 0; height: 50vh; display: flex; flex-direction: column; justify-content: center; gap: 0.8vh; --pitch: calc(50vh / var(--n, 4)); }
.tv .g-ruin .ru-opts li { flex: 1 1 0; min-height: 0; max-height: 9.5vh; display: flex; align-items: center; overflow: hidden; background: var(--panel); border: 0.4vh solid var(--line); border-radius: 1.6vh; padding: 0 1.2vw; font-weight: 700; line-height: 1.15; font-size: clamp(1.8vh, calc(var(--pitch) * 0.34), 3.4vh); }
.tv .g-ruin .ru-opts.many li { font-size: clamp(1.8vh, min(calc(var(--pitch) * 0.5), 1.45vw), 3.4vh); }
.tv .g-ruin .ru-opts.many li span { -webkit-line-clamp: 1; }
.tv .g-ruin.s-award .ru-opts { height: 46vh; --pitch: calc(46vh / var(--n, 4)); }

/* The winning change, and who typed it. */
.tv .g-ruin .ru-win { font-size: 5.6vh; font-weight: 800; line-height: 1.1; color: var(--ink); overflow-wrap: anywhere; }
.tv .g-ruin .ru-by { font-size: 3.4vh; font-weight: 700; color: var(--lime); }
.tv .g-ruin .ru-cash { font-family: var(--display, 'Bungee'), 'Arial Black', sans-serif; font-weight: 400; color: var(--yellow); margin-left: 0.4em; }
.tv .g-ruin .ru-wait { font-size: 3vh; color: var(--muted); margin-top: 1.4vh; }
.tv .g-ruin .ru-dots { display: inline-flex; gap: 0.3em; margin-left: 0.5em; vertical-align: middle; }
.tv .g-ruin .ru-dots i { width: 0.35em; height: 0.35em; border-radius: 50%; background: var(--muted); animation: ruin-hop 1.1s ease-in-out infinite; }
.tv .g-ruin .ru-dots i:nth-child(2) { animation-delay: 0.15s; }
.tv .g-ruin .ru-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ruin-hop { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-70%); opacity: 1; } }

/* The cover (style.css draws it: the striped panel with the "?"). It starts out of sight above the
   picture, comes down once the winning change has been read, and comes off again on the reveal. */
.tv .g-ruin .cover { display: grid; transform: translateY(-103%); }
.tv .g-ruin .cover.ru-drop { animation: ruin-drop 0.4s cubic-bezier(0.6, 0, 0.3, 1) 2.6s forwards; }
.tv .g-ruin .cover.ru-down { transform: none; }
.tv .g-ruin .cover.ru-lift { transform: none; animation: ruin-lift 0.5s cubic-bezier(0.6, 0, 0.3, 1) var(--lift, 0.8s) forwards; }
.tv .g-ruin.s-reveal .shot img { animation: ruin-flash 0.7s ease-out var(--lift, 0.8s) backwards; }
@keyframes ruin-drop { to { transform: none; } }
@keyframes ruin-lift { to { transform: translateY(-103%); } }
@keyframes ruin-flash { from { transform: scale(1.25); filter: brightness(2.4) saturate(0.2); } to { transform: none; filter: none; } }

/* These screens follow one another on the same picture, so the whole screen must not rise in again
   each time (the picture would blink). Only the text column moves. */
.tv #stage > .g-ruin.s-suggest, .tv #stage > .g-ruin.s-vote, .tv #stage > .g-ruin.s-apply, .tv #stage > .g-ruin.s-reveal, .tv #stage > .g-ruin.s-award, .tv #stage > .g-ruin.s-awardresult { animation: none; }
.tv .g-ruin .ru-side > * { animation: riseIn 0.4s ease backwards; }
.tv .g-ruin .ru-side > :nth-child(2) { animation-delay: 0.08s; }
.tv .g-ruin .ru-side > :nth-child(3) { animation-delay: 0.16s; }
.tv .g-ruin .ru-side > :nth-child(4) { animation-delay: 0.24s; }
.tv .g-ruin .ru-side > .ru-win { animation: ruin-land 0.45s cubic-bezier(0.3, 1.7, 0.5, 1) both; }
@keyframes ruin-land { from { opacity: 0; transform: scale(1.5) rotate(-4deg); } to { opacity: 1; transform: none; } }
.tv .g-ruin .ru-opts li { animation: rowIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.1) backwards; animation-delay: calc(var(--i, 0) * 0.05s); }
.tv .g-ruin .ru-strip li.hot { animation: ruin-land 0.45s cubic-bezier(0.3, 1.7, 0.5, 1) var(--lift, 0.8s) both; }
.tv .g-ruin.s-replay .ru-strip li.hot { animation: none; }

/* The replay. Every version of the picture is stacked in one frame and shown in turn (ruin.tv.js adds
   "on"); then "side" swaps the screen for the first and last versions next to each other. */
.tv .g-ruin.s-replay .ru-frame { width: min(48vw, 74vh); }
.tv .g-ruin .ru-stack { aspect-ratio: 1; }
.tv .g-ruin .ru-stack img { position: absolute; inset: 0; height: 100%; opacity: 0; }
.tv .g-ruin .ru-stack img.on { opacity: 1; }
.tv .g-ruin .ru-stack img.on:not(:first-child) { animation: ruin-flash 0.45s ease-out; }
.tv .g-ruin .product figcaption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 3vh; }
/* The caption under the flipping picture is always two lines tall, so the frame does not jump between versions. */
.tv .g-ruin.s-replay .ru-left figcaption { height: 8.9vh; }
.tv .g-ruin .ru-pair { display: none; }
.tv .g-ruin.side { grid-template-columns: 1fr; justify-items: center; }
.tv .g-ruin.side .ru-left, .tv .g-ruin.side .ru-side { display: none; }
.tv .g-ruin.side .ru-pair { display: flex; gap: 4vw; align-items: center; justify-content: center; }
.tv .g-ruin.side .ru-pair .ru-frame { width: min(42vw, 72vh); animation: popIn 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
.tv .g-ruin.side .ru-pair .ru-frame:last-child { animation-delay: 0.15s; }

/* Someone who has asked for less motion gets no animations at all (style.css), so the cover can
   neither come down nor come off. Leave it off: the picture simply changes. */
@media (prefers-reduced-motion: reduce) {
  .tv .g-ruin .cover { display: none; }
}

/* ---------- phone ---------- */
/* Typing: with the keyboard up there is no room for the picture (it is on the TV), so it goes and the
   field and its buttons are what is left. */
.phone.typing .g-ruin .fit { display: none; }

/* The vote. The list takes whatever height is left and its rows share it, so nothing scrolls however
   many changes there are. --pitch is roughly the height one row gets (the visible screen, less the
   bars and the heading, over the number of rows from ruin.phone.js); the type follows it, so eleven
   two-line rows still fit a small phone. */
.phone .g-ruin .ru-list { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: flex-start; gap: 5px; --pitch: calc((var(--vvh, 100vh) - 165px) / var(--n, 4)); }
.phone .g-ruin .ru-opt { flex: 1 1 0; min-height: 0; max-height: 78px; display: flex; align-items: center; overflow: hidden; padding: 0 12px; color: var(--ink); background: var(--panel-2); border: 2px solid var(--line); border-radius: 12px; font-weight: 600; line-height: 1.15; font-size: clamp(11px, calc(var(--pitch) * 0.33), 17px); cursor: pointer; touch-action: manipulation; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; animation: riseIn 0.35s ease backwards; }
.phone .g-ruin .ru-opt span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.phone .g-ruin .ru-opt:active { border-color: var(--lime); background: color-mix(in srgb, var(--lime) 20%, var(--panel-2)); transform: scale(0.98); }
