/* calc/shell + calc/result — one card, five tools. Frames 3A and 3B. */

.di-calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-frame);
  box-shadow: var(--shadow-card);
  padding: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-5);
}

/* ---------- tab bar ---------- */
.di-calc__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
}
.di-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.di-tab {
  min-height: 38px; padding: 0 var(--sp-4);
  background: var(--surface-muted);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-family: var(--font-sans);
  font-size: 13.5px; font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.di-tab:hover { color: var(--ink); background: var(--border); }
.di-tab--on,
.di-tab--on:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.di-calc__worked { color: var(--text-muted); }

.di-calc__panel { display: block; }
.di-calc__panel[hidden] { display: none; }

/* Inputs left, result right. Source order is result-first so mobile pins the answer
   above the controls, which is what frame 3B shows. */
.di-calc__grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 420px;
  gap: var(--sp-8); align-items: start;
}

/* ---------- inputs ---------- */
.di-inputs { order: -1; display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.di-inputs__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4);
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--hairline);
}
.di-linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--font-mono); font-size: var(--fs-micro);
  letter-spacing: var(--ls-eyebrow); text-transform: uppercase;
  color: var(--accent);
}
.di-linkbtn:hover { text-decoration: underline; }
.di-calc__head { display: flex; flex-direction: column; gap: var(--sp-2); max-width: 68ch; }
.di-calc__head h2, .di-calc__head p { margin: 0; }

.di-input { display: flex; flex-direction: column; gap: var(--sp-2); }
.di-input__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.di-input__value { display: inline-flex; align-items: baseline; gap: 5px; }
.di-input__value input {
  width: 128px;
  min-height: 38px;
  padding: 0 var(--sp-3);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px; color: var(--ink); text-align: right;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-btn);
}
.di-input__value input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.di-input__unit {
  font-family: var(--font-mono); font-size: var(--fs-micro);
  color: var(--text-muted); white-space: nowrap; min-width: 62px;
}
.di-input .di-micro { margin: 0; }

.di-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; padding: 0;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.di-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(16,20,19,.25);
}
.di-range::-moz-range-thumb {
  width: 20px; height: 20px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
}
.di-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Segmented switch — for choices where a slider would be nonsense. */
.di-seg {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--surface-muted);
  border-radius: var(--r-btn);
  align-self: flex-start; flex-wrap: wrap;
}
.di-seg__opt {
  min-height: 34px; padding: 0 var(--sp-4);
  background: none; border: 0; border-radius: calc(var(--r-btn) - 3px);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: var(--fw-semibold);
  color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.di-seg__opt:hover { color: var(--ink); }
.di-seg__opt--on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

/* ---------- result ---------- */
.di-result {
  position: sticky; top: 88px;
  display: flex; flex-direction: column; gap: var(--sp-5);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-5);
  min-width: 0;
}
.di-result__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--hairline);
}
.di-result__headline { display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; }
.di-result__big {
  font-family: var(--font-sans);
  font-size: 54px; font-weight: var(--fw-semibold);
  letter-spacing: -.035em; line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.di-result__caption { margin: 0; color: var(--text-secondary); }

.di-metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.di-metric {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
}
.di-metric__value {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 17px; color: var(--ink);
}

/* ---------- acquisition bars ---------- */
.di-bars { display: flex; flex-direction: column; gap: var(--sp-2); }
.di-bar {
  display: grid; grid-template-columns: minmax(0, 1fr) 84px auto;
  align-items: center; gap: var(--sp-3);
}
.di-bar__label { color: var(--text-secondary); }
.di-bar__track {
  height: 6px; border-radius: var(--r-pill);
  background: var(--border);
  overflow: hidden;
}
.di-bar__fill {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width var(--dur) var(--ease);
}
.di-bar__value { white-space: nowrap; }
/* The purchase price is the base the fees sit on, not one of them — it gets no track,
   so the fee bars can be scaled against each other instead of all collapsing to a stub
   next to a seven-figure number. */
.di-bar--base {
  grid-template-columns: minmax(0, 1fr) auto;
  padding-bottom: var(--sp-2);
  border-bottom: 1px dashed var(--hairline);
}
.di-bar--total {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: var(--sp-2); padding-top: var(--sp-3);
  border-top: 1px solid var(--hairline);
}
.di-bar--total .di-bar__label { color: var(--ink); font-weight: var(--fw-semibold); }
.di-bar--total .di-bar__value { font-weight: var(--fw-semibold); }

.di-result__read {
  margin: 0; padding: var(--sp-4);
  background: var(--surface);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
}
.di-result__read strong { color: var(--ink); }
.di-result__cta { display: flex; flex-wrap: wrap; gap: var(--sp-3); }

.di-calc__foot { margin: 0; max-width: 86ch; }

@media (max-width: 1023px) {
  .di-calc { padding: var(--sp-4); }
  .di-calc__grid { grid-template-columns: 1fr; gap: var(--sp-6); }
  /* Result above the inputs, and it stops sticking so it does not eat the viewport. */
  .di-inputs { order: 0; }
  .di-result { position: static; }
  .di-result__big { font-size: 42px; }
  /* Frame 3B: the tab row swipes rather than wrapping to three lines. */
  .di-tabs {
    flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin-inline: calc(var(--sp-4) * -1); padding-inline: var(--sp-4);
  }
  .di-tabs::-webkit-scrollbar { display: none; }
  .di-tab { flex: 0 0 auto; }
  .di-calc__worked { display: none; }
}

@media (max-width: 640px) {
  .di-metrics { grid-template-columns: 1fr; }
  .di-bar { grid-template-columns: minmax(0, 1fr) auto; }
  /* No room for a track beside the numbers, so the bar runs under its own row. */
  .di-bar__track { grid-column: 1 / -1; }
  .di-result__cta .di-btn { flex: 1 1 100%; justify-content: center; }
  .di-input__value input { width: 108px; }
  .di-input__unit { min-width: 0; }
}
