/* ============================================================
   QuoTrak — free markup and margin calculators
   Depends on the tokens in shell.css and builder.css, which also holds
   the hero and article styles. The results card mirrors the app's
   Internal Workshop, with the same colour rule for margin.
   ============================================================ */

.calc-app { background: var(--app-bg); padding: 40px 0 48px; font-family: var(--app-font); color: var(--app-fg); }
.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; max-width: 920px; margin: 0 auto; align-items: stretch; }

.calc-card { background: var(--app-card); border: 1px solid var(--app-border); border-radius: 12px; padding: 24px; }
.calc-group { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.calc-group:last-child { margin-bottom: 0; }
.calc-group > legend, .calc-heading { display: block; font-size: 13px; font-weight: 600; color: var(--app-fg); margin: 0 0 10px; padding: 0; }

.calc-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--app-muted); border-radius: var(--app-radius); padding: 4px; }
.calc-mode { position: relative; }
.calc-mode input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.calc-mode span { display: block; padding: 9px 4px; border-radius: 6px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--app-muted-fg); }
.calc-mode input:checked + span { background: var(--white); color: var(--app-fg); box-shadow: 0 1px 2px rgba(8, 26, 48, 0.12); }
.calc-mode input:focus-visible + span { outline: 2px solid var(--app-primary-dark); outline-offset: 1px; }

.calc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.calc-row label { font-size: 14.5px; color: var(--app-fg); }
.calc-row[hidden] { display: none; }
.calc-input { position: relative; flex: 0 0 140px; }
.calc-input::before, .calc-input[data-unit]::after { position: absolute; top: 50%; transform: translateY(-50%); font-size: 14.5px; color: var(--app-muted-fg); pointer-events: none; }
.calc-input::before { left: 11px; }
.calc-input[data-unit="$"]::before { content: "$"; }
.calc-input[data-unit="%"]::after { content: "%"; right: 11px; }
.calc-input input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--app-border); border-radius: var(--app-radius); background: var(--white); font: inherit; font-size: 15px; color: var(--app-fg); font-variant-numeric: tabular-nums; }
.calc-input[data-unit="$"] input { padding-left: 23px; }
.calc-input[data-unit="%"] input { padding-right: 26px; }
.calc-input input:focus { outline: 2px solid var(--app-primary); outline-offset: 0; border-color: var(--app-primary); }

.calc-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; margin-top: 2px; border-top: 1px solid var(--app-border-soft); font-size: 14.5px; font-weight: 600; }
.calc-total output { font-variant-numeric: tabular-nums; }

.calc-results { background: var(--app-sidebar); border-radius: 12px; padding: 24px; color: var(--white); display: flex; flex-direction: column; }
.calc-results .calc-heading { color: rgba(255, 255, 255, 0.65); text-transform: uppercase; letter-spacing: 0.6px; font-size: 12px; margin-bottom: 14px; }
.calc-price { font-size: clamp(34px, 5vw, 44px); font-weight: 700; line-height: 1.1; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.calc-price-label { font-size: 13.5px; color: rgba(255, 255, 255, 0.65); margin: 2px 0 20px; }
.calc-stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0 0 20px; }
.calc-stats dt { font-size: 12.5px; color: rgba(255, 255, 255, 0.65); margin-bottom: 3px; }
.calc-stats dd { margin: 0; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.calc-gauge { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); margin-bottom: 14px; }
.calc-gauge-fill { display: block; height: 100%; border-radius: 4px; background: rgba(255, 255, 255, 0.5); transition: width 0.2s ease; }
.calc-gauge-tick { position: absolute; top: -3px; width: 2px; height: 14px; margin-left: -1px; background: var(--white); border-radius: 1px; }
.calc-equals { font-size: 15px; font-weight: 600; margin: 0 0 4px; min-height: 1.4em; }
.calc-hint { font-size: 14px; line-height: 1.45; margin: 0; color: rgba(255, 255, 255, 0.8); }
.calc-next { margin-top: auto; padding-top: 20px; font-size: 14px; font-weight: 600; color: var(--app-primary); text-decoration: underline; text-underline-offset: 3px; }
.calc-next:hover { color: var(--white); }
.is-good .calc-gauge-fill { background: #4ade80; }
.is-good [data-out="margin"], .is-good .calc-hint { color: #4ade80; }
.is-thin .calc-gauge-fill { background: #fcd34d; }
.is-thin [data-out="margin"], .is-thin .calc-hint { color: #fcd34d; }
.is-low .calc-gauge-fill { background: #f87171; }
.is-low [data-out="margin"], .is-low .calc-hint { color: #f87171; }
@media (prefers-reduced-motion: reduce) { .calc-gauge-fill { transition: none; } }

.calc-note { max-width: 920px; margin: 14px auto 0; font-size: 13.5px; color: var(--app-muted-fg); text-align: center; }

.calc-table { width: 100%; border-collapse: collapse; margin: 14px 0 22px; font-variant-numeric: tabular-nums; }
.calc-table th, .calc-table td { padding: 9px 12px; border-bottom: 1px solid var(--gray-200); font-size: 15.5px; text-align: left; color: var(--gray-700); }
.calc-table th { color: var(--navy); font-weight: 700; }
.calc-example { background: var(--gray-50); border-left: 3px solid var(--orange); padding: 14px 18px; border-radius: 0 8px 8px 0; margin: 0 0 18px; }
.calc-example p { margin-bottom: 6px; }
.calc-example p:last-child { margin-bottom: 0; }

@media (max-width: 760px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr); }
  .calc-card, .calc-results { padding: 20px 16px; }
  .calc-input { flex-basis: 128px; }
}
