/* Body Stats page — Composition + Measurement.
   Scoped to .bcx-* classes. Reuses exercise.css tokens:
   --bg, --surface, --border, --ink, --slate, --muted, --blue, --blue-dark, --blue-lt.
*/

/* ── Main scroll container ────────────────────────────────────────────────── */
#bs-main {
  overflow-y: auto;
  padding: 16px 0 96px;  /* top breathing room; bottom space for the FAB */
}

/* ── Mode tab bar (sliding "glass" pill — mirrors exercise.css .xl-tabbar) ────
   Pinned directly under the header as a flex sibling of the scroll container
   (#bs-main), so it stays put while the content scrolls. */
.bcx-tabbar {
  position: relative;            /* anchor for the sliding glass pill */
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 9px 12px;
  background: var(--white);
  border-bottom: 1px solid #eceef0;
}

/* ── sliding "glass" indicator ──
   A single frosted-blue pill that slides to sit behind the active tab.
   JS positions it (left/width). */
.bcx-tab-glass {
  position: absolute;
  top: 9px;                      /* matches .bcx-tabbar vertical padding */
  left: 0;
  width: 0;
  height: calc(100% - 18px);     /* tabbar height minus top+bottom padding */
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep, #0d47a1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35),
              0 4px 14px rgba(37, 99, 201, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: left 0.42s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.42s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.22s ease;
  z-index: 0;                    /* sits BEHIND the tab buttons (z-index:1) */
  overflow: hidden;
}
.bcx-tab-glass.ready { opacity: 1; }
.bcx-tab-glass::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
              transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%);
}
.bcx-tab-glass.sweep::after { animation: bcxGlassSweep 0.55s ease-out; }
@keyframes bcxGlassSweep {
  from { transform: translateX(-120%); }
  to   { transform: translateX(120%); }
}

.bcx-tabbtn {
  position: relative;            /* keep label/icon above the glass pill */
  z-index: 1;
  flex: 1 1 0;                   /* the two tabs split the bar evenly */
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 6px;
  border: none; border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.32s ease, background 0.18s ease;
}
.bcx-tabbtn:not(.on):hover { color: var(--blue); background: var(--blue-light); }
.bcx-tabicon { display: block; flex: 0 0 auto; }
.bcx-tabbtn-label {
  white-space: nowrap;
  font-size: 13px; font-weight: 600;
}
.bcx-tabbtn.on { color: #fff; }   /* the glass pill provides the blue fill */

/* ── Coming-soon placeholder (measurement, until built) ───────────────────── */
.bcx-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  margin: 0 16px;
}
.bcx-placeholder-icon {
  color: var(--muted);
  opacity: 0.5;
  margin-bottom: 16px;
}
.bcx-placeholder-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.bcx-placeholder-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ── View panels (mode switch) ────────────────────────────────────────────── */
.bcx-view { display: none; }
.bcx-view.on { display: block; }

/* ── Hero (flat blue) ─────────────────────────────────────────────────────── */
.bcx-hero {
  background: var(--blue);
  border-radius: 18px;
  padding: 18px;
  color: #fff;
  margin: 0 16px 14px;
}
.bcx-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.bcx-hero-label { font-size: 11px; opacity: .85; font-weight: 500; }
.bcx-hero-range { font-size: 10px; opacity: .75; }
.bcx-hero-val {
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
}
.bcx-hero-val span { font-size: 16px; font-weight: 500; opacity: .85; }
.bcx-hero-delta { font-size: 13px; font-weight: 600; margin-top: 6px; }
.bcx-hero-delta.dn { color: #c9f3e4; }
.bcx-hero-delta.up { color: #ffd2c2; }
.bcx-hero-delta.flat { opacity: .7; }

/* ── Composition 2×2 stat tiles ──────────────────────────────────────────── */
.bcx-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 16px 14px;
}
.bcx-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 13px;
  border-left: 3px solid var(--border);
}
.bcx-tile.lean { border-left-color: #0f6e56; }
.bcx-tile.mus  { border-left-color: #7f77dd; }
.bcx-tile.fat  { border-left-color: #d85a30; }
.bcx-tile.fatp { border-left-color: #993556; }
.bcx-tile-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.bcx-tile-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 3px;
}
.bcx-tile-val span { font-size: 12px; font-weight: 500; color: var(--muted); }
.bcx-tile-delta { font-size: 11px; margin-top: 2px; }
.bcx-tile-delta.good { color: #0f6e56; }
.bcx-tile-delta.bad  { color: #c0392b; }
.bcx-tile-delta.flat { color: var(--muted); }

/* ── Measurement 3-col tile grid ─────────────────────────────────────────── */
.bcx-ms-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 16px 14px;
}
.bcx-ms-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
}
.bcx-ms-tile-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.bcx-ms-tile-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 3px;
}
.bcx-ms-tile-val span { font-size: 10px; font-weight: 500; color: var(--muted); }
.bcx-ms-tile-delta { font-size: 10px; margin-top: 1px; }
.bcx-ms-tile-delta.good { color: #0f6e56; }
.bcx-ms-tile-delta.bad  { color: #c0392b; }
.bcx-ms-tile-delta.flat { color: var(--muted); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.bcx-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin: 0 16px 14px;
}
.bcx-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}

/* ── Metric pills ────────────────────────────────────────────────────────── */
.bcx-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bcx-pills::-webkit-scrollbar { display: none; }
.bcx-pill {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--slate);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.bcx-pill.on {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ── Chart ───────────────────────────────────────────────────────────────── */
.bcx-chart-wrap { position: relative; width: 100%; height: 180px; }
.bcx-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ── Weekly records accordion (composition) ──────────────────────────────── */
.bcx-rec { border-bottom: 1px solid var(--border); }
.bcx-rec:last-child { border-bottom: none; }
.bcx-rec-head {
  display: grid;
  grid-template-columns: 1fr auto auto 16px;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  cursor: pointer;
}
.bcx-rec-range { font-size: 12px; font-weight: 600; color: var(--ink); }
.bcx-rec-mini { text-align: right; }
.bcx-rec-mini-lab { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.bcx-rec-mini-val { font-size: 13px; font-weight: 600; color: var(--ink); }
.bcx-rec-chev { color: var(--muted); font-size: 9px; transition: transform .2s; }
.bcx-rec.open .bcx-rec-chev { transform: rotate(180deg); }
.bcx-rec-detail { display: none; padding: 0 0 12px; }
.bcx-rec.open .bcx-rec-detail { display: block; }
.bcx-rec-dl {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 5px 0;
  border-top: 1px dashed var(--border);
  color: var(--ink);
}
.bcx-rec-dl span:first-child { color: var(--slate); }

/* ── Measurement records accordion (2-col detail grid) ───────────────────── */
.bcx-ms-rec { border-bottom: 1px solid var(--border); }
.bcx-ms-rec:last-child { border-bottom: none; }
.bcx-ms-rec-head {
  display: grid;
  grid-template-columns: 1fr auto auto 16px;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  cursor: pointer;
}
.bcx-ms-rec-range { font-size: 12px; font-weight: 600; color: var(--ink); }
.bcx-ms-rec-mini { text-align: right; }
.bcx-ms-rec-mini-lab { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; }
.bcx-ms-rec-mini-val { font-size: 13px; font-weight: 600; color: var(--ink); }
.bcx-ms-rec-chev { color: var(--muted); font-size: 9px; transition: transform .2s; }
.bcx-ms-rec.open .bcx-ms-rec-chev { transform: rotate(180deg); }
.bcx-ms-rec-detail { display: none; padding: 0 0 12px; }
.bcx-ms-rec.open .bcx-ms-rec-detail { display: block; }
.bcx-ms-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.bcx-ms-dl {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 0;
  color: var(--ink);
}
.bcx-ms-dl span:first-child { color: var(--slate); }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.bcx-empty { font-size: 12px; color: var(--muted); padding: 8px 0; }

/* ── FAB speed dial ───────────────────────────────────────────────────────── */
.bcx-fab-wrap {
  /* Fixed to the viewport (centered within the 640px app frame), NOT absolute
     inside the scroll container — otherwise it anchors to the bottom of the
     scrolled content and the speed-dial actions land at the very bottom of the
     page. Mirrors exercise.css .xl-fabbar. */
  position: fixed;
  right: max(18px, calc(50% - 320px + 18px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.bcx-fab-wrap[hidden] { display: none; }

.bcx-fab-action {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px) scale(.9);
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.bcx-fab-wrap.open .bcx-fab-action {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
/* stagger */
.bcx-fab-wrap.open #bcx-fab-action-goal { transition-delay: .06s; }
.bcx-fab-wrap.open #bcx-fab-action-meas { transition-delay: .03s; }
.bcx-fab-wrap.open #bcx-fab-action-comp { transition-delay: 0s; }

.bcx-fab-lab {
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  white-space: nowrap;
}
.bcx-fab-mini {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  flex-shrink: 0;
}
.bcx-fab-mini svg { width: 20px; height: 20px; }
.bcx-fab-log  { background: var(--blue); }
.bcx-fab-meas { background: #d85a30; }
.bcx-fab-goal { background: #0f6e56; }

.bcx-fab-main {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37,99,201,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s;
  flex-shrink: 0;
}
.bcx-fab-wrap.open .bcx-fab-main { transform: rotate(45deg); }
.bcx-fab-main svg { width: 26px; height: 26px; stroke: #fff; }

/* ── Scrim ────────────────────────────────────────────────────────────────── */
.bcx-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 50;
}
.bcx-scrim.show { opacity: 1; pointer-events: auto; }

/* ── Floating sheets ──────────────────────────────────────────────────────────
   Detached card that floats above the bottom edge (mirrors the exercise
   manual-entry sheet): inset from the screen sides, lifted off the bottom by the
   safe-area, all corners rounded, with a lifted shadow. Slides up from below on
   open. */
.bcx-sheet {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 28px);
  max-width: 612px;
  transform: translateX(-50%) translateY(calc(100% + 28px));
  z-index: 60;
  background: var(--bg);
  border-radius: 18px;
  padding: 8px 16px 22px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .28);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  max-height: 84%;
  overflow-y: auto;
}
.bcx-sheet.show { transform: translateX(-50%) translateY(0); }
.bcx-grab {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  margin: 6px auto 14px;
}
.bcx-sheet h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 16px;
}

/* Sheet input grid */
.bcx-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-bottom: 16px;
}
.bcx-sheet-grid--three { grid-template-columns: repeat(3, 1fr); }
.bcx-field { display: flex; flex-direction: column; gap: 4px; }
.bcx-field--full { grid-column: 1 / -1; }
.bcx-field label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.bcx-field input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;  /* prevent iOS auto-zoom */
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  -webkit-appearance: none;
  box-sizing: border-box;
  outline: none;
}
.bcx-field input:focus { border-color: var(--blue); }

/* Sheet action row */
.bcx-sheet-actions { display: flex; gap: 8px; align-items: center; }
.bcx-btn-primary {
  flex: 2;
  background: var(--blue);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 12px;
  border-radius: 9px;
  cursor: pointer;
}
.bcx-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.bcx-btn-ghost {
  flex: 1;
  background: transparent;
  color: var(--slate);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 9px;
  cursor: pointer;
}
.bcx-status {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.bcx-status.success { color: #0f6e56; }
.bcx-status.error   { color: #c0392b; }

/* ── Goal option rows ─────────────────────────────────────────────────────── */
.bcx-goal-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.bcx-goal-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background .15s;
}
.bcx-goal-opt.on { border-color: var(--blue); background: #eff6ff; }
.bcx-goal-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
  transition: border-color .15s;
}
.bcx-goal-opt.on .bcx-goal-radio { border-color: var(--blue); }
.bcx-goal-opt.on .bcx-goal-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--blue);
}
.bcx-goal-optname { font-size: 14px; font-weight: 600; color: var(--ink); }
.bcx-goal-optdesc { font-size: 11px; color: var(--muted); }
