/* Win cinematics: the full-screen film that plays when a card with one ends a
   match. The film itself is drawn on the canvas by public/win-cinematic.js;
   this file only places the overlay and the card layer, fades them and styles
   the Skip button. */

.win-cine {
  position: fixed;
  inset: 0;
  z-index: 20000; /* above modals, toasts and the onboarding spotlight */
  background: #000;
  opacity: 0;
  transition: opacity 0.18s ease-out;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.win-cine.win-cine-in {
  opacity: 1;
}

/* The last 0.75s: the victory screen is already arriving underneath. */
.win-cine.win-cine-out {
  opacity: 0;
  transition: opacity 0.75s ease-in;
  pointer-events: none;
}

.win-cine.win-cine-skipped {
  opacity: 0;
  transition: opacity 0.26s ease-out;
  pointer-events: none;
}

.win-cine-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* The winning card itself: a clone of the played card, moved by the film
   (env.card.place in win-cinematic.js) so the opening shot shows the card as
   it looks on the board, in the player's card theme and art set. */
.win-cine-card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

.win-cine-card-mover {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

/* The hand lays a card out as a flex item 1px wide; here it stands alone. */
.win-cine-card-mover .card-container {
  display: block;
  width: auto;
  flex: none;
}

/* White-out as the card burns up. The glow also swallows the card's shadow. */
.win-cine-card-burn {
  position: absolute;
  background: #fff;
  box-shadow: 0 0 8px 16px #fff;
  opacity: 0;
}

.win-cine-actions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
}

.win-cine-skip {
  min-width: 96px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font: 700 15px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.win-cine-skip:hover,
.win-cine-skip:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.75);
  outline: none;
  border-color: #fff;
}

.win-cine-skip:active {
  transform: scale(0.95);
}

/* "Turn off" sits just left of Skip, quieter so Skip stays the main choice. */
.win-cine-off {
  min-width: 0;
  font-weight: 600;
  font-size: 13px;
  opacity: 0.55;
}

/* The choice "Turn off" opens: just this film, or all of them. Above the
   button row, right-aligned with it. */
.win-cine-off-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.win-cine-off-menu[hidden] {
  display: none;
}
.win-cine-off-choice {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.win-cine-off-choice:hover,
.win-cine-off-choice:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  border-color: #fff;
  outline: none;
}

.win-cine-off-note {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100000;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font: 500 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: opacity 0.4s ease;
}

.win-cine-off-note-out {
  opacity: 0;
}

/* Waiting for the painted images: the film holds on the winning card. Skip
   stays hidden until the bar has been up a couple of seconds. */
.win-cine-waiting:not(.win-cine-can-skip) .win-cine-skip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.win-cine-loader {
  position: absolute;
  left: 50%;
  bottom: max(13%, calc(env(safe-area-inset-bottom) + 72px));
  width: min(320px, 62vw);
  height: 8px;
  margin-left: calc(min(320px, 62vw) / -2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 2px 10px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.win-cine-loading .win-cine-loader {
  opacity: 1;
}

.win-cine-loader-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f4b84a, #ffe7a6);
  transition: width 0.2s ease-out;
}

/* Test page: /testing/win-cinematic */
.win-cine-harness {
  max-width: 720px;
  margin: 24px auto;
  padding: 20px;
}

.win-cine-harness-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

.win-cine-harness-row label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.win-cine-harness-cards {
  display: flex;
  gap: 16px;
  margin: 14px 0;
}

.win-cine-harness-cards .card-container {
  width: auto;
  flex: none;
}

.win-cine-harness-state {
  font-family: monospace;
  opacity: 0.8;
}

/* Card details page: replay a finishing move the player has unlocked. */
.card-finishing-move-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid #c8932f;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe7a6, #f4b84a);
  color: #3a2408;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, filter 0.15s ease;
}

.card-finishing-move-btn[hidden] {
  display: none;
}

.card-finishing-move-btn:hover,
.card-finishing-move-btn:focus-visible {
  filter: brightness(1.06);
  outline: none;
}

.card-finishing-move-btn:active {
  transform: scale(0.96);
}

/* Profile > Preferences: "N turned off one by one · Turn back on". */
.win-cine-films-off {
  margin-top: 4px;
}
.win-cine-films-off[hidden] {
  display: none;
}
.win-cine-films-off-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
