/* ============================================================
   HomeSifu Tools — Mobile UI layer  (shared by every tool page)
   Loaded AFTER each tool's own styles.css. Desktop is untouched:
   every rule here lives inside a max-width media query, except the
   collapse primitive (which defaults to open, so no-JS is safe).
   ============================================================ */

/* ---------- collapse primitive (open by default) ---------- */
.hs-collapse {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .28s cubic-bezier(.2,.8,.2,1);
}
.hs-collapse > .hs-collapse-inner { overflow: hidden; min-height: 0; }

/* toggles are a mobile affordance only */
.hs-toggle { display: none; }

/* the strip head wrapper is inert on desktop: children lay out as before */
.hs-strip-top { display: contents; }

/* the cap/target label is lifted out of the overflow:hidden track by tools-ui.js,
   so the gauge itself must be the positioning context (otherwise the label
   anchors to the card and lands on top of the big number) */
.gauge { position: relative; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 860px) {

  /* ---------- collapsed state ---------- */
  .hs-collapse.is-shut { grid-template-rows: 0fr; }

  .hs-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; min-height: 48px; padding: 12px 0;
    background: none; border: 0; cursor: pointer;
    font-family: var(--font-body); font-size: 14px; font-weight: 700;
    color: var(--ink-soft); text-align: left;
  }
  .hs-toggle .hs-chev {
    flex: none; width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface-sunk); color: var(--ink);
    display: grid; place-items: center; font-size: 12px; line-height: 1;
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
  }
  .hs-toggle[aria-expanded="true"] .hs-chev { transform: rotate(180deg); }

  /* ---------- 1. result card becomes a sticky strip ---------- */
  .app .card.sticky {
    order: -1;
    position: sticky; top: 0; z-index: 60;
    padding: 14px 18px 10px;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    background: var(--surface);
    /* keep it clear of the strip's own shadow while scrolling */
    margin-bottom: 14px;
  }
  /* label + number share one tight row */
  .app .card.sticky .hs-strip-top {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  }
  .app .card.sticky .result-head { margin: 0; }
  .app .card.sticky .result-head .label { font-size: 11px; letter-spacing: .1em; }
  .app .card.sticky .big-number {
    font-size: clamp(30px, 9vw, 40px); line-height: 1.05; margin: 0;
  }
  .app .card.sticky .verdict {
    margin-top: 8px; font-size: 12.5px; padding: 7px 12px;
  }
  /* gauge rides along in the head — compact, scale hidden */
  .app .card.sticky .gauge { margin: 10px 0 2px; }
  .app .card.sticky .gauge .scale { display: none; }
  .app .card.sticky .gauge .track { height: 10px; }
  .app .card.sticky .gauge .cap-label { top: 15px; font-size: 10px; }
  .app .card.sticky .gauge.has-cap-label { margin-bottom: 14px; }

  /* the strip's own toggle stays slim so the strip never eats the screen */
  .app .card.sticky > .hs-toggle {
    min-height: 44px; padding: 8px 0 4px; font-size: 13px; color: var(--muted);
  }
  .app .card.sticky > .hs-toggle .hs-chev { width: 22px; height: 22px; font-size: 11px; }

  /* the collapsible tail of the strip (breakdown, callouts) */
  .app .card.sticky .hs-collapse-inner > *:first-child { margin-top: 14px; }
  .app .card.sticky .breakdown { margin-top: 14px; }

  /* ---------- 2. input card: core fields first, rest behind a disclosure ---------- */
  .app .card:not(.sticky) { padding: 22px 18px; }
  .hs-more-wrap { border-top: 1px solid var(--line); margin-top: 18px; }
  .hs-more-wrap .hs-toggle { color: var(--ink); }
  .hs-more-wrap .section-label:first-of-type { margin-top: 4px; }

  /* ---------- 3. learn / faq sections collapse under their own heading ---------- */
  .learn.hs-section, .faq.hs-section { padding-top: 6px; }
  .hs-section > .hs-toggle {
    font-family: var(--font-display); font-weight: 800;
    font-size: 19px; letter-spacing: -.02em; color: var(--ink);
    min-height: 56px; border-top: 1px solid var(--line);
  }
  .hs-section .hs-collapse-inner > *:first-child { margin-top: 4px; }
  .hs-h-folded { display: none; }   /* the toggle carries this heading on mobile */
  .hs-section .cards-grid { margin-top: 16px; }

  /* ---------- 4. touch targets ---------- */
  .pillset { width: 100%; }
  .pillset button { flex: 1; min-height: 44px; font-size: 14px; padding: 10px 12px; }
  .btn, .add-btn { min-height: 48px; }
  .commit-row .rm-btn { min-height: 44px; }
  .slider-row input[type="range"] { height: 10px; }
  .slider-row input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; }
  .slider-row input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; }
  details summary { min-height: 48px; display: flex; align-items: center; }

  /* ---------- 5. breathing room ---------- */
  .hero { padding: 24px 0 6px; }
  .hero p.lede { margin-top: 12px; }
  .app { margin-top: 18px; gap: 14px; }
  .learn, .faq { margin-top: 28px; }
}

/* very small phones: keep the strip from eating the screen */
@media (max-width: 380px) {
  .app .card.sticky { padding: 12px 14px 8px; }
  .app .card.sticky .big-number { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .hs-collapse, .hs-toggle .hs-chev { transition: none; }
}
