/* ===========================================================================
   BUG HUNT — an editor window, a draining clock, and a review drawer
   =========================================================================== */

.bh-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 16px 16px;
  overflow: hidden;
}

/* --- Editor window --- */
.bh-window {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #0E1120, #0A0C18);
  box-shadow: 0 0 0 1px var(--arena-line-strong), 0 30px 60px -30px rgba(0, 0, 0, 0.9),
              0 0 50px -30px var(--game-glow);
  overflow: hidden;
}

.bh-window.enter {
  animation: bh-enter 0.38s var(--ease);
}

@keyframes bh-enter {
  from { opacity: 0.2; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.bh-titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--arena-line);
  flex-shrink: 0;
}

.bh-dots {
  display: flex;
  gap: 6px;
}

.bh-dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #FF5F57;
}

.bh-dots i:nth-child(2) { background: #FEBC2E; }
.bh-dots i:nth-child(3) { background: #28C840; }

.bh-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 -2px 0 var(--game-accent);
  min-width: 0;
}

.bh-tab__name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--arena-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bh-tab__lang {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  color: #05060D;
  background: #F7DF1E;
}

.bh-tab__lang[data-lang="CSS"] { background: #2EA8FF; }
.bh-tab__lang[data-lang="HTML"] { background: #FF7A45; }
.bh-tab__lang[data-lang="PY"] { background: #FFD447; }
.bh-tab__lang[data-lang="JSX"] { background: #61DAFB; }
.bh-tab__lang[data-lang="SQL"] { background: #C792EA; }

.bh-level {
  margin-left: auto;
  display: flex;
  gap: 3px;
}

.bh-level i {
  width: 16px;
  height: 5px;
  border-radius: 3px;
  background: var(--arena-line-strong);
}

.bh-level i.on {
  background: var(--game-accent);
  box-shadow: 0 0 8px var(--game-glow);
}

/* --- Clock drains along the top edge of the code --- */
.bh-clock {
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.bh-clock__fill {
  display: block;
  height: 100%;
  transform-origin: left;
  background: linear-gradient(90deg, var(--game-accent), #9DB2FF);
  box-shadow: 0 0 14px var(--game-glow);
  transition: transform 0.25s linear, background 0.3s;
}

.bh-clock__fill[data-tone="warn"] { background: var(--arena-warn); box-shadow: 0 0 14px rgba(255, 201, 77, 0.6); }
.bh-clock__fill[data-tone="bad"] { background: var(--arena-bad); box-shadow: 0 0 14px rgba(255, 84, 104, 0.7); }

/* --- Code --- */
.bh-code {
  flex: 1;
  overflow: auto;
  padding: 16px 0 24px;
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 1.6vw, 0.98rem);
  line-height: 2;
  color: var(--syn-punc);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  user-select: none;
}

.bh-line {
  display: flex;
  min-width: max-content;
  padding-right: 24px;
  transition: background 0.3s var(--ease);
}

.bh-line__no {
  width: 3.2em;
  padding-right: 1.2em;
  text-align: right;
  color: var(--arena-ink-3);
  opacity: 0.6;
  flex-shrink: 0;
}

.bh-line__code {
  white-space: pre;
}

.bh-line.hinted {
  background: linear-gradient(90deg, rgba(255, 201, 77, 0.14), transparent 80%);
  box-shadow: inset 3px 0 0 var(--arena-warn);
}

.bh-line.hinted .bh-line__no {
  color: var(--arena-warn);
  opacity: 1;
}

/* Every token is a target. */
.tok {
  position: relative;
  border-radius: 5px;
  padding: 3px 1px;
  margin: -3px -1px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}

@media (hover: hover) {
  .tok:hover {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
  }
}

.tok--kw   { color: var(--syn-kw); }
.tok--str  { color: var(--syn-str); }
.tok--num  { color: var(--syn-num); }
.tok--fn   { color: var(--syn-fn); }
.tok--com  { color: var(--syn-com); font-style: italic; }
.tok--tag  { color: #FF7A90; }
.tok--punc { color: var(--syn-punc); }

.tok.wrong {
  animation: bh-wrong 0.45s var(--ease);
}

@keyframes bh-wrong {
  0%, 50% { background: rgba(255, 84, 104, 0.35); box-shadow: 0 0 0 1px var(--arena-bad); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(2px); }
}

.tok.fixed {
  color: #05060D;
  background: var(--arena-good);
  box-shadow: 0 0 22px rgba(59, 240, 160, 0.6);
  animation: bh-fixed 0.5s var(--ease-spring);
}

@keyframes bh-fixed {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.tok.revealed {
  color: #fff;
  background: rgba(255, 84, 104, 0.35);
  box-shadow: 0 0 0 1px var(--arena-bad);
  text-decoration: line-through wavy var(--arena-bad);
}

/* --- Bottom bar --- */
.bh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.bh-brief {
  font-size: 0.9rem;
  color: var(--arena-ink-2);
  min-width: 0;
}

.bh-brief strong { color: var(--arena-ink); }
.bh-brief.bad strong { color: var(--arena-bad); }

.bh-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.bh-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-full);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--arena-ink-2);
  background: var(--arena-chip);
  border: 1px solid var(--arena-line);
  transition: color var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}

.bh-action svg { width: 16px; height: 16px; }
.bh-action small { font-family: var(--font-mono); font-size: 0.7rem; color: var(--arena-ink-3); }

.bh-action:hover:not(:disabled) {
  color: var(--arena-ink);
  border-color: var(--game-accent);
}

.bh-action:disabled {
  opacity: 0.35;
  cursor: default;
}

/* --- Review drawer --- */
.bh-review {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: rgba(10, 13, 26, 0.96);
  border: 1px solid rgba(59, 240, 160, 0.4);
  box-shadow: 0 -20px 60px -10px rgba(0, 0, 0, 0.8), 0 0 40px -10px rgba(59, 240, 160, 0.35);
  transform: translateY(calc(100% + 24px));
  opacity: 0;
  transition: transform 0.42s var(--ease), opacity 0.3s var(--ease);
  pointer-events: none;
}

.bh-review.open {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.bh-review__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bh-review__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.bh-review__title b {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--arena-good);
  text-shadow: 0 0 20px rgba(59, 240, 160, 0.5);
}

.bh-review__title b.skipped {
  color: var(--arena-warn);
  text-shadow: none;
}

.bh-review__title span {
  font-size: 0.82rem;
  color: var(--arena-ink-3);
}

.bh-review__diff {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.bh-review__diff del,
.bh-review__diff ins {
  padding: 3px 9px;
  border-radius: 6px;
  text-decoration: none;
}

.bh-review__diff del {
  color: #FFB3BC;
  background: rgba(255, 84, 104, 0.16);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 84, 104, 0.8);
}

.bh-review__diff ins {
  color: #B8FFDD;
  background: rgba(59, 240, 160, 0.14);
}

.bh-review__arrow {
  color: var(--arena-ink-3);
}

.bh-review__text {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--arena-ink-2);
}

.bh-review__text code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--arena-ink);
}

@media (max-width: 760px) {
  .bh-stage { padding: 4px 10px 10px; gap: 8px; }
  .bh-titlebar { padding: 8px 10px; gap: 10px; }
  .bh-dots { display: none; }
  .bh-code { font-size: 0.8rem; line-height: 2.1; padding: 12px 0 18px; }
  .bh-line__no { width: 2.4em; padding-right: 0.8em; }
  .bh-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .bh-brief { text-align: center; font-size: 0.84rem; }
  .bh-actions { justify-content: center; }
  .bh-action { flex: 1; justify-content: center; height: 44px; }
  .bh-review { left: 10px; right: 10px; bottom: 10px; padding: 14px; }
  .tok { padding: 5px 2px; margin: -5px -2px; }
}
