/* =========================================================================
 * FINAL KILLCAM — the match-winning replay's own chrome.
 * =========================================================================
 * The requirement: "a sick HUD/banner overlay for final killcam". Before this,
 * `Game._matchOver` called the same `hud.showKillcam(...)` every death calls, so
 * the one replay in a match that is a piece of PRESENTATION looked exactly like
 * the twelve that are feedback.
 *
 * Everything here is scoped under `#killcam[data-final]`, which `HUD.showKillcam`
 * sets and `HUD.hideKillcam` removes. Nothing in this file applies to an ordinary
 * killcam, so it cannot regress one — the whole sheet is inert without that
 * attribute.
 *
 * LAYOUT IS A RELATIONSHIP, NOT A LITERAL. AGENTS.md: "express a layering
 * requirement as a relationship... writing it as a number is precisely how
 * `--z-fx` came to equal `--z-modal` and paint the damage vignette over the live
 * endboard." So the banner's vertical position is derived from the height of the
 * strip it must clear (`--kcf-strip`), and its z-index from the killcam's own
 * layer, rather than from numbers that happen to work at 1920x1080.
 *
 * The three viewports this was verified in a rendered browser at — 1280x720,
 * 1600x900, 1920x1080 — are the ones the loadout screen's three separate
 * off-screen-action failures were found at. Static verification cannot see any of
 * this; only a rendered viewport can.
 */

#killcam-final { display: none; }

#killcam[data-final] #killcam-final {
  /* The band between the top strip and the skip affordance is the only part of
   * the killcam frame nothing else occupies, and this claims it explicitly rather
   * than landing there by luck. `--kcf-strip` is the measured height of `.kc-top`
   * at its largest (14px pad + the .kc-line clamp ceiling + 18px pad); the
   * `clamp` keeps the banner off a 720-line viewport's strip without shrinking it
   * below legibility on a tall one. */
  --kcf-strip: 84px;
  --kcf-gap: clamp(10px, 1.6vh, 26px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.6vw, 22px);
  position: absolute;
  top: calc(var(--kcf-strip) + var(--kcf-gap));
  left: 50%;
  transform: translateX(-50%);
  /* Bounded rather than intrinsic: a long word is not a reason to touch the
   * frame edges, and `max-width` is what stops a future localisation from
   * pushing the rules off screen. */
  max-width: min(760px, 82vw);
  pointer-events: none;
  /* Above the killcam's own inset frame (`#killcam::before`, which is a plain
   * stacking sibling) and below anything modal. Derived from the HUD layer that
   * already exists rather than restated as a number. */
  z-index: 2;
  animation: kcf-in 620ms cubic-bezier(0.16, 0.84, 0.32, 1) both;
}

/* The rules either side. They are the reason the words read as a title card and
 * not as another HUD label: a centred phrase with nothing around it is a status
 * line, a centred phrase between two rules is a masthead. */
#killcam[data-final] .kcf-rule {
  flex: 1 1 0;
  min-width: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold, #e0a437) 70%, var(--gold, #e0a437));
  opacity: 0.85;
}
#killcam[data-final] .kcf-rule:last-child {
  background: linear-gradient(270deg, transparent, var(--gold, #e0a437) 70%, var(--gold, #e0a437));
}

#killcam[data-final] .kcf-text {
  font-family: var(--ui, system-ui, sans-serif);
  font-weight: 700;
  /* Larger than `.kc-line`'s ceiling of 23px at every viewport, because the
   * banner has to outrank the strip it sits under — if the killer's name reads
   * bigger than FINAL KILLCAM, the hierarchy says the wrong thing. */
  font-size: clamp(20px, 2.6vw, 34px);
  letter-spacing: 0.34em;
  /* The trailing letter-space is real space on the right of the last glyph, so
   * a centred run of tracked capitals sits visibly left of centre unless it is
   * paid back. This is the optical-alignment fix, not a nudge. */
  text-indent: 0.34em;
  white-space: nowrap;
  color: #14100a;
  background: var(--gold, #e0a437);
  padding: 7px clamp(12px, 1.4vw, 20px) 6px;
  /* A flat gold plate reads as a UI chip; the inner light line and the drop give
   * it an edge, which is what makes it read as struck rather than printed. */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28),
    0 6px 26px rgba(0, 0, 0, 0.55);
}

/* THE CORNER TAG GOES ENTIRELY.
 *
 * *"the top left final badge is redundant get rid of that since we have final killcam
 * main badge."* This used to reduce the tag to a gold outline reading "FINAL" so it would
 * "agree with the banner rather than contradict it" — but agreeing with the banner is
 * still saying the same word twice on one frame, once in the corner and once across the
 * middle in 26px type. The banner is the answer; the corner was the draft of it.
 *
 * `display: none` rather than removing the element or the `showKillcam` write: `#killcam-tag`
 * is the ORDINARY killcam's own label ("KILLCAM") and it must keep working, so this is
 * scoped under `[data-final]` like everything else in this sheet. `#killcam-victim` is its
 * sibling inside `.kc-id` and is unaffected — on a final cam it is the losing side's name,
 * which the banner does not carry. */
#killcam[data-final] #killcam-tag { display: none; }

/* AND THE SKIP AFFORDANCE, because the final killcam cannot be skipped.
 *
 * *"u shouldnt be able to skp the final killcam so the space skip to scoreboard shouldnt
 * be there for final killcame."* `Game._updateKillcam` refuses the skip itself — this is
 * the half that stops the frame promising something the code no longer does, which is
 * worse than either alone. The ordinary killcam keeps its `skip killcam` prompt. */
#killcam[data-final] .kc-skip { display: none; }

/* The frame itself, brighter for the one replay that is not routine. Same
 * mechanism as the ordinary frame — an inset box-shadow on `::before` — so it
 * cannot disagree about geometry, only about weight. */
#killcam[data-final]::before {
  box-shadow:
    inset 0 0 0 2px rgba(224, 164, 55, 0.55),
    inset 0 0 180px rgba(0, 0, 0, 0.66);
}

/* The elapsed bar, in the same gold. It is the only moving element on the frame
 * and it is what tells a player the replay is going somewhere. */
#killcam[data-final] #killcam-bar-fill {
  background: var(--gold, #e0a437);
  box-shadow: 0 0 14px rgba(224, 164, 55, 0.55);
}

@keyframes kcf-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); letter-spacing: 0.5em; }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* A player who has asked for less motion still needs the banner; they do not
 * need it to arrive. The end state is identical, so nothing is lost. */
@media (prefers-reduced-motion: reduce) {
  #killcam[data-final] #killcam-final { animation: none; }
}

/* SHORT VIEWPORTS. At 720 lines the top strip and the banner together are a
 * sixth of the frame, which is the band a player is trying to watch the kill
 * through. The banner tightens rather than the strip, because the strip carries
 * the only text that answers "who killed whom". */
@media (max-height: 760px) {
  #killcam[data-final] #killcam-final { --kcf-strip: 72px; --kcf-gap: 8px; }
  #killcam[data-final] .kcf-text { font-size: clamp(18px, 2.2vw, 26px); padding: 5px 12px 4px; }
}
