/* ============================================================================
 * result-panel.css — campaign post-fight verdict card.
 *
 * Wraps the existing .story-panel-container output (image + narration + extras)
 * with a "broadcast verdict" treatment. Wins and losses share structure but
 * diverge in palette, typography weight, and motion.
 *
 * Activated by adding `.is-result` + `.is-victory|.is-defeat` to the existing
 * .story-panel-container element (see story-panel.js _showPanel hook).
 *
 * Mobile-first; primary target is the Arena.social iframe at ~480px.
 * ========================================================================== */

/* ---------------------------------------------------------------- VARIABLES */
.story-panel-container.is-result {
  --rp-gold: #ffd700;
  --rp-gold-deep: #c89500;
  --rp-red: #ff2d3a;
  --rp-cyan: #00d4ff;
  --rp-bg: #08060a;
  --rp-paper: #0f0a12;
  --rp-bone: #f0eded;
  --rp-grit: rgba(255, 255, 255, 0.08);
}

/* ---------------------------------------------------------- BACKDROP / BASE */
/* Dim the hero image so word art reads cleanly. Keep a touch of color through. */
.story-panel-container.is-result .story-panel-image {
  filter: brightness(0.55) contrast(1.05) saturate(1.1);
}
.story-panel-container.is-defeat .story-panel-image {
  filter: brightness(0.4) contrast(1.15) saturate(0.35) hue-rotate(-8deg);
}

/* Vignette overlay — sits just above the image, below all chrome. */
.story-panel-container.is-result::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(ellipse at 50% 35%, transparent 0%, rgba(8,6,10,0.35) 55%, rgba(8,6,10,0.85) 100%),
    linear-gradient(180deg, rgba(8,6,10,0.3) 0%, transparent 25%, transparent 75%, rgba(8,6,10,0.5) 100%);
}

/* Defeat: add a red duotone wash + scanline static. */
.story-panel-container.is-defeat::before {
  background:
    radial-gradient(ellipse at 50% 40%, transparent 0%, rgba(8,6,10,0.55) 70%, rgba(8,6,10,0.95) 100%),
    linear-gradient(180deg, rgba(255,45,58,0.12) 0%, transparent 50%);
}
.story-panel-container.is-defeat::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(255,255,255,0.025) 2px,
    rgba(255,255,255,0.025) 3px
  );
  mix-blend-mode: overlay;
  animation: rp-scan-drift 8s linear infinite;
}

/* ---------------------------------------------------------- VERDICT CHYRON */
/* Top strip: REC dot + verdict label + episode code. Mirrors og-image.js style. */
.rp-chyron {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 34px;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: linear-gradient(180deg, rgba(8,6,10,0.95) 0%, rgba(8,6,10,0.7) 100%);
  border-bottom: 1px solid var(--rp-grit);
  font-family: var(--font-mono, "JetBrains Mono"), monospace;
  font-size: 10px;
  letter-spacing: 3px;
  color: rgba(180, 175, 175, 0.7);
  animation: rp-chyron-slide 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.rp-chyron-rec {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 14px;
  color: var(--rp-red);
  font-weight: 700;
}
.rp-chyron-rec::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rp-red);
  box-shadow: 0 0 10px rgba(255,45,58,0.65);
  animation: rp-rec-pulse 1.4s ease-in-out infinite;
}
.rp-chyron-divider {
  margin: 0 10px;
  opacity: 0.4;
}
.rp-chyron-tx {
  margin-left: auto;
  color: var(--rp-gold);
}
.story-panel-container.is-defeat .rp-chyron-tx {
  color: var(--rp-red);
}

/* ---------------------------------------------------------- WORD ART */
/* The big VICTORY / DEFEATED treatment. Sits above the image, below narration. */
.rp-verdict {
  position: absolute;
  top: 50px;
  left: 0; right: 0;
  z-index: 6;
  pointer-events: none;
  text-align: center;
  padding: 0 20px;
}
.rp-verdict-eyebrow {
  font-family: var(--font-mono, "JetBrains Mono"), monospace;
  font-size: 10px;
  letter-spacing: 8px;
  color: var(--rp-gold);
  margin-bottom: 6px;
  opacity: 0;
  animation: rp-eyebrow-fade 0.5s ease 0.3s forwards;
}
.story-panel-container.is-defeat .rp-verdict-eyebrow {
  color: var(--rp-red);
}
.rp-verdict-word {
  display: inline-block;
  font-family: var(--font-display, "Bebas Neue"), Impact, sans-serif;
  font-size: clamp(64px, 18vw, 140px);
  line-height: 0.85;
  letter-spacing: 4px;
  font-weight: 400;
  color: var(--rp-gold);
  text-shadow:
    0 2px 0 rgba(0,0,0,0.4),
    0 0 32px rgba(255,215,0,0.45);
  transform: translateY(20px);
  opacity: 0;
  animation: rp-verdict-rise 0.7s cubic-bezier(0.18, 1.05, 0.4, 1) 0.45s forwards;
  position: relative;
}
/* Diagonal slash that wipes across the word on entrance — VICTORY only. */
.rp-verdict-word::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -10%;
  right: -10%;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, var(--rp-gold) 30%, var(--rp-gold) 70%, transparent 100%);
  transform: translateY(-50%) scaleX(0);
  transform-origin: left center;
  opacity: 0.85;
  animation: rp-slash 0.5s cubic-bezier(0.7, 0, 0.3, 1) 0.95s forwards;
}

/* DEFEAT word treatment — chromatic aberration via stacked text-shadow + glitch. */
.story-panel-container.is-defeat .rp-verdict-word {
  color: var(--rp-bone);
  text-shadow:
    -2px 0 0 var(--rp-red),
    2px 0 0 var(--rp-cyan),
    0 0 24px rgba(0,0,0,0.6);
  animation: rp-verdict-rise 0.7s cubic-bezier(0.18, 1.05, 0.4, 1) 0.45s forwards,
             rp-glitch 3.6s steps(1) 1.5s infinite;
}
.story-panel-container.is-defeat .rp-verdict-word::after {
  display: none;
}

/* Subline — finishing-blow tag for wins, signal-lost for losses. */
.rp-verdict-sub {
  margin-top: 8px;
  font-family: var(--font-mono, "JetBrains Mono"), monospace;
  font-size: 11px;
  letter-spacing: 4px;
  color: rgba(240, 237, 237, 0.78);
  opacity: 0;
  animation: rp-eyebrow-fade 0.5s ease 1.2s forwards;
}
.story-panel-container.is-defeat .rp-verdict-sub {
  color: var(--rp-red);
}

/* Registration marks at corners — broadcast print-feel. */
.rp-regmark {
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 6;
  border: 1.5px solid var(--rp-gold);
  opacity: 0.55;
  animation: rp-regmark-fade 0.4s ease 0.2s both;
}
.story-panel-container.is-defeat .rp-regmark {
  border-color: var(--rp-red);
}
.rp-regmark.tl { top: 46px; left: 12px; border-right: none; border-bottom: none; }
.rp-regmark.tr { top: 46px; right: 12px; border-left: none; border-bottom: none; }
.rp-regmark.bl { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.rp-regmark.br { bottom: 12px; right: 12px; border-left: none; border-top: none; }

/* ---------------------------------------------------------- NARRATION FRAME */
/* Override the default narration box for results. */
.story-panel-container.is-result .story-panel-narration {
  position: absolute;
  bottom: 24px;
  left: 14px;
  right: 14px;
  z-index: 8;
  background: linear-gradient(180deg, rgba(15,10,18,0.92) 0%, rgba(8,6,10,0.96) 100%);
  border: 1px solid var(--rp-grit);
  border-left: 3px solid var(--rp-gold);
  border-radius: 4px;
  padding: 18px 18px 16px 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(20px);
  animation: rp-narration-rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) 1.0s forwards;
}
.story-panel-container.is-defeat .story-panel-narration {
  border-left-color: var(--rp-red);
}
.story-panel-container.is-result .story-panel-speaker {
  font-family: var(--font-mono, "JetBrains Mono"), monospace;
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--rp-gold);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.story-panel-container.is-defeat .story-panel-speaker {
  color: var(--rp-red);
}
.story-panel-container.is-result .story-panel-text {
  font-family: var(--font-host, "Playfair Display"), Georgia, serif;
  font-style: italic;
  font-size: 14px;
  line-height: 1.55;
  color: var(--rp-bone);
}

/* The avatar in the narration block — for the result card, scale and frame it. */
.story-panel-container.is-result .story-panel-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--rp-gold);
  box-shadow: 0 0 18px rgba(255,215,0,0.35);
  object-fit: cover;
  object-position: center 15%;
}
.story-panel-container.is-defeat .story-panel-avatar {
  border-color: var(--rp-red);
  box-shadow: 0 0 14px rgba(255,45,58,0.35);
  filter: grayscale(0.5) brightness(0.85);
}

/* ---------------------------------------------------------- BOTTOM TAGS */
/* Brutalist bottom strip — campaign progress (wins) or retry CTA hint (losses). */
.story-panel-container.is-result .story-panel-narration > div:last-child:not(.story-panel-text):not(.story-panel-speaker) {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--rp-grit);
}

/* ---------------------------------------------------------- KEYFRAMES */
@keyframes rp-chyron-slide {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes rp-rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
@keyframes rp-eyebrow-fade {
  to { opacity: 1; }
}
@keyframes rp-verdict-rise {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes rp-slash {
  to { transform: translateY(-50%) scaleX(1); }
}
@keyframes rp-narration-rise {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes rp-regmark-fade {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 0.55; transform: scale(1); }
}
@keyframes rp-scan-drift {
  from { background-position: 0 0; }
  to { background-position: 0 12px; }
}
@keyframes rp-glitch {
  0%, 90%, 100% { transform: translate(0, 0); }
  92% { transform: translate(-2px, 1px); }
  94% { transform: translate(3px, -1px); }
  96% { transform: translate(-1px, 2px); }
}

/* ---------------------------------------------------------- DESKTOP */
@media (min-width: 768px) {
  .rp-verdict { top: 70px; }
  .rp-verdict-word { font-size: clamp(96px, 11vw, 180px); }
  .rp-verdict-eyebrow, .rp-chyron { font-size: 11px; }
  .story-panel-container.is-result .story-panel-narration {
    bottom: 32px; left: 32px; right: 32px;
    padding: 22px 24px 20px 26px;
  }
  .story-panel-container.is-result .story-panel-text { font-size: 16px; }
}

/* ---------------------------------------------------------- REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  .story-panel-container.is-result *,
  .story-panel-container.is-result *::before,
  .story-panel-container.is-result *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
}
