/* ==========================================================
   BLITZ TRACKER — Controls & Bottom Bar
   Touch targets: 44×44px minimum
   Mobile-first: compact grid layout
   ========================================================== */

/* ── BOTTOM CONTROL BAR ── */

.bt-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  background: var(--bg-dark);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  flex-shrink: 0;
}

/* ── PRIMARY ROW: End Turn + Pause ── */

.bt-bar__primary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bt-bar__primary .bt-bar__btn:first-child {
  flex: 1;
  min-height: 52px;
  font-size: var(--text-lg);
  font-weight: 700;
}

/* ── SECONDARY: 6-column icon grid ── */

.bt-bar__secondary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}

/* Wide buttons (Turnover, TD Home, TD Away) span 2 columns */
.bt-bar__btn--wide {
  grid-column: span 2;
}

/* Icon-cell buttons stack icon over label */
.bt-bar__btn--icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: var(--space-1) 2px;
  min-height: 44px;
  font-size: var(--text-xs);
}

.bt-bar__btn--icon-cell .fas,
.bt-bar__btn--icon-cell .bt-bar__icon {
  font-size: var(--text-base);
  line-height: 1;
}

.bt-bar__btn--icon-cell .bt-bar__label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.7;
  line-height: 1;
}

/* Short label (H/A) for TD buttons — shown on mobile */
.bt-bar__label--short {
  display: inline;
}

/* The event count badge overlays on the icon-cell */
.bt-bar__btn--icon-cell .bt-evt-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 0.625rem;
  border-radius: 8px;
  line-height: 16px;
}

.bt-bar__btn--icon-cell {
  position: relative;
}

/* ── TD BUTTONS ── */

.bt-bar__btn--td {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.bt-bar__btn--td .fas {
  font-size: var(--text-sm);
}

/* ── TURNOVER BUTTON ── */

.bt-bar__btn--turnover {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--status-error, #ef4444);
  border-color: var(--status-error, #ef4444);
}

.bt-bar__btn--turnover:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ── MUTE (now part of grid) ── */

.bt-bar__mute {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.bt-bar__mute:hover {
  color: var(--gold-500);
  border-color: var(--gold-600);
}

.bt-bar__mute--muted {
  opacity: 0.5;
}

/* ── BUTTONS ── */

.bt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 48px;
  padding: 0 var(--space-8);
  font-family: var(--font-button);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: none;
  outline: none;
  appearance: none;
  background: none;
  border-radius: var(--radius-md);
  box-sizing: border-box;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), color 160ms var(--ease-out), opacity 160ms var(--ease-out);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  position: relative;
  overflow: visible;
  isolation: isolate;
  text-decoration: none;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}

.bt-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.03) 20%, rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, rgba(244, 215, 166, 0.18) 0%, var(--gold-600) 18%, var(--gold-700) 58%, var(--gold-900) 100%);
  border: 1px solid rgba(244, 215, 166, 0.42);
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(20, 11, 22, 0.58),
    0 6px 14px rgba(0, 0, 0, 0.32);
  pointer-events: none;
  z-index: -1;
  transition: filter 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

.bt-btn > * {
  position: relative;
  z-index: 1;
}

.bt-btn:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 3px;
}

.bt-btn:active {
  transform: translateY(1px);
}

.bt-btn:active::before {
  filter: brightness(0.85);
}

.bt-btn--primary {
  color: var(--text-on-gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.bt-btn--primary::before {
  filter: brightness(1);
}

.bt-btn--primary:hover {
  transform: translateY(-2px);
}

.bt-btn--primary:hover::before {
  filter: brightness(1.18) drop-shadow(0 4px 12px rgba(199, 150, 82, 0.5));
}

.bt-btn--secondary {
  color: var(--purple-300);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.bt-btn--secondary::before {
  filter: hue-rotate(255deg) saturate(0.9) brightness(0.82);
}

.bt-btn--secondary:hover {
  transform: translateY(-2px);
}

.bt-btn--secondary:hover::before {
  filter: hue-rotate(255deg) saturate(1.1) brightness(1) drop-shadow(0 4px 12px rgba(140, 80, 200, 0.4));
}

.bt-btn--ghost {
  color: var(--text-muted);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.bt-btn--ghost::before {
  filter: saturate(0.1) brightness(0.42) opacity(0.6);
}

.bt-btn--ghost:hover {
  color: var(--text-secondary);
  transform: translateY(-1px);
}

.bt-btn--ghost:hover::before {
  filter: saturate(0.18) brightness(0.55) opacity(0.75);
}

.bt-btn--danger {
  color: #ffd0cc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.bt-btn--danger::before {
  filter: hue-rotate(328deg) saturate(1.5) brightness(0.78);
}

.bt-btn--danger:hover {
  transform: translateY(-2px);
}

.bt-btn--danger:hover::before {
  filter: hue-rotate(328deg) saturate(1.8) brightness(0.95) drop-shadow(0 4px 12px rgba(180, 50, 50, 0.45));
}

.bt-btn--end-turn {
  flex: 1;
  font-size: var(--text-lg);
  height: 58px;
  min-height: 58px;
  min-width: 0;
  padding: 0 var(--space-10);
  color: var(--text-on-gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.bt-btn--end-turn::before {
  filter: brightness(1);
}

.bt-btn--end-turn:hover {
  transform: translateY(-2px);
}

.bt-btn--end-turn:hover::before {
  filter: brightness(1.18) drop-shadow(0 4px 12px rgba(199, 150, 82, 0.5));
}

.bt-btn--icon {
  width: 48px;
  min-width: 48px;
  padding: 0;
  font-size: var(--text-xl);
  color: var(--text-muted);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.bt-btn--icon::before {
  filter: saturate(0.1) brightness(0.42) opacity(0.6);
}

.bt-btn--icon:hover {
  color: var(--text-secondary);
  transform: translateY(-1px);
}

.bt-btn--icon:hover::before {
  filter: saturate(0.18) brightness(0.55) opacity(0.75);
}

.bt-btn--score {
  min-width: 48px;
  height: 48px;
  padding: 0 var(--space-4);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--gold-400);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.bt-btn--score::before {
  filter: saturate(0.22) brightness(0.65);
}

.bt-btn--score:hover {
  transform: translateY(-2px);
}

.bt-btn--score:hover::before {
  filter: saturate(0.35) brightness(0.8) drop-shadow(0 3px 8px rgba(168, 136, 125, 0.25));
}

.bt-btn--full {
  width: 100%;
}

.bt-btn--sm {
  height: 36px;
  min-height: 36px;
  font-size: var(--text-sm);
  padding: 0 var(--space-5);
}

.bt-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  pointer-events: none;
}

.bt-btn:disabled::before {
  filter: saturate(0.2) brightness(0.5);
}

/* ── MODAL OVERLAY ── */

.bt-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black-alpha-85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: var(--space-4);
}

.bt-modal__box {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.bt-modal__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--gold-500);
  margin: 0 0 var(--space-4);
  text-transform: uppercase;
}

.bt-modal__actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.bt-modal__actions .bt-btn {
  flex: 1;
}

/* ── EDIT TIME MODAL ── */

.bt-edit-time__section {
  margin-bottom: var(--space-4);
}

.bt-edit-time__tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.bt-edit-time__tab {
  flex: 1;
  min-height: 40px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bt-edit-time__tab--active {
  color: var(--text-on-gold);
  background: var(--gradient-gold);
  border-color: transparent;
}

.bt-edit-time__field {
  margin-bottom: var(--space-3);
}

/* ── CONFIRM MODAL ── */

.bt-confirm__text {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin: 0 0 var(--space-2);
  line-height: 1.5;
}

/* ── UNDO BUTTON ── */

.bt-bar__undo[disabled],
#btUndoBtn[disabled] {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
}

/* ── SETUP TOGGLES ── */

.bt-toggle-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bt-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.bt-toggle__check {
  width: 20px;
  height: 20px;
  accent-color: var(--gold-500);
  cursor: pointer;
}

.bt-toggle__label {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-secondary);
  user-select: none;
}

/* ── REDUCED MOTION ── */

@media (prefers-reduced-motion: reduce) {
  .bt-btn {
    transition-duration: 0.01ms !important;
  }

  .bt-btn:active {
    transform: none;
  }
}
