/* B7 Tracker — core.css
 * Styles ONLY the inside of #b7-top (header strip) and #toasts (toast stack),
 * both built by js/core.js.
 *
 * base.css owns the boxes themselves: #b7-top is a sticky horizontal flex row
 * (align-items:center, gap:--s-3, safe-area padding) and #toasts is fixed under
 * the header with `#toasts > *` already sized and pointer-events:auto. Nothing
 * here touches either box, redefines a token, or re-declares base's keyframes.
 *
 * Primitives reused from base.css: .btn .btn.icon .btn.ghost .btn.on .chip
 * .chip.ok/.info/.warn/.bad .chip.on .dot .dot.live .num .sr-only.
 */

/* ================================================================== *
 * Header strip — inside #b7-top
 * ================================================================== */

#b7-top [hidden] { display: none !important; }

#b7-top .b7-ico {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
}

/* --- identity block: takes all the room the actions leave ---------- */

.b7-id {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.b7-id__line {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-width: 0;
}

.b7-race {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-1);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Back-to-hero pill; replaces the race name while another racer is shown.
   Rendered as button.chip.on, so base.css already gives it a 44px target. */
.b7-back {
  flex: 0 1 auto;
  min-width: 0;
  margin-right: auto;
  gap: var(--s-1);
}

.b7-back__txt {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#b7-top .b7-back .b7-ico {
  width: 16px;
  height: 16px;
}

.b7-age {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  flex: none;
  font-size: var(--fs-1);
  color: var(--fg-3);
  white-space: nowrap;
  transition: color var(--dur) ease;
}

.b7-age.is-old { color: var(--warn); }

#b7-top .b7-age__ico {
  width: 13px;
  height: 13px;
  opacity: 0.7;
}

.b7-conn { flex: none; }

/* --- racer identity: the biggest thing in the header --------------- */

.b7-racer {
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  margin: 0 0 0 calc(-1 * var(--s-2));
  padding: 2px var(--s-2);
  border: 0;
  border-radius: var(--r-2);
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur) ease;
}

@media (hover: hover) {
  .b7-racer:hover { background: var(--surface); }
}
.b7-racer:active { background: var(--surface-2); }
.b7-racer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.b7-racer__name {
  max-width: 100%;
  font-size: var(--fs-4);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.b7-racer.is-other .b7-racer__name { color: var(--accent-2); }

.b7-racer__sub {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  max-width: 100%;
  min-width: 0;
  font-size: var(--fs-1);
  line-height: 1.3;
  color: var(--fg-3);
}

.b7-bib {
  flex: none;
  font-weight: 600;
  color: var(--accent);
}

.b7-cat {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- actions ------------------------------------------------------- */

.b7-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.b7-refresh.is-spinning .b7-ico {
  transform-origin: 50% 50%;
  animation: b7-core-spin 0.85s linear infinite;
}

@keyframes b7-core-spin { to { transform: rotate(360deg); } }

/* Phones: the racer name wins the space it needs. */
@media (max-width: 380px) {
  .b7-cat { display: none; }
  .b7-actions { gap: 0; }
  .b7-racer__name { font-size: var(--fs-3); }
}

/* ================================================================== *
 * Toasts — inside #toasts (base.css positions the stack and sizes rows)
 * ================================================================== */

.b7-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--line-strong);
  border-left-width: 3px;
  border-left-color: var(--info);
  border-radius: var(--r-2);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  color: var(--fg);
  font-size: var(--fs-2);
  line-height: 1.35;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--dur) ease, transform var(--dur) ease;
}

.b7-toast.is-in       { opacity: 1; transform: translateY(0); }
.b7-toast.is-out      { opacity: 0; transform: translateY(-6px) scale(0.98); }
.b7-toast.is-dragging { transition: none; }

.b7-toast--ok   { border-left-color: var(--ok); }
.b7-toast--warn { border-left-color: var(--warn); }
.b7-toast--bad  { border-left-color: var(--bad); }
.b7-toast--info { border-left-color: var(--info); }

/* Alert toasts (checkpoint passed) stay until dismissed — mark them. */
.b7-toast.is-sticky {
  border-color: var(--accent-dim);
  border-left-color: var(--accent);
  background: var(--surface-2);
}

.b7-toast__icon {
  flex: none;
  margin-top: 1px;
  color: var(--info);
}
.b7-toast--ok   .b7-toast__icon { color: var(--ok); }
.b7-toast--warn .b7-toast__icon { color: var(--warn); }
.b7-toast--bad  .b7-toast__icon { color: var(--bad); }
.b7-toast.is-sticky .b7-toast__icon { color: var(--accent); }

#toasts .b7-ico {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
}

.b7-toast__body {
  flex: 1 1 auto;
  min-width: 0;
}

.b7-toast__msg {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.b7-toast__sub {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-1);
  color: var(--fg-2);
  overflow-wrap: anywhere;
}

/* 44px target, pulled into the toast padding so rows stay compact. */
.b7-toast__close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -12px -10px -12px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-2);
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur) ease, background-color var(--dur) ease;
}

@media (hover: hover) {
  .b7-toast__close:hover { color: var(--fg); background: var(--surface-2); }
}
.b7-toast__close:active { background: var(--bg-3); }
.b7-toast__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

#toasts .b7-toast__close .b7-ico {
  width: 17px;
  height: 17px;
}

/* base.css already zeroes --dur and neutralises animations under
   prefers-reduced-motion; this only stops the entry offset from moving. */
@media (prefers-reduced-motion: reduce) {
  .b7-toast,
  .b7-toast.is-in,
  .b7-toast.is-out { transform: none; }
  .b7-refresh.is-spinning .b7-ico { animation: none; }
}
