/* ============================================================
 * components.css — Shared component primitives for SPA + standalone tools
 *
 * Single source of truth for:
 *   - Card primitives (.card, .card-head, .card-body, .card-title, .card-action, .card-body-flush)
 *   - Music canonical classes (.tool-card, .calc-card, .btn-p, .btn-g, .fi, .fl)
 *
 * Loaded by:
 *   - app-v2.html (SPA shell — alongside app.css)
 *   - components-v2.js (standalone tool wrapper — injected before tool-shared.css)
 *
 * IMPORTANT: when changing anything here, both contexts get the change automatically.
 * NEVER duplicate these rules in app.css or tool-shared.css.
 * ============================================================ */

/* ──────────────────────────────────────────────────────────────
   CARDS (canonical — used by finance, business, devtools, productivity, etc.)
   ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-inset);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
/* Cards that contain search + table directly (no card-head/card-body) */
.card > div:first-child:has(.input) { padding: 16px 20px 0; }
/* Tables inside cards scroll horizontally instead of clipping */
.card table.tbl { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl th, .tbl td { white-space: nowrap; }
.tbl-wrap table.tbl { display: table; overflow-x: visible; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 0.5px solid var(--border);
}
.card-title  { font-size: 14px; font-weight: 600; }
.card-action { font-size: 12px; font-weight: 500; color: var(--primary); cursor: pointer; transition: color .12s; }
.card-action:hover { color: var(--text); }
.card-body { padding: 20px; }
.card-body-flush { padding: 0; }

/* Mobile mirror — matches app-v2.html SPA mobile behavior */
@media (max-width: 768px) {
  .card-body { padding: var(--card-pad, 12px); }
  .card-head { padding: var(--card-pad, 12px) var(--card-pad, 12px) 0; }
}

/* ──────────────────────────────────────────────────────────────
   MUSIC TOOL CANONICAL CLASSES (.tool-card / .calc-card containers,
   .btn-p / .btn-g buttons, .fi / .fl form fields)
   Used by oscillators, chords, arpeggios, rhythm-maker, song-maker, piano,
   and any future music/synth tool that follows tools/admin/design-reference.html.
   ────────────────────────────────────────────────────────────── */

/* Music card containers — keep solid border + rounded corners */
.tool-card,
.calc-card {
  background: var(--surface-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tool-card > .card-head,
.calc-card > .card-head {
  padding: 14px 18px;
  background: var(--surface-alt, var(--surface-inset));
  border-bottom: 1px solid var(--border);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  display: block; /* override generic card-head flex layout above */
}
.tool-card > .card-body,
.calc-card > .card-body { padding: 18px; }
@media (max-width: 768px) {
  /* Music tools use nested panels (.osc-ctrl-block, .osc-viz, .pn-hint, .rhy-transport etc.)
     that each have their own padding. Card-body's horizontal padding goes to ZERO so
     those nested panels sit at the card edge — no compound padding stacking.
     Vertical padding stays small so the card-head doesn't butt against first panel. */
  .tool-card > .card-body,
  .calc-card > .card-body { padding: 8px 0; }
  .tool-card > .card-head,
  .calc-card > .card-head { padding: 10px 12px; font-size: 0.88rem; }
}

/* Music form labels + inputs */
.fl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.fi {
  width: 100%;
  padding: 10px 12px;
  min-height: var(--touch-min, 44px);
  background: var(--surface-inset);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--duration, .18s) var(--ease, ease);
}
.fi:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
select.fi { appearance: auto; -webkit-appearance: auto; }

/* Music primary + ghost buttons */
.btn-p {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  min-height: var(--touch-min, 44px);
  background: var(--primary);
  color: var(--text-on-primary, #fff);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--duration, .18s), transform var(--duration, .18s), filter var(--duration, .18s);
}
.btn-p:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-p:active { transform: translateY(0); filter: brightness(0.95); }
.btn-p:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  min-height: var(--touch-min, 44px);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--duration, .18s), color var(--duration, .18s), background var(--duration, .18s);
}
.btn-g:hover { border-color: var(--primary); color: var(--text); }
