/* Responsive overrides for CABRI BPP Dashboard
   Linked AFTER the inline <style> so these rules win at equal specificity. */

@media (max-width: 768px) {
  html, body { height: auto; }

  body {
    flex-direction: column;
    overflow: auto;
  }

  /* Sidebar becomes a stacked, collapsible-feeling panel on top. */
  #sidebar {
    width: 100%;
    max-height: 45vh;
    overflow-y: auto;
    flex-shrink: 0;
  }

  .sb-filter { margin-top: 12px; }
  .cpills { max-height: 80px; }

  /* Main column flows naturally and contributes to page scroll. */
  #main {
    width: 100%;
    overflow: visible;
    min-height: 0;
  }

  #topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
  }

  #search-box { width: 100%; order: 3; }
  .view-toggle { order: 2; }
  .tb-title { font-size: 15px; }

  #content {
    overflow: visible;
    padding: 16px 14px 40px;
  }

  /* Hero: stack and shrink. */
  .hero { padding: 20px 18px; gap: 12px; }
  .hero-title { font-size: 20px; }
  .hero-body { font-size: 13.5px; max-width: 100%; }
  .hero-stats { flex-wrap: wrap; gap: 14px; width: 100%; }
  .hstat-n { font-size: 30px; }

  /* Section header */
  .sec-title { font-size: 21px; }
  .sec-desc { font-size: 13.5px; }
  .stats-row { flex-wrap: wrap; }

  /* Tighter card grids on small screens. */
  .theme-grid { grid-template-columns: 1fr; gap: 9px; }
  .compare-grid { grid-template-columns: 1fr 1fr; }

  /* Chart bars: drop the fixed-width label/code columns so rows can breathe. */
  .bar-row { flex-wrap: wrap; }
  .bar-lbl {
    width: 100%;
    text-align: left;
    white-space: normal;
    overflow: visible;
  }
  .bar-codes {
    width: 100%;
    justify-content: flex-start;
  }
  .bar-main { width: 100%; }

  /* Question header: let actions wrap instead of clipping. */
  .q-header { flex-wrap: wrap; }
  .q-actions { margin-left: 0; margin-top: 6px; flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .compare-grid { grid-template-columns: 1fr; }
  .hero-stats { gap: 10px; }
  .hstat-n { font-size: 26px; }
  #sidebar { max-height: 40vh; }
}

/* ── Scroll hint (scroll-hint.js) ─────────────────────────────
   Round chevron shown at the bottom of the content pane while there is more
   to scroll inside the iframe. */
#main { position: relative; }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 40, 60, .28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s, visibility 0s linear .2s, background .15s;
}
.scroll-hint.is-visible {
  opacity: .92;
  visibility: visible;
  transform: none;
  transition: opacity .2s, transform .2s, visibility 0s, background .15s;
  animation: scroll-hint-nudge 2.4s ease-in-out 1s 3;
}
.scroll-hint:hover { opacity: 1; background: var(--navy2); }
.scroll-hint:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }

@keyframes scroll-hint-nudge {
  0%, 60%, 100% { transform: none; }
  30% { transform: translateY(5px); }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint, .scroll-hint.is-visible { animation: none; transition: none; }
}
/* On phones the pane is not a separate scroller (the page scrolls), so the
   hint is not needed. */
@media (max-width: 768px) {
  .scroll-hint { display: none; }
}
