/*
 * Blue Wave Baseball — SWING TIMING BAR (experimental overlay, v1)
 * Every selector is namespaced .tbar*. Nothing here touches existing rules.
 * To remove: drop the <link> in index.html and delete this file.
 */

.tbar {
  --tbar-zone-opacity: 1;
  --tbar-cyan: 140, 233, 255;
  --tbar-gold: 255, 195, 52;

  position: absolute;
  left: 50%;
  bottom: 1.35rem;
  z-index: 6;
  width: min(32rem, 48%);
  transform: translateX(-50%);
  pointer-events: none;
  font-family: inherit;
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.tbar[data-state="ready"],
.tbar[data-state="live"],
.tbar[data-state="frozen"] { opacity: 1; }

.tbar[data-state="idle"] { opacity: 0.4; }

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

.tbar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  padding: 0 0.1rem;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.tbar-stats { color: rgba(var(--tbar-cyan), 0.92); }
.tbar-window { color: rgba(255, 255, 255, 0.62); }

/* ---- track ---- *
 * .tbar-rail is the unclipped positioning context. The track clips the zone
 * fills to its rounded corners; the marks layer sits above it so the cursor
 * and pin can overhang top and bottom without being cut off.
 */

.tbar-rail { position: relative; }

.tbar-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tbar-track {
  position: relative;
  height: 1.7rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0.3rem;
  background: rgba(5, 30, 43, 0.82);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.tbar-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: var(--tbar-zone-opacity);
  transition: opacity 260ms ease-out;
}

/* Nested largest to smallest: contact > deep > barrel >= home run. */
.tbar-contact {
  background: rgba(var(--tbar-cyan), 0.2);
  box-shadow: inset 1px 0 0 rgba(var(--tbar-cyan), 0.5), inset -1px 0 0 rgba(var(--tbar-cyan), 0.5);
}

.tbar-deep { background: rgba(var(--tbar-cyan), 0.34); }

.tbar-barrel { background: rgba(255, 255, 255, 0.42); }

/* Brightest in the middle: home-run odds scale with closeness to centre.
   Exempt from the heat dimming - this is the thing you are aiming at. */
.tbar-hr {
  opacity: 1 !important;
  background: radial-gradient(ellipse at center,
    rgba(var(--tbar-gold), 0.98) 0%,
    rgba(var(--tbar-gold), 0.72) 45%,
    rgba(var(--tbar-gold), 0.4) 100%);
  box-shadow: 0 0 10px rgba(var(--tbar-gold), 0.5);
}

.tbar-centre {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.85);
  transform: translateX(-50%);
}

/* ---- live cursor ---- */

.tbar-cursor {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 50%;
  width: 3px;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9), 0 0 16px rgba(var(--tbar-cyan), 0.7);
  transform: translateX(-50%);
  opacity: 0;
}

/* ---- post-swing pin ---- */

.tbar-pin {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 50%;
  width: 3px;
  background: #ffffff;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 120ms ease-out;
}

.tbar-pin::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: inherit;
  transform: translateX(-50%);
}

.tbar-pin[data-verdict="hr"]     { background: rgb(var(--tbar-gold)); box-shadow: 0 0 12px rgba(var(--tbar-gold), 0.95); }
.tbar-pin[data-verdict="barrel"] { background: #ffffff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); }
.tbar-pin[data-verdict="deep"]   { background: rgb(var(--tbar-cyan)); box-shadow: 0 0 10px rgba(var(--tbar-cyan), 0.8); }
.tbar-pin[data-verdict="base"]   { background: rgba(var(--tbar-cyan), 0.8); }
.tbar-pin[data-verdict="miss"]   { background: #ff4923; box-shadow: 0 0 10px rgba(255, 73, 35, 0.8); }

/* ---- verdict line ---- */

.tbar-verdict {
  height: 1rem;
  margin-top: 0.28rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 140ms ease-out, transform 140ms ease-out;
}

.tbar-verdict.show { opacity: 1; transform: translateY(0); }
.tbar-verdict.v-hr     { color: rgb(var(--tbar-gold)); }
.tbar-verdict.v-barrel { color: #ffffff; }
.tbar-verdict.v-deep   { color: rgb(var(--tbar-cyan)); }
.tbar-verdict.v-base   { color: rgba(var(--tbar-cyan), 0.85); }
.tbar-verdict.v-miss   { color: #ff7a5e; }

/* ---- mode toast ---- */

.tbar-toast {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  padding: 0.3rem 0.6rem;
  border-radius: 0.3rem;
  background: rgba(5, 30, 43, 0.92);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.tbar-toast.show { opacity: 1; }

/* The toast must stay readable even when the bar itself is hidden. */
.tbar[data-mode="off"] { opacity: 1 !important; }
.tbar[data-mode="off"] .tbar-head,
.tbar[data-mode="off"] .tbar-track,
.tbar[data-mode="off"] .tbar-verdict { opacity: 0; }

/* ---- responsive: clear the swing button on narrow fields ---- */

@media (max-width: 920px) {
  .tbar {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 4.6rem;
    width: auto;
    transform: none;
  }
  .tbar-toast { transform: translateX(-50%); }
}

@media (max-width: 560px) {
  .tbar { bottom: 4.1rem; }
  .tbar-track { height: 1.4rem; }
  .tbar-head { font-size: 0.6rem; }
  .tbar-verdict { font-size: 0.64rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tbar,
  .tbar-zone,
  .tbar-verdict,
  .tbar-toast { transition: none; }
}
