/* ============================================================
   v5.17.2 — Mobile broadcast layout + chat + visibility
   CRASH-SAFE: CSS-only. No intervals. No MutationObservers.

   Goals:
   A) Mobile becomes a clean broadcast stack:
      scorebar (sticky) → pitch (compact) → chat (main scroll)
   B) Chat is enlarged by default, never covers the pitch, sits
      above the mnav.
   C) Every on-pitch floating HUD card is banished on mobile.
   D) Speed indicator (⚡1×/2×/4×/TURBO) visible in the scorebar.
   E) Scorer feed becomes a thin horizontal chip strip under pitch.
   F) Mnav always shows labels.
   ============================================================ */

/* --- A) Kill every on-pitch floating card on mobile ---------------------- */
@media (max-width: 900px) {
  .hud-card { display: none !important; visibility: hidden !important; }
}

/* --- B) Mobile broadcast stack ------------------------------------------- */
@media (max-width: 768px) {
  /* Page is a vertical flex column */
  .broadcast {
    display: flex !important;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 72px;   /* room for mnav */
  }

  /* Scorebar sticks to the top */
  .scorebar {
    position: sticky;
    top: 0;
    z-index: 900;
    background: #050a13;
  }

  /* Subbar tucks under the scorebar — optional, keep compact */
  .subbar { padding: 4px 10px; font-size: 9px; }
  .subbar .weather { display: none; }

  /* Pitch: fixed compact height, NEVER scrolls away */
  .pitch-wrap {
    position: relative;
    aspect-ratio: auto;
    width: 100%;
    height: 44vh;          /* compact so chat has room */
    min-height: 280px;
    max-height: 380px;
    flex: 0 0 auto;
    overflow: hidden;
  }
  .pitch-wrap #pitch {
    width: 100% !important;
    height: 100% !important;
    display: block;
  }

  /* Momentum bar: thin strip at the top of the pitch */
  .momentum {
    position: absolute !important;
    top: 0; left: 0; right: 0;
    height: 20px !important;
    padding: 2px 8px !important;
    background: rgba(5,10,19,0.72);
    z-index: 5;
  }
  .mom-label { font-size: 9px !important; letter-spacing: 0.1em !important; }
  .mom-bar { height: 4px !important; }

  /* Scorer feed: horizontal chip strip BELOW the pitch, above chat */
  .scorer-feed {
    position: static !important;
    order: 3;              /* after pitch-wrap */
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 6px 10px !important;
    margin: 0 !important;
    background: #050a13;
    border-top: 1px solid rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 0 0 auto;
    max-height: 38px;
  }
  .scorer-feed::-webkit-scrollbar { display: none; }
  .scorer-feed:empty { display: none !important; }
  .scorer-item {
    flex: 0 0 auto !important;
    padding: 4px 10px !important;
    font-size: 10px !important;
    letter-spacing: 0.06em !important;
    white-space: nowrap;
    background: rgba(12,22,36,0.9) !important;
    backdrop-filter: none !important;
  }

  /* Corner banner: small pill at bottom-centre of pitch */
  .corner-overlay {
    top: auto !important;
    bottom: 6px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    font-size: 11px !important;
    padding: 5px 12px !important;
    letter-spacing: 0.1em !important;
    white-space: nowrap;
  }

  /* Stats: continues to live below the scorer feed but becomes a
     collapsible compact strip (already styled in v517-1.css). */

  /* Hide the dock (floating round buttons) everywhere on mobile. The
     labelled mnav is the control surface. */
  #dock, .dock { display: none !important; }
  #lfFab { display: none !important; }

  /* Mnav always visible when match chrome is up (cheap check: scorebar
     visible === we’re in a match-ish view) */
  .mnav { display: flex !important; }
  .mnav-btn .mnav-lbl { display: block !important; }
}

/* --- C) Chat becomes the main scrollable region ------------------------- */
@media (max-width: 768px) {
  /* Mount chat as the flex-1 main region, BELOW the pitch+feed, ABOVE mnav.
     livefeel.js appends #vflLiveFeel to body.appendChild with fixed position.
     Override that so it sits between the pitch block and the mnav and
     scrolls internally. */
  #vflLiveFeel.live-feel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    /* top pins BELOW the pitch+subbar+scorebar. Use a CSS var so we
       can adjust if the header grows. */
    top: calc(64px + 44vh + 44px) !important;   /* scorebar + pitch + subbar/feed */
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    border-radius: 12px 12px 0 0;
    transform: none !important;
    /* Default OPEN + ENLARGED */
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  /* Force-open state so it's always visible */
  #vflLiveFeel.live-feel.open,
  #vflLiveFeel.live-feel {
    display: flex !important;
  }
  #vflLiveFeel.live-feel .lf-head {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    background: rgba(5,10,19,0.96);
    z-index: 2;
  }
  #vflLiveFeel.live-feel .lf-odds {
    flex: 0 0 auto;
  }
  #vflLiveFeel.live-feel .lf-feed {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #vflLiveFeel.live-feel .lf-input {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    background: rgba(5,10,19,0.96);
  }

  /* Denser messages on mobile so more fit */
  .lf-msg {
    padding: 6px 10px !important;
    margin: 2px 8px !important;
    font-size: 12.5px !important;
    line-height: 1.32 !important;
  }
  .lf-msg .lf-who {
    font-size: 11px !important;
  }
  .lf-msg .lf-avatar img,
  .lf-msg .lf-avatar {
    width: 22px !important;
    height: 22px !important;
  }

  /* If collapsed, the user doesn't want it. Respect the collapse button
     but keep the panel pinned — just hide the feed + odds + input. */
  #vflLiveFeel.live-feel.collapsed .lf-feed,
  #vflLiveFeel.live-feel.collapsed .lf-odds,
  #vflLiveFeel.live-feel.collapsed .lf-input {
    display: none !important;
  }
  #vflLiveFeel.live-feel.collapsed {
    top: auto !important;
    height: auto !important;
    min-height: 0 !important;
  }
}

/* --- D) Turbo chip visible on mobile in the scorebar -------------------- */
@media (max-width: 640px) {
  /* style.css hides #turboChip on mobile. Un-hide, make it compact. */
  .sb-right > #turboChip {
    display: inline-flex !important;
    padding: 3px 8px !important;
    font-size: 10.5px !important;
    gap: 4px !important;
  }
  #turboChip .tc-val {
    font-size: 11px !important;
    font-weight: 800;
  }
  #turboChip.fire {
    animation: turboPulse 0.9s ease-in-out infinite alternate;
  }
  @keyframes turboPulse {
    from { box-shadow: 0 0 0 0 rgba(255,107,0,0.6); }
    to   { box-shadow: 0 0 12px 3px rgba(255,107,0,0.55); }
  }
}

/* --- E) Typing indicator (used by v517-2.js) ---------------------------- */
.lf-typing {
  padding: 4px 12px 6px !important;
  margin: 2px 8px !important;
  color: #6b7a8c;
  font-size: 11px;
  font-style: italic;
  opacity: 0.85;
  letter-spacing: 0.02em;
}
.lf-typing .lf-typing-dot {
  display: inline-block;
  width: 4px; height: 4px;
  background: #6b7a8c;
  border-radius: 50%;
  margin: 0 1px;
  animation: lfTypingDot 1.1s infinite ease-in-out both;
}
.lf-typing .lf-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.lf-typing .lf-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes lfTypingDot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
