/* ─────────────────────────────────────────────────────────────
   BATTLE JAR — the whole site's styles
   Holo console: black glass, electric blue glow, old CRT lines.

   Colours
     --void    #03060c   the darkest background
     --deep    #0f2744   the glow behind the jar
     --panel   #0a182c   panel glass
     --blue    #2ea8ff   the electric blue, lines and glow
     --ice     #9fe6ff   light blue, highlights
     --text    #cfeaff   normal text
     --muted   #7fd0ff   labels
     --white   #eaf7ff   the brightest text
   ───────────────────────────────────────────────────────────── */

:root {
  --void:  #03060c;
  --deep:  #0f2744;
  --panel: #0a182c;
  --blue:  #2ea8ff;
  --ice:   #9fe6ff;
  --text:  #cfeaff;
  --muted: #7fd0ff;
  --white: #eaf7ff;

  --jar-h: clamp(380px, 72vh, 820px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

html { background: var(--void); }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 120% 80% at 50% 30%, var(--deep) 0%, #060b16 60%, var(--void) 100%);
  overflow-x: hidden;
  color: var(--text);
  font-family: 'Share Tech Mono', ui-monospace, monospace;
  font-size: 16px;
  line-height: 1.5;
}

/* the CRT lines over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
              rgba(255,255,255,0.035) 0 2px, transparent 2px 4px);
}

/* links: no underline, only on hover */
a { color: var(--ice); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

/* ---------- header ---------- */

.bj-header {
  text-align: center;
  padding: 34px 20px 8px;
}

.bj-title-link:hover { text-decoration: none; }

.bj-title {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(40px, 7vw, 76px);
  letter-spacing: 0.12em;
  line-height: 1;
  color: var(--white);
  text-shadow: 0 0 10px var(--blue), 0 0 26px var(--blue), 0 0 52px rgba(46,168,255,0.45);
}

.bj-tagline {
  margin: 12px 0 0;
  font-size: clamp(12px, 1.4vw, 15px);
  letter-spacing: 0.35em;
  color: var(--muted);
}

/* ---------- the three columns ---------- */

.bj-arena {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 22px 10px;
  display: grid;
  grid-template-columns: 250px 1fr 250px;
  align-items: end;
  gap: 20px;
}

/* lets the columns shrink on small screens instead of spilling off */
.bj-arena > * { min-width: 0; }

/* ---------- panels ---------- */

.bj-panel {
  align-self: center;
  background: rgba(10, 24, 44, 0.72);
  border: 1px solid rgba(46, 168, 255, 0.55);
  border-radius: 12px;
  padding: 16px;
  box-shadow: inset 0 0 18px rgba(46,168,255,0.15), 0 0 14px rgba(46,168,255,0.15);
}

.bj-panel-head {
  margin: 0 0 14px;
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* fighter slots */
.bj-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bj-slot {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(46, 168, 255, 0.04);
  border: 1px dashed rgba(46, 168, 255, 0.45);
  border-radius: 8px;
  font-size: 26px;
  color: rgba(127, 208, 255, 0.45);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.bj-slot:hover {
  border-color: var(--blue);
  color: var(--ice);
  box-shadow: 0 0 10px rgba(46,168,255,0.35);
}

/* a slot with a fighter in it: the avatar fills the square.
   Two pictures sit on top of each other: looking away, and
   looking at you. Hover or selected shows the second one. */
.bj-slot-filled {
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--blue);
  background: none;
}

.bj-slot-filled img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .15s ease;
}

.bj-avatar-look { opacity: 0; }

.bj-slot-filled:hover .bj-avatar-look,
.bj-slot-filled.is-selected .bj-avatar-look { opacity: 1; }

.bj-slot-filled:hover img,
.bj-slot-filled.is-selected img { transform: scale(1.08); }

/* hologram: faint lines always rolling over the avatar,
   and the picture flickers now and then */
.bj-holo-lines,
.bj-scan-sweep {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.bj-holo-lines {
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(0deg,
              rgba(46,168,255,0.18) 0 2px, transparent 2px 5px);
  animation: bj-holo-roll 1.2s linear infinite;
}

@keyframes bj-holo-roll { to { background-position: 0 10px; } }

.bj-avatar-idle,
.bj-slot-filled:hover .bj-avatar-look,
.bj-slot-filled.is-selected .bj-avatar-look {
  animation: bj-holo-flicker 5s infinite;
}

@keyframes bj-holo-flicker {
  0%, 91%, 100% { opacity: 1; }
  92% { opacity: 0.55; }
  93% { opacity: 1; }
  95% { opacity: 0.7; }
  96% { opacity: 1; }
}

/* scan sweep: a bright line runs down the square while hovering */
.bj-scan-sweep {
  top: -15%;
  height: 14%;
  background: linear-gradient(transparent, rgba(159,230,255,0.55), transparent);
  opacity: 0;
}

.bj-slot-filled:hover .bj-scan-sweep {
  opacity: 1;
  animation: bj-scan 1.6s linear infinite;
}

@keyframes bj-scan {
  0%   { top: -15%; }
  70%  { top: 100%; }
  100% { top: 100%; }
}

/* selected: a brighter glow around the square */
.bj-slot-filled.is-selected {
  border-color: var(--ice);
  box-shadow: 0 0 16px rgba(46,168,255,0.9);
}

.bj-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.bj-pager-btn {
  background: none;
  border: 1px solid rgba(46, 168, 255, 0.55);
  border-radius: 5px;
  padding: 0 10px;
  font-size: 18px;
  line-height: 1.4;
  color: var(--muted);
  cursor: pointer;
}

.bj-pager-btn:hover { border-color: var(--blue); color: var(--ice); }

/* ---------- the jar ---------- */

.bj-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bj-jar {
  position: relative;
  width: min(100%, calc(var(--jar-h) * 1.2));
  aspect-ratio: 1.2;
  border: 2px solid rgba(127, 208, 255, 0.8);
  border-radius: 40px 40px 48px 48px;
  background: linear-gradient(135deg, rgba(46,168,255,0.16), rgba(46,168,255,0.03) 60%);
  box-shadow: 0 0 26px rgba(46,168,255,0.45), inset 0 0 40px rgba(46,168,255,0.25);
  animation: bj-breathe 4s ease-in-out infinite;
}

/* the one bit of motion: the glass glow slowly breathing */
@keyframes bj-breathe {
  0%, 100% { box-shadow: 0 0 22px rgba(46,168,255,0.40), inset 0 0 36px rgba(46,168,255,0.22); }
  50%      { box-shadow: 0 0 34px rgba(46,168,255,0.60), inset 0 0 46px rgba(46,168,255,0.32); }
}

.bj-lid {
  position: absolute;
  top: -22px;
  left: 15%;
  right: 15%;
  height: 20px;
  border-radius: 7px;
  background: linear-gradient(var(--white), #8fbcd8);
  box-shadow: 0 0 12px var(--blue);
}

.bj-shine {
  position: absolute;
  top: 7%;
  left: 7%;
  width: 6%;
  height: 58%;
  border-radius: 20px;
  background: linear-gradient(rgba(255,255,255,0.32), rgba(255,255,255,0));
  pointer-events: none;
}

.bj-bars {
  position: absolute;
  top: 6%;
  left: 17%;
  right: 7%;
  display: flex;
  gap: 18px;
}

.bj-bar {
  flex: 1;
  height: 10px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  overflow: hidden;
}

.bj-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--ice));
}

/* health drains smoothly; the right bar drains toward its outer edge */
.bj-bar span { transition: width .3s ease; }
.bj-bar-right span { margin-left: auto; }

.bj-empty {
  position: absolute;
  top: 45%;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: rgba(127, 208, 255, 0.6);
}

.bj-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 13%;
  border-top: 1px solid rgba(127, 208, 255, 0.6);
  border-radius: 0 0 46px 46px;
  background: repeating-linear-gradient(90deg,
              rgba(46,168,255,0.18) 0 16px, rgba(46,168,255,0.08) 16px 32px);
}

/* the fighters inside the jar. Each is a box holding one
   picture; fight.js moves the box and swaps the picture. */
.bj-fighter {
  position: absolute;
  z-index: 60;              /* above the screen lines, so they stay crisp */
  bottom: 7%;
  height: 36%;
  pointer-events: none;
  transform-origin: 50% 100%;
}

/* pictures stand on the floor; a bigger picture grows upward */
.bj-fighter {
  display: flex;
  align-items: flex-end;
}

.bj-fighter img {
  display: block;
  flex: none;
  height: 100%;
  width: auto;
}

.bj-fighter-left  { left: 12%; }
.bj-fighter-right { right: 12%; }

/* the glow around each fighter (set in roster.js):
   white helps a blue fighter stand out from the blue glass */
.bj-fighter img {
  filter: drop-shadow(0 0 6px rgba(46,168,255,0.45));
}

.bj-fighter[data-glow="white"] img {
  filter: drop-shadow(0 0 2px rgba(255,255,255,0.9))
          drop-shadow(0 0 6px rgba(255,255,255,0.35));
}

/* whoever stands on the right is flipped to face the left */
.bj-fighter-right img { transform: scaleX(-1); }

/* standing ready: a small bounce while the fight is on */
.bj-fighter.is-ready { animation: bj-bob .5s ease-in-out infinite alternate; }
.bj-fighter-right.is-ready { animation-duration: .75s; }

@keyframes bj-bob {
  from { transform: translateY(0); }
  to   { transform: translateY(-2.5%); }
}

/* taking a hit: red flash and a shake */
.bj-fighter.is-hit { animation: bj-shake .28s linear; }
.bj-fighter.is-hit img {
  filter: brightness(1.5) drop-shadow(0 0 3px #ff2d4a) drop-shadow(0 0 10px #ff2d4a);
}

@keyframes bj-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4%); }
  40% { transform: translateX(4%); }
  60% { transform: translateX(-3%); }
  80% { transform: translateX(2%); }
}

/* blocking a hit: a blue flash */
.bj-fighter.is-blocking img {
  filter: brightness(1.3) drop-shadow(0 0 4px var(--ice)) drop-shadow(0 0 12px var(--blue));
}

/* knocked out: falls over backwards */
.bj-fighter-left.is-down  { transform: translate(55%, -38%) rotate(-90deg); }
.bj-fighter-right.is-down { transform: translate(-55%, -45%) rotate(90deg); }
.bj-fighter.is-down {
  animation: none;
  transition: transform .45s cubic-bezier(.5, 0, .9, .5);
}
.bj-fighter.is-down img { filter: brightness(0.6); }

/* knocked out with their own lying-down picture: a thud onto the floor */
.bj-fighter.is-out { animation: bj-thud .35s ease-out; }

@keyframes bj-thud {
  0%   { transform: translateY(-25%); }
  60%  { transform: translateY(0); }
  80%  { transform: translateY(-4%); }
  100% { transform: translateY(0); }
}

/* the winner hops */
.bj-fighter.is-winner { animation: bj-hop .45s ease-out 4; }

@keyframes bj-hop {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-14%); }
}

/* the spark where a kick lands */
.bj-spark {
  position: absolute;
  z-index: 61;
  width: 11%;
  aspect-ratio: 1;
  margin: -5.5% 0 0 -5.5%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, #fff 0 18%, #ffd34d 30%, rgba(255,60,60,0.8) 55%, transparent 70%);
  animation: bj-spark .3s ease-out forwards;
}

.bj-spark.is-blocked {
  background: radial-gradient(circle, #fff 0 18%, var(--ice) 35%, rgba(46,168,255,0.7) 55%, transparent 70%);
}

@keyframes bj-spark {
  from { transform: scale(0.3); opacity: 1; }
  to   { transform: scale(1.6); opacity: 0; }
}

/* the whole jar jolts on a big hit */
.bj-jar.is-jolted { animation: bj-jolt .2s linear; }

/* (moves the jar by its position rather than a transform,
   so the fighters stay above the screen lines during the jolt) */
@keyframes bj-jolt {
  0%, 100% { left: 0;    top: 0; }
  30%      { left: -3px; top: 2px; }
  60%      { left: 3px;  top: -1px; }
}

/* the start button, in the middle of the jar */
.bj-start {
  position: absolute;
  top: 24%;
  left: 50%;
  z-index: 5;
  transform: translateX(-50%);
  padding: 16px 34px;
  background: linear-gradient(var(--ice), var(--blue));
  border: 0;
  border-radius: 10px;
  color: var(--void);
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(15px, 1.6vw, 22px);
  letter-spacing: 0.1em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(46,168,255,0.7);
  transition: box-shadow .15s ease, opacity .25s ease, transform .1s ease;
}

.bj-start:hover  { box-shadow: 0 0 30px rgba(46,168,255,0.95); }
.bj-start:active { transform: translateX(-50%) translateY(2px); }

/* hidden while the fight is on */
.bj-start.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* the glow the jar sits on */
.bj-platform {
  width: 118%;
  max-width: 100%;
  height: 24px;
  margin-top: 8px;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--blue) 0%, rgba(46,168,255,0.15) 55%, transparent 72%);
  filter: blur(1px);
}

/* ---------- footer ---------- */

.bj-footer {
  margin-top: 28px;
  padding: 16px 20px 20px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: rgba(127, 208, 255, 0.6);
  border-top: 1px solid rgba(46, 168, 255, 0.25);
}

/* ---------- smaller screens: jar on top, panels underneath ---------- */

@media (max-width: 900px) {
  .bj-arena {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .bj-stage    { grid-column: 1 / -1; order: -1; }
  .bj-slots    { grid-template-columns: repeat(3, 1fr); }
  .bj-fighters { order: 1; }
}

@media (max-width: 560px) {
  :root { --jar-h: clamp(300px, 56vh, 440px); }
  .bj-arena { grid-template-columns: 1fr; padding: 32px 14px 6px; }
  .bj-slots { max-width: 300px; margin: 0 auto; }
  .bj-header { padding-top: 26px; }
}

/* anyone who asks for less motion gets a still jar */
@media (prefers-reduced-motion: reduce) {
  .bj-jar { animation: none; }
  .bj-fighter { animation: none !important; }
  .bj-holo-lines, .bj-scan-sweep, .bj-slot-filled img { animation: none !important; }
  * { transition: none !important; }
}
