/*
 * Brawl Stars tournament match page (match_detail.html → partials/brawl_match/).
 * Builds on tournament_match_valorant.css (.mdv) and only adds Brawl pieces, scoped under .bmv.
 */

/* Top-down map art reads as a texture: turned sideways and kept faint. */
.bmv .bmv-faceoff__map {
  inset: -40% -10%;
  filter: saturate(.9);
  opacity: .14;
  transform: rotate(-90deg) scale(1.6);
}

.bmv-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--mdv-line);
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  color: var(--mdv-muted);
  font-size: .78rem;
  font-weight: 800;
}

.bmv-mode-pill img { width: 22px; height: 22px; object-fit: contain; }
.bmv-mode-pill b { color: var(--mdv-text); }

.bmv .mdv-team__meta .bmv-rank-ico { width: 26px; height: 26px; object-fit: contain; }
.bmv .mdv-team__meta .bi-trophy-fill { color: var(--mdv-yellow); }

/* ---------------- Map strip ---------------- */
.bmv-maps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.bmv-map {
  --mode: var(--mdv-yellow);
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 14px 10px 10px;
  overflow: hidden;
  border: 1px solid var(--mdv-line);
  border-radius: 14px;
  background: rgba(17, 17, 18, .82);
  backdrop-filter: blur(4px);
}

.bmv-map::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: transparent;
}

.bmv-map.is-win-a::after { background: var(--mdv-team-a); }
.bmv-map.is-win-b::after { background: var(--mdv-team-b); }
.bmv-map.is-disputed::after { background: var(--mdv-red); }
.bmv-map.is-skipped { opacity: .45; }

.bmv-map__thumb {
  position: relative;
  display: block;
  width: 46px;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px;
  background: #0a0a0b;
}

.bmv-map__art { width: 100%; height: 100%; border-radius: 9px; object-fit: cover; }

.bmv-map__mode {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 24px;
  height: 24px;
  padding: 3px;
  border-radius: 8px;
  background: #0b0b0d;
  box-shadow: 0 0 0 2px #111112;
  object-fit: contain;
}

.bmv-map__thumb--empty { display: grid; place-items: center; border-style: dashed; color: var(--mdv-dim); font-size: 1.1rem; }

.bmv-map__label { display: grid; gap: 2px; min-width: 0; }
.bmv-map__label small { color: var(--mdv-dim); font-size: .66rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.bmv-map__label small b { color: var(--mode); }
.bmv-map__label strong { overflow: hidden; color: #fff; font-size: 1rem; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }

.bmv-map__right { display: grid; justify-items: end; gap: 6px; }
.bmv-map__score { color: #fff; font-size: 1.2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.bmv-map__score .w { color: var(--mdv-yellow); }
.bmv-map__score .l { color: rgba(255, 255, 255, .4); }
.bmv-map__state { color: var(--mdv-dim); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }

.bmv-pips { display: inline-flex; gap: 5px; }
.bmv-pips i { width: 9px; height: 9px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 3px; transform: rotate(45deg); }
.bmv-pips i.a { border-color: var(--mdv-team-a); background: var(--mdv-team-a); box-shadow: 0 0 8px rgba(255, 223, 0, .5); }
.bmv-pips i.b { border-color: var(--mdv-team-b); background: var(--mdv-team-b); }

.mdv.is-animated .bmv-map { animation: bmv-rise .6s var(--mdv-ease) both; animation-delay: calc(.55s + var(--i, 0) * 90ms); }
@keyframes bmv-rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------------- Friendly Battle ---------------- */
.bmv-battle {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 223, 0, .28);
  border-radius: 16px;
  background: var(--mdv-inner);
}

.bmv-battle::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 120% at 0% 0%, rgba(255, 223, 0, .14), transparent 60%),
    linear-gradient(180deg, transparent, rgba(0, 0, 0, .25));
}

.bmv-battle__main { display: grid; align-content: start; gap: 14px; min-width: 0; padding: 22px; }
.bmv-battle__title { display: flex; align-items: center; gap: 14px; }

.bmv-battle__logo {
  display: grid;
  flex: none;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 223, 0, .35);
  border-radius: 16px;
  background: rgba(255, 223, 0, .08);
}

.bmv-battle__logo img { width: 38px; height: 38px; object-fit: contain; }
.bmv-battle__title small { display: block; color: var(--mdv-yellow); font-size: .7rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.bmv-battle__title h3 { margin: 2px 0 0; color: #fff; font-size: 1.25rem; font-weight: 900; }
.bmv-battle__text { margin: 0; color: var(--mdv-muted); font-size: .88rem; line-height: 1.5; }
.bmv-battle__text b { color: #fff; }

.bmv-battle__cta { display: flex; flex-wrap: wrap; gap: 8px; }

.bmv .bmv-join {
  min-height: 52px;
  padding: 0 22px;
  font-size: 1rem;
  box-shadow: 0 14px 34px -12px rgba(255, 223, 0, .7);
}

.bmv .bmv-join .bi { font-size: 1.15rem; }

.bmv-battle__form { display: grid; gap: 8px; margin: 0; }
.bmv-inline { display: flex; gap: 8px; }
.bmv-inline .mdv-field { flex: 1; min-width: 0; }
.bmv-battle__hint { margin: 0; color: var(--mdv-dim); font-size: .78rem; }
.bmv-battle__error { margin: 0; color: var(--mdv-red-soft); font-size: .8rem; font-weight: 700; }

.bmv-battle__locked {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px dashed rgba(255, 255, 255, .14);
  border-radius: 12px;
  color: var(--mdv-muted);
  font-size: .86rem;
  font-weight: 600;
}

.bmv-battle__locked i { color: var(--mdv-yellow); }

.bmv-battle__side {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  border-left: 1px solid var(--mdv-line);
  background: rgba(0, 0, 0, .25);
  text-align: center;
}

.bmv-battle__side small { color: var(--mdv-muted); font-size: .8rem; font-weight: 700; line-height: 1.4; }
.bmv-battle__side small b { color: #fff; }
.bmv-battle__badge { width: 84px; height: 84px; object-fit: contain; }
.bmv-battle__badge.is-dim { opacity: .55; }

.bmv-qr {
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
  padding: 10px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 223, 0, .25), 0 18px 40px -16px rgba(255, 223, 0, .6);
}

.bmv-qr img,
.bmv-qr canvas { display: block; width: 128px !important; height: 128px !important; image-rendering: pixelated; }
.bmv-qr--empty { background: rgba(255, 255, 255, .05); box-shadow: none; color: var(--mdv-dim); font-size: 2.2rem; }

.bmv-verified {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mdv-green);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* How it works */
.bmv-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }

.bmv-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--mdv-line);
  border-radius: 14px;
  background: var(--mdv-inner);
}

.bmv-step__n {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: var(--mdv-muted);
  font-weight: 900;
}

.bmv-step strong { display: block; color: #fff; font-size: .92rem; font-weight: 900; }
.bmv-step span { color: var(--mdv-muted); font-size: .8rem; line-height: 1.4; }
.bmv-step.is-done .bmv-step__n { background: rgba(89, 241, 139, .14); color: var(--mdv-green); }
.bmv-step.is-now { border-color: rgba(255, 223, 0, .45); }
.bmv-step.is-now .bmv-step__n { background: var(--mdv-yellow); color: #111; }

.bmv-action-grid { margin-top: 12px; }
.bmv-action-grid:empty { display: none; }

.bmv-score-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bmv .bmv-score-inputs label { display: grid; gap: 4px; min-width: 0; color: var(--mdv-dim); font-size: .72rem; font-weight: 800; }

.bmv [data-brawl-pull-button]:disabled { opacity: .85; cursor: progress; }
.bmv [data-brawl-pull-button]:disabled .bi { animation: bmv-spin .9s linear infinite; }
@keyframes bmv-spin { to { transform: rotate(360deg); } }

/* Lineups */
.bmv-trophies { display: inline-flex; align-items: center; gap: 4px; }
.bmv-trophies i { color: var(--mdv-yellow); font-size: .72rem; }

/* ---------------- Results ---------------- */
.bmv-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }

.bmv-sum > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--mdv-line);
  border-radius: 12px;
  background: var(--mdv-inner);
}

.bmv-sum > div > span { color: var(--mdv-dim); font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.bmv-sum strong { display: flex; align-items: center; gap: 8px; min-width: 0; color: #fff; font-size: 1rem; font-weight: 900; }
.bmv-sum .mdv-mark { width: 24px; height: 24px; }
.bmv-sum__mvp img { width: 30px; height: 30px; object-fit: contain; }
.bmv-sum__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bmv-sum__mvp em { flex: none; color: var(--mdv-yellow); font-size: .8rem; font-style: normal; }

.bmv-maps-results { display: grid; gap: 10px; }

.bmv-res-map {
  --mode: var(--mdv-yellow);
  overflow: hidden;
  border: 1px solid var(--mdv-line);
  border-radius: 16px;
  background: var(--mdv-inner);
}

.bmv-res-map > summary {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.bmv-res-map > summary::-webkit-details-marker { display: none; }

.bmv-res-map > summary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(17, 17, 18, .97) 40%, rgba(17, 17, 18, .82)),
    var(--map, none) right center / 260px auto no-repeat;
}

.bmv-res-map__thumb {
  display: grid;
  place-items: center;
  width: 52px;
  height: 58px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  background: #0a0a0b;
  color: var(--mdv-dim);
}

.bmv-res-map__thumb img { width: 100%; height: 100%; object-fit: cover; }
.bmv-res-map__name { min-width: 0; }
.bmv-res-map__name small { display: flex; align-items: center; gap: 6px; color: var(--mdv-dim); font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.bmv-res-map__name small img { width: 18px; height: 18px; object-fit: contain; }
.bmv-res-map__name small b { color: var(--mode); }
.bmv-res-map__name strong { display: block; margin-top: 2px; color: #fff; font-size: 1.15rem; font-weight: 900; }
.bmv-res-map__name em { display: block; margin-top: 2px; color: var(--mdv-muted); font-size: .8rem; font-style: normal; font-weight: 700; }

.bmv-res-map__score { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.bmv-res-map__score .w { color: var(--mdv-yellow); }
.bmv-res-map__score .l { color: rgba(255, 255, 255, .35); }
.bmv-res-map__chev { color: var(--mdv-dim); transition: transform .3s var(--mdv-ease); }
.bmv-res-map[open] .bmv-res-map__chev { transform: rotate(180deg); }

.bmv-res-map.is-skipped { opacity: .55; }
.bmv-res-map__skip { display: flex; align-items: center; gap: 8px; padding: 14px 16px; color: var(--mdv-muted); font-size: .86rem; font-weight: 700; }

.bmv-rounds { display: grid; gap: 8px; padding: 4px 14px 14px; }

.bmv-round {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--mdv-line);
  border-radius: 14px;
  background: var(--mdv-card);
}

.bmv-round__mid { display: grid; justify-items: center; gap: 3px; text-align: center; }
.bmv-round__mid small { color: var(--mdv-dim); font-size: .66rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.bmv-round__mid strong { color: #fff; font-size: .86rem; font-weight: 900; }
.bmv-round__mid strong.is-a { color: var(--mdv-yellow); }
.bmv-round__mid em { color: var(--mdv-muted); font-size: .74rem; font-style: normal; font-weight: 700; }

.bmv-squad { display: flex; gap: 8px; min-width: 0; }
.bmv-squad--b { flex-direction: row-reverse; }
.bmv-squad__empty { color: var(--mdv-dim); font-size: .8rem; font-weight: 700; }

.bmv-brawler {
  position: relative;
  display: grid;
  flex: 1 1 0;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid var(--mdv-line);
  border-radius: 12px;
  background: var(--mdv-inner);
  text-align: center;
  transition: border-color .2s, transform .2s var(--mdv-ease);
}

.bmv-brawler:hover { border-color: rgba(255, 223, 0, .4); transform: translateY(-2px); }
.bmv-squad.is-win .bmv-brawler { border-color: rgba(255, 223, 0, .22); background: linear-gradient(180deg, rgba(255, 223, 0, .07), var(--mdv-inner)); }
.bmv-squad.is-loss .bmv-brawler { opacity: .62; }

.bmv-brawler__art { position: relative; width: 52px; height: 52px; }
.bmv-brawler__art img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); }

.bmv-brawler__pw {
  position: absolute;
  bottom: -4px;
  left: -4px;
  padding: 1px 5px;
  border-radius: 6px;
  background: #7b2cff;
  box-shadow: 0 0 0 2px var(--mdv-inner);
  color: #fff;
  font-size: .6rem;
  font-weight: 900;
}

.bmv-brawler__star {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mdv-yellow);
  box-shadow: 0 0 0 2px var(--mdv-inner), 0 0 14px rgba(255, 223, 0, .7);
  color: #111;
  font-size: .7rem;
}

.bmv-brawler strong { max-width: 100%; overflow: hidden; color: #fff; font-size: .76rem; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.bmv-brawler > span:last-child { max-width: 100%; overflow: hidden; color: var(--mdv-dim); font-size: .68rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.bmv-state { margin-top: 12px; }

@media (max-width: 960px) {
  .bmv-battle { grid-template-columns: 1fr; }
  .bmv-battle__side { grid-template-columns: auto minmax(0, 1fr); justify-items: start; border-top: 1px solid var(--mdv-line); border-left: 0; text-align: left; }
  .bmv-qr { width: 112px; height: 112px; }
  .bmv-qr img,
  .bmv-qr canvas { width: 92px !important; height: 92px !important; }
  .bmv-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .bmv-maps { grid-template-columns: 1fr; margin-top: 20px; }
  .bmv-steps { grid-template-columns: 1fr; }
  .bmv-inline { flex-direction: column; }
  .bmv .bmv-join { flex: 1 1 100%; }
  .bmv-round { grid-template-columns: 1fr; }
  .bmv-round__mid { grid-row: 1; grid-template-columns: auto auto auto; justify-content: space-between; width: 100%; }
  .bmv-squad--b { flex-direction: row; }
  .bmv-res-map > summary { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 12px; }
  .bmv-res-map__chev { display: none; }
  .bmv-rounds { padding: 4px 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .bmv *, .bmv *::before, .bmv *::after { animation: none !important; }
}
