/* =============================================================
   FIZ — the tool "instrument". Shared layout for the calculators, layered
   on editorial.css + tools.css. No boxes: the dark spread IS the surface.
   Structure is carried by hairlines, type size and space, never by
   bordered panels (a stack of cards read as a form, not a product).

   Anatomy, mobile first:
     .inst__head      eyebrow, h1, lead
     .inst__grid
       .inst__readout the answer: label, one huge number, caption, facts,
                      and the tool's visual. First on mobile, so the page
                      opens on an answer. Sticky beside the controls on
                      desktop.
       .inst__sheet   the controls as a spec sheet: hairline rows, each
                      a small caps label over its control.
     .inst-dock       mobile only: a slim bar pinned to the bottom that
                      repeats the answer once the readout scrolls away
                      (instrument.js). Hidden when the readout is visible.

   Type: Archivo Black italic for the answer only. Every control is
   upright Inter. One red moment: the bloom behind the answer.
   ============================================================= */

.inst { padding-top: clamp(28px, 5vw, 72px); padding-bottom: clamp(56px, 8vw, 104px); }

/* ---------- head ---------- */
.inst__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px 48px; margin-bottom: clamp(20px, 4vw, 56px); }
.inst__head .h-hero { font-size: clamp(44px, 8vw, 96px); margin-top: 16px; }
.inst__head .lead { max-width: 420px; font-size: clamp(15px, 1.4vw, 18px); }

/* ---------- grid ---------- */
.inst__grid { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .inst__grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 72px; align-items: start; }
}

/* ---------- readout ---------- */
.inst__readout { position: relative; min-width: 0; padding-bottom: 28px; isolation: isolate; }
/* ⚠️ Must come after the base rule: `position: relative` above would win on
   source order and turn `top` into a plain 96px shove down the page. */
@media (min-width: 960px) { .inst__readout { position: sticky; top: 96px; } }
.inst__readout::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  left: -10%; top: -12%; width: 90%; height: 70%;
  background: radial-gradient(closest-side, rgba(255, 72, 72, .16), rgba(255, 72, 72, 0));
  filter: blur(8px);
}
.inst__k { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: #8A8A93; }
.inst__num { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; min-width: 0; }
.inst__num b {
  font-family: 'Archivo Black', 'Inter', sans-serif; font-style: italic; font-weight: 400;
  font-size: clamp(96px, 30vw, 184px); line-height: .84; letter-spacing: -0.03em; color: #fff;
  font-variant-numeric: tabular-nums;
}
.inst__num b.is-long { font-size: clamp(72px, 21vw, 150px); }
.inst__num span { font-size: clamp(20px, 2.4vw, 28px); font-weight: 800; color: #8A8A93; }
.inst__cap { margin-top: 16px; font-size: 16px; line-height: 1.5; color: #C4C4CC; max-width: 46ch; }

/* Facts: a flat row of labelled values split by hairlines. Never a box. */
.inst__facts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin-top: 26px; border-top: 1px solid #1F1F1F; }
.inst__facts > div { padding: 14px 12px 0 0; min-width: 0; }
.inst__facts > div + div { padding-left: 14px; border-left: 1px solid #1F1F1F; }
.inst__facts dt { font-size: 10.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: #71717A; }
.inst__facts dd { margin-top: 6px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; color: #fff; font-variant-numeric: tabular-nums; }
.inst__facts dd small { font-size: 12px; font-weight: 600; color: #71717A; margin-left: 3px; }

/* The visual (barbell, zone bar...) sits edge to edge under the answer. */
.inst__visual { margin-top: 28px; }

/* ---------- sheet (controls) ---------- */
.inst__sheet { min-width: 0; border-top: 1px solid #1F1F1F; }
.inst__row { padding: 22px 0; border-bottom: 1px solid #1F1F1F; min-width: 0; }
.inst__row-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.inst__row-h .inst__k { color: #A0A0A0; }
.inst__row-h small { font-size: 12px; color: #71717A; }
@media (min-width: 960px) { .inst__sheet { border-top: 0; } .inst__row:first-child { padding-top: 6px; } }

/* Segmented pill: units, machine, method. */
.inst-pill { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 100px; background: #141416; }
.inst-pill button {
  min-width: 64px; min-height: 38px; padding: 0 16px; border: 0; border-radius: 100px; background: transparent;
  color: #8A8A93; font-size: 14px; font-weight: 700; white-space: nowrap; transition: background .2s ease, color .2s ease;
}
.inst-pill button[aria-checked="true"], .inst-pill button[aria-selected="true"], .inst-pill button[aria-pressed="true"] { background: #fff; color: #0A0A0A; }
.inst-pill button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Stepper: a big number between two quiet round buttons. */
.inst-step { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; gap: 8px; }
.inst-step__btn {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid #2A2A2E; background: transparent; color: #fff;
  font-size: 24px; font-weight: 400; line-height: 1; display: grid; place-items: center;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.inst-step__btn:active { transform: scale(.93); background: #161618; }
.inst-step__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.inst-step__field { display: flex; align-items: baseline; justify-content: center; gap: 8px; min-width: 0; cursor: text; }
.inst-step__field input {
  width: 100%; min-width: 0; max-width: 5.4ch; border: 0; border-radius: 0; background: transparent; color: #fff; text-align: center;
  font: 800 clamp(36px, 10vw, 48px)/1.1 'Inter', sans-serif; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
  padding: 0 0 4px; border-bottom: 1px solid #2A2A2E; transition: border-color .2s ease;
}
.inst-step__field input:focus { outline: none; border-color: #fff; }
.inst-step__field input::placeholder { color: #3F3F46; }
.inst-step__unit { font-size: 15px; font-weight: 700; color: #71717A; }

/* Chips: filled, not outlined. The selected one is white. */
.inst-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.inst-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 15px; border: 0; border-radius: 100px; background: #141416; color: #D4D4D8;
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; touch-action: manipulation;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.inst-chip:active { transform: scale(.95); }
.inst-chip[aria-checked="true"], .inst-chip[aria-selected="true"], .inst-chip[aria-pressed="true"] { background: #fff; color: #0A0A0A; }
.inst-chip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.inst-chip small { font-size: 11px; font-weight: 600; opacity: .6; }

/* Switch row: the whole row is the button. */
.inst-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 0; border: 0; background: transparent; color: #fff; text-align: left; }
.inst-switch__t { display: flex; flex-direction: column; gap: 3px; }
.inst-switch__t b { font-size: 15px; font-weight: 700; }
.inst-switch__t small { font-size: 13px; color: #71717A; }
.inst-switch__s { flex: none; position: relative; width: 46px; height: 28px; border-radius: 100px; background: #26262A; transition: background .2s ease; }
.inst-switch__s::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #8A8A93; transition: transform .2s ease, background .2s ease; }
.inst-switch[aria-checked="true"] .inst-switch__s { background: #fff; }
.inst-switch[aria-checked="true"] .inst-switch__s::after { transform: translateX(18px); background: #0A0A0A; }
.inst-switch:focus-visible { outline: 2px solid #fff; outline-offset: 6px; border-radius: 4px; }

/* Tables below the grid: flat tap rows, full width. */
.inst__tables { display: grid; gap: 40px; margin-top: clamp(40px, 6vw, 72px); }
@media (min-width: 760px) { .inst__tables { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 56px; } }
.inst__tables .inst__k { margin-bottom: 12px; }

/* Tap rows: flat table rows (splits, zones, percentages). Selecting one
   fills it white; it is the only filled shape in a table. Use <button> for
   tappable rows, <div> for read-only ones. Columns: __k label, __v value
   (right), optional __s secondary value between them. The list hangs 12px
   into the gutter on both sides, so row text lines up with the content
   above while a selected row's fill gets room to breathe; the top rule
   hangs with it. */
.inst-rows { display: flex; flex-direction: column; margin: 0 -12px; border-top: 1px solid #1F1F1F; }
.inst-r {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 4px 16px;
  width: 100%; margin: 0; min-height: 50px; padding: 13px 12px;
  border: 0; border-bottom: 1px solid #1F1F1F; border-radius: 0; background: transparent; color: #D4D4D8; text-align: left;
  font: inherit; font-variant-numeric: tabular-nums; touch-action: manipulation; transition: background .15s ease;
}
.inst-r--3 { grid-template-columns: minmax(0, 1fr) auto auto; }
.inst-r__k { font-size: 15px; font-weight: 600; color: #A0A0A0; min-width: 0; }
.inst-r__k b { color: #fff; font-weight: 700; }
.inst-r__k small { display: block; margin-top: 3px; font-size: 13px; font-weight: 500; color: #71717A; line-height: 1.45; }
.inst-r__s { font-size: 14px; font-weight: 600; color: #71717A; text-align: right; }
.inst-r__v { font-size: 17px; font-weight: 800; color: #fff; text-align: right; white-space: nowrap; }
.inst-r__v small, .inst-r__s small { font-size: 12px; font-weight: 600; color: #71717A; margin-left: 2px; }
.inst-r.is-muted .inst-r__k, .inst-r.is-muted .inst-r__v { color: #52525B; }
.inst-r.is-on { background: #fff; border-radius: 12px; border-bottom-color: transparent; }
.inst-r.is-on .inst-r__k, .inst-r.is-on .inst-r__k b, .inst-r.is-on .inst-r__v, .inst-r.is-on .inst-r__s, .inst-r.is-on small { color: #0A0A0A; }
.inst-r:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
@media (hover: hover) { button.inst-r:hover:not(.is-on) { background: #111113; } }

/* ---------- dock (mobile) ---------- */
.inst-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 8, 9, .92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid #1F1F1F; color: #fff;
  transform: translateY(110%); transition: transform .25s ease;
}
.inst-dock.is-on { transform: none; }
.inst-dock__k { font-size: 10.5px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: #8A8A93; }
.inst-dock__sub { display: block; margin-top: 2px; font-size: 13px; color: #A0A0A0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
.inst-dock__v { font-family: 'Archivo Black', 'Inter', sans-serif; font-style: italic; font-size: 30px; line-height: 1; white-space: nowrap; }
.inst-dock__v small { font-family: 'Inter', sans-serif; font-style: normal; font-size: 13px; font-weight: 700; color: #8A8A93; margin-left: 4px; }
@media (min-width: 960px) { .inst-dock { display: none; } }

@media (hover: hover) {
  .inst-pill button:hover:not([aria-checked="true"]):not([aria-selected="true"]):not([aria-pressed="true"]) { color: #fff; }
  .inst-step__btn:hover { border-color: #52525B; }
  .inst-chip:hover:not([aria-checked="true"]):not([aria-selected="true"]):not([aria-pressed="true"]) { background: #1E1E21; color: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  .inst-pill button, .inst-step__btn, .inst-chip, .inst-switch__s, .inst-switch__s::after, .inst-dock, .inst-step__field input { transition: none; }
}
