/* ===========================================================================
   /watch/<Name>: THE MOMENTS AROUND A MATCH.

   Three things live here, each drawn by its own script:

     the sound toggle   channel-sounds.js     in the viewer bar
     the VS splash      player-channel.js     over the stage as a match goes live
     the result         results-scene.js      full screen once the last ball drops

   Same palette and same rule as player-channel-scenes.css: dark in both themes,
   because this is a broadcast surface read from across a room, and the brand
   green is the light.
   ========================================================================= */

/* --------------------------------------------------------------------------
   The sound toggle

   Dressed exactly like the full-screen button beside it -- the two are one bar
   of viewer controls -- with one addition: the "locked" state, where the viewer
   wants sound and the browser is still refusing it, glows until tapped. That is
   the state a first-time visitor lands in, and without a nudge they would never
   know the page makes a noise at all.
   -------------------------------------------------------------------------- */

.pc-sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  margin: 0;
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;

  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(8, 13, 20, 0.85);

  cursor: pointer;
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.pc-sound-toggle[hidden] {
  display: none;
}

.pc-sound-toggle:hover,
.pc-sound-toggle:focus-visible {
  color: #fff;
  border-color: rgba(46, 255, 115, 0.55);
  background: rgba(46, 255, 115, 0.12);
}

.pc-sound-icon {
  display: block;
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pc-sound-body {
  fill: currentColor;
}

/* Waves when it is on, a cross when it is not. Locked shows the waves: the
   viewer's answer is "yes", the browser just has not caught up. */
.pc-sound-toggle[data-state="off"] .pc-sound-waves,
.pc-sound-toggle:not([data-state="off"]) .pc-sound-cross {
  display: none;
}

.pc-sound-toggle[data-state="on"] {
  color: #2eff73;
  border-color: rgba(46, 255, 115, 0.4);
}

.pc-sound-toggle[data-state="locked"] {
  color: #04150a;
  border-color: #2eff73;
  background: #2eff73;
  animation: pc-sound-nudge 2.4s ease-in-out infinite;
}

.pc-sound-toggle[data-state="locked"]:hover,
.pc-sound-toggle[data-state="locked"]:focus-visible {
  color: #04150a;
  background: #5dff93;
}

@keyframes pc-sound-nudge {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(46, 255, 115, 0.5);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(46, 255, 115, 0);
  }
}

/* --------------------------------------------------------------------------
   The VS splash

   Laid over the whole match hero for three seconds as the match goes live: the
   two names slide in from either side, the VS lands (with the app's sting),
   and it all fades back to the stage. pointer-events: none throughout -- it is
   a flourish, and it must never be the thing between a viewer and a control.
   -------------------------------------------------------------------------- */

.player-channel-hero {
  position: relative;
}

.pc-intro {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(12px, 3vw, 40px);
  padding: 0 clamp(16px, 4vw, 60px);
  border-radius: 18px;
  pointer-events: none;
  color: #fff;
  background:
    radial-gradient(60% 80% at 50% 50%, rgba(46, 255, 115, 0.18), transparent 70%),
    rgba(4, 7, 11, 0.9);
  animation: pc-intro-out 3.4s ease forwards;
}

.pc-intro-side {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.pc-intro-side.is-left {
  text-align: right;
  animation: pc-intro-left 450ms cubic-bezier(0.55, 0, 1, 0.45) both;
}

.pc-intro-side.is-right {
  text-align: left;
  animation: pc-intro-right 450ms cubic-bezier(0.55, 0, 1, 0.45) both;
}

.pc-intro-name {
  overflow: hidden;
  font-size: clamp(22px, 4.4vw, 58px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-intro-meta {
  font-size: clamp(11px, 1.2vw, 15px);
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.pc-intro-vs {
  font-size: clamp(34px, 7vw, 96px);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  color: #2eff73;
  text-shadow: 0 0 36px rgba(46, 255, 115, 0.55);
  /* Lands as the two sides meet -- the same moment the sting plays. */
  animation: pc-intro-slam 420ms 450ms cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes pc-intro-left {
  from {
    opacity: 0;
    transform: translateX(-60%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pc-intro-right {
  from {
    opacity: 0;
    transform: translateX(60%);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pc-intro-slam {
  from {
    opacity: 0;
    transform: scale(2.6);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pc-intro-out {
  0%,
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   THE RESULT

   A scene like the idle ones (same felt, same identity strip), tinted by how
   the night went for the player whose channel it is:

     is-win      the lamp over the table burns brighter
     is-loss     the room cools, and the winner's side still gets its glow
     is-neutral  a caster's channel, a draw, a void
   -------------------------------------------------------------------------- */

.pc-scene--results {
  align-items: flex-start;
}

.pc-scene--results.is-win .pc-scene-felt-glow {
  background: radial-gradient(
    circle,
    rgba(46, 255, 115, 0.3) 0%,
    rgba(46, 255, 115, 0.08) 45%,
    transparent 70%
  );
}

.pc-scene--results.is-loss .pc-scene-felt-glow {
  background: radial-gradient(
    circle,
    rgba(120, 150, 190, 0.16) 0%,
    rgba(120, 150, 190, 0.05) 45%,
    transparent 70%
  );
}

.pc-res {
  margin-top: clamp(18px, 3vw, 30px);
}

.pc-res-kicker {
  display: inline-block;
  margin: 0 0 12px;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.pc-res-headline {
  margin: 0;
  font-size: clamp(34px, 6.4vw, 68px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -1px;
  color: #fff;
  animation: pc-res-in 600ms cubic-bezier(0.2, 1.3, 0.4, 1) both;
  word-break: break-word;
}

.pc-scene--results.is-win .pc-res-headline {
  color: #2eff73;
  text-shadow: 0 0 40px rgba(46, 255, 115, 0.35);
}

.pc-res-reason {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
}

@keyframes pc-res-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* The two sides ------------------------------------------------------------ */

.pc-res-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(10px, 2.4vw, 26px);
  max-width: 720px;
  margin: clamp(22px, 3.4vw, 34px) auto 0;
}

.pc-res-side {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: clamp(20px, 2.8vw, 28px) 12px clamp(16px, 2.4vw, 22px);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  animation: pc-res-in 600ms 120ms cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.pc-res-side.is-win {
  border-color: rgba(46, 255, 115, 0.55);
  background: linear-gradient(180deg, rgba(46, 255, 115, 0.14), rgba(46, 255, 115, 0.03));
  box-shadow:
    0 0 0 1px rgba(46, 255, 115, 0.15),
    0 18px 50px rgba(46, 255, 115, 0.16);
}

.pc-res-side.is-loss {
  opacity: 0.86;
}

.pc-res-crown {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #04150a;
  background: #2eff73;
  box-shadow: 0 8px 20px rgba(46, 255, 115, 0.35);
}

.pc-res-mono {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.1);
}

.pc-res-side.is-win .pc-res-mono {
  color: #04150a;
  background: linear-gradient(145deg, #2eff73, #12b855);
}

.pc-res-name {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 900;
  line-height: 1.2;
  color: #fff;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-res-name:hover {
  text-decoration: underline;
}

.pc-res-rank {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.5);
}

.pc-res-score {
  margin-top: 4px;
  font-size: clamp(46px, 8vw, 84px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.pc-res-side.is-win .pc-res-score {
  color: #2eff73;
}

/* The tiebreaker score, beside the regulation one it decided. */
.pc-res-sd {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #ffb066;
  background: rgba(255, 176, 102, 0.16);
}

.pc-res-rating {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pc-res-rating-value {
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pc-res-rating-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.pc-res-delta {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pc-res-delta.is-up {
  color: #2eff73;
  background: rgba(46, 255, 115, 0.14);
}

.pc-res-delta.is-down {
  color: #ff7b7b;
  background: rgba(255, 107, 107, 0.14);
}

.pc-res-vs {
  align-self: center;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
}

/* The detail ---------------------------------------------------------------- */

.pc-res-details {
  display: grid;
  gap: 12px;
  max-width: 820px;
  margin: clamp(22px, 3.4vw, 34px) auto 0;
  text-align: left;
  animation: pc-res-in 600ms 260ms ease both;
}

.pc-res-details-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.pc-res-card {
  min-width: 0;
  padding: 14px 16px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.045);
}

.pc-res-card-head {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

/* Round by round: scrolls sideways on its own rather than pushing the page,
   because a match that went deep into sudden death has a lot of columns. */
.pc-res-table-wrap {
  overflow-x: auto;
}

.pc-res-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.pc-res-table th,
.pc-res-table td {
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}

.pc-res-table thead th {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.45);
}

.pc-res-table tbody th {
  max-width: 180px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}

.pc-res-table tbody tr + tr {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.pc-res-table td {
  font-size: 16px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.82);
}

.pc-res-table td.is-best {
  color: #2eff73;
}

.pc-res-table .is-sd {
  color: #ffb066;
}

.pc-res-table .is-total {
  font-weight: 900;
  color: #fff;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.pc-res-table tr.is-winner th,
.pc-res-table tr.is-winner td.is-total {
  color: #2eff73;
}

/* Turn of the match */

.pc-res-turn-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.pc-res-turn-line strong {
  color: #fff;
}

.pc-res-turn-points {
  margin-left: auto;
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #2eff73;
}

.pc-res-turn-balls {
  margin-top: 10px;
}

/* At the table: the same numbers for both players, the better one lit. */

.pc-res-h2h-names,
.pc-res-h2h-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.pc-res-h2h-names {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.6);
}

.pc-res-h2h-names span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-res-h2h-names span:last-child {
  grid-column: 3;
  text-align: right;
}

.pc-res-h2h-row {
  padding: 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.pc-res-h2h-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-align: center;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.pc-res-h2h-val {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.7);
}

.pc-res-h2h-row .pc-res-h2h-val:last-child {
  text-align: right;
}

.pc-res-h2h-val.is-lead {
  color: #2eff73;
}

/* What happens next --------------------------------------------------------- */

.pc-res-next {
  min-height: 1px;
  margin-top: clamp(18px, 2.8vw, 26px);
}

.pc-res-next-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  color: #2eff73;
  background: rgba(46, 255, 115, 0.12);
  border: 1px solid rgba(46, 255, 115, 0.4);
  animation: pc-res-in 420ms ease both;
}

.pc-res-next-line.is-found {
  color: #1a0d03;
  background: linear-gradient(90deg, #ffb066, #ef5c23);
  border-color: transparent;
}

.pc-res-next-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  animation: pc-blip 1.4s ease-in-out infinite;
}

/* How long this screen has left. Quiet on purpose: it answers "will this
   change on its own?" for somebody who wonders, and is ignorable otherwise. */
.pc-res-hold {
  height: 3px;
  max-width: 320px;
  margin: 18px auto 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.pc-res-hold span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(46, 255, 115, 0.55);
  transform-origin: left center;
  animation-name: pc-res-drain;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes pc-res-drain {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.pc-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Phones
   -------------------------------------------------------------------------- */

@media (max-width: 560px) {
  .pc-res-board {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .pc-res-vs {
    display: none;
  }

  .pc-res-side {
    grid-template-columns: auto minmax(0, 1fr) auto;
    justify-items: start;
    align-items: center;
    column-gap: 12px;
    text-align: left;
  }

  .pc-res-mono {
    grid-row: span 2;
  }

  .pc-res-score {
    grid-column: 3;
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 44px;
  }

  .pc-res-rank,
  .pc-res-sd,
  .pc-res-rating {
    grid-column: 2;
  }

  .pc-res-rating {
    justify-content: flex-start;
    margin: 0;
  }

  .pc-res-crown {
    left: 16px;
    transform: none;
  }

  .pc-intro {
    grid-template-columns: 1fr;
    align-content: center;
    text-align: center;
  }

  .pc-intro-side.is-left,
  .pc-intro-side.is-right {
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   Across the room

   On the television the result is the whole screen, and it is read from a
   sofa: the column widens and the numbers grow.
   -------------------------------------------------------------------------- */

html.is-tv .pc-scene--results .pc-res-board {
  max-width: min(1100px, 70vw);
}

html.is-tv .pc-scene--results .pc-res-details {
  max-width: min(1300px, 80vw);
}

html.is-tv .pc-scene--results .pc-res-score {
  font-size: clamp(64px, 9vh, 140px);
}

html.is-tv .pc-scene--results .pc-res-name {
  font-size: clamp(20px, 2.8vh, 40px);
}

html.is-tv .pc-scene--results .pc-res-table td {
  font-size: clamp(16px, 2.2vh, 28px);
}

/* --------------------------------------------------------------------------
   Reduced motion: every screen still says everything; nothing moves to say it.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .pc-sound-toggle[data-state="locked"],
  .pc-res-headline,
  .pc-res-side,
  .pc-res-details,
  .pc-res-next-line,
  .pc-res-next-dot,
  .pc-intro-side.is-left,
  .pc-intro-side.is-right,
  .pc-intro-vs {
    animation: none;
  }

  /* The splash still comes and goes -- it carries who is playing -- but
     without the slam. */
  .pc-intro {
    animation: pc-intro-out 3.4s steps(1, end) forwards;
  }
}
