/* ============================================================
   CALC — Free Tools calculators (BPM ↔ frame, timecode).
   Sits on top of style.css: same blue page, condensed type,
   VT323 readouts, hairline rows like the tools list.
   ============================================================ */

.calc-back {
  display: inline-block; margin-bottom: 18px;
  font-family: var(--font-crt); font-size: 1.25rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.70);
  transition: color 0.25s;
}
.calc-back:hover, .calc-back:focus-visible { color: #fff; }
.calc-title { font-size: clamp(3.6rem, 8.5vw, 10rem); }

@media (min-width: 769px) {
  .calc { margin-right: clamp(150px, 14vw, 240px); }
}
.calc { margin-bottom: 64px; }

/* one numbered step per row, label left / controls right */
.calc-block {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  column-gap: 28px; row-gap: 14px;
  padding: 28px 0;
  border-top: 1px solid var(--line);
}
.calc-block:last-child { border-bottom: 1px solid var(--line); }
.calc-label {
  padding-top: 0.2em;
  font-family: var(--font-crt); font-size: 1.3rem; letter-spacing: 0.08em; line-height: 1.1;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.70);
}
.calc-body { min-width: 0; display: flex; flex-direction: column; gap: 18px; }

/* ── inputs ── */
.calc input {
  font: inherit; color: #fff; background: transparent;
  border: 0; border-bottom: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 0; outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s;
}
.calc input:focus { border-color: #fff; }
.calc input:focus-visible { box-shadow: none; }
.calc input[aria-invalid="true"] { border-color: #facc15; color: #facc15; }
.calc input::placeholder { color: rgba(255, 255, 255, 0.35); }
@media (pointer: fine) { .calc input { cursor: none; } }

.calc .calc-big {
  width: 100%; min-width: 0;
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(3.4rem, 8vw, 8rem); line-height: 1;
  padding: 0 0 4px;
}
.calc .calc-mid {
  width: 100%; min-width: 0;
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(2.2rem, 4.6vw, 4.6rem); line-height: 1;
  padding: 0 0 4px;
}
.calc .calc-small {
  width: 5.5em;
  font-family: var(--font-crt); font-size: 1.5rem; line-height: 1;
  padding: 2px 0;
}
.calc .calc-tc { width: 8.6em; }
.calc-unitwrap { display: flex; align-items: flex-end; gap: 14px; max-width: 760px; }
.calc-unitwrap .calc-big, .calc-unitwrap .calc-mid { flex: 1; }
.calc-unit {
  flex: none; padding-bottom: 0.7em;
  font-family: var(--font-crt); font-size: 1.4rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.70);
}
.calc-inline {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 14px;
  font-family: var(--font-crt); font-size: 1.3rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.85);
}

/* ── chips & buttons ── */
.calc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.calc-chip, .calc-btn {
  font-family: var(--font-crt); font-size: 1.3rem; letter-spacing: 0.06em; line-height: 1;
  text-transform: uppercase; white-space: nowrap;
  color: #fff; background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 2px;
  padding: 9px 12px; min-height: 40px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}
.calc-chip:hover, .calc-btn:hover,
.calc-chip:focus-visible, .calc-btn:focus-visible { border-color: #fff; background: rgba(255, 255, 255, 0.12); }
.calc-chip[aria-pressed="true"], .calc-btn[aria-pressed="true"], .calc-btn--main {
  background: #fff; color: var(--blue); border-color: #fff;
}
.calc-btn--main:hover, .calc-btn--main:focus-visible { background: #0d0d0d; color: #fff; border-color: #0d0d0d; }
.calc-chip:disabled, .calc-btn:disabled { opacity: 0.35; pointer-events: none; }
.calc-btn.is-hit { background: #facc15; color: #0d0d0d; border-color: #facc15; }
.calc-btn kbd {
  font: inherit; font-size: 0.85em; opacity: 0.6; margin-left: 6px;
}
.calc-chip small { font-size: 0.8em; opacity: 0.7; margin-left: 4px; }

/* ── readouts ── */
.calc-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
}
.calc-stat { background: var(--blue); padding: 16px 16px 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-width: 0; container-type: inline-size; }
.calc-stat--hero { background: #fff; color: var(--blue); grid-column: span 2; }
/* last cell stretches to the row end, so no empty gap shows */
.calc-stat:last-child { grid-column-end: -1; }
.calc-stat-num {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(2.2rem, 3.6vw, 3.6rem); line-height: 0.9;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
/* timecodes are long: size them to the cell so they never wrap */
.calc-stat--tc .calc-stat-num { font-size: clamp(1.5rem, 16cqi, 3.6rem); white-space: nowrap; overflow-wrap: normal; }
.calc-stat-label {
  font-family: var(--font-crt); font-size: 1.1rem; letter-spacing: 0.08em; line-height: 1.05;
  text-transform: uppercase; opacity: 0.75;
}

.calc-note {
  max-width: 62ch;
  font-size: 0.85rem; font-weight: 500; line-height: 1.6;
  color: rgba(255, 255, 255, 0.72);
}
.calc-note strong { color: #fff; font-weight: 700; }
.calc-status {
  font-family: var(--font-crt); font-size: 1.35rem; letter-spacing: 0.06em; line-height: 1.25;
  text-transform: uppercase; color: #fff;
}
.calc-status--warn { color: #facc15; }

/* metronome monitor: beat lamps + running counter */
.calc-monitor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px;
  padding: 14px 16px; background: #000; border-radius: 2px;
  font-family: var(--font-crt); font-size: 1.45rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.85);
  font-variant-numeric: tabular-nums;
}
.calc-lamps { display: flex; gap: 6px; }
.calc-lamp { width: 22px; height: 22px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 2px; }
.calc-lamp.on { background: #fff; border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, 0.7); }
.calc-lamp.on.down { background: #facc15; border-color: #facc15; box-shadow: 0 0 14px rgba(250, 204, 21, 0.8); }
.calc-readout { min-width: 0; }

/* beat map */
.calc-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.calc-tablewrap { max-height: 520px; overflow: auto; border-top: 1px solid var(--line); scrollbar-width: thin; }
.calc-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-crt); font-size: 1.3rem; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; text-align: left;
}
.calc-table th {
  position: sticky; top: 0; z-index: 1; background: var(--blue);
  font-weight: 400; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.65); padding: 10px 12px 8px 0;
  border-bottom: 1px solid var(--line);
}
.calc-table td { padding: 6px 12px 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.70); white-space: nowrap; }
.calc-table td.f { color: #fff; font-size: 1.5rem; }
.calc-table td.off { color: #facc15; }
.calc-table td.off.zero { color: rgba(255, 255, 255, 0.35); }
.calc-table tr.bar td { border-top: 1px solid rgba(255, 255, 255, 0.30); }
.calc-table tr.bar td:first-child { color: #fff; }
.calc-table tr.now td { background: #fff; color: var(--blue); }

/* ── responsive ── */
@media (max-width: 768px) {
  .calc-block { grid-template-columns: minmax(0, 1fr); padding: 24px 0; }
  .calc-label { padding-top: 0; }
  .calc .calc-big { font-size: clamp(3rem, 18vw, 5rem); }
  .calc .calc-mid { font-size: clamp(2rem, 10vw, 3rem); }
  .calc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-table { font-size: 1.15rem; }
  .calc-table td.f { font-size: 1.3rem; }
  .calc-table .opt { display: none; }
}
@media (pointer: coarse) {
  .calc-chip, .calc-btn { min-height: 44px; }
}
