/* ResCal — "blueprint grid" dark theme.
   Deep navy-slate surfaces, teal primary (#2dd4bf) + amber accent (#fbbf24)
   from site.config.json. Declared in both color-scheme modes so the palette
   is identical regardless of prefers-color-scheme and stylesheet order. */

:root {
  --bg: #0a0f1a;
  --surface: #101828;
  --surface-2: #182230;
  --text: #e6edf5;
  --text-dim: #8fa0b5;
  --border: #26334a;
  --rc-ok: #4ade80;
  --rc-warn: #fbbf24;
  --rc-bad: #fb7185;
  --rc-grid: rgba(45, 212, 191, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1a;
    --surface: #101828;
    --surface-2: #182230;
    --text: #e6edf5;
    --text-dim: #8fa0b5;
    --border: #26334a;
  }
}
html {
  color-scheme: dark;
}

/* ---------- calculator shell ---------- */
.rc {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 1.4rem 0 1.8rem;
  box-shadow: 0 12px 40px -26px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
@media (min-width: 54rem) {
  .prose .rc {
    width: min(60rem, calc(100vw - 2.5rem));
  }
}

/* ---------- mode tabs ---------- */
.rc-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(var(--rc-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--rc-grid) 1px, transparent 1px),
    var(--surface-2);
  background-size: 14px 14px;
}
.rc-tabs button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}
.rc-tabs button:hover {
  color: var(--text);
}
.rc-tabs button.on {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
}
.rc-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---------- shared source bar ---------- */
.rc-shared {
  padding: 0.85rem 1rem;
  border-bottom: 1px dashed var(--border);
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.rc-shared:not([hidden]) {
  display: flex;
}
.rc-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rc-field > span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.rc-shared input[type="text"],
.rc-panel input[type="text"],
.rc-panel select,
.rc-shared select {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.4rem 0.55rem;
  box-sizing: border-box;
}
.rc-shared input[type="text"] {
  width: 6.5rem;
}
.rc-shared input:focus,
.rc-panel input:focus,
.rc-panel select:focus,
.rc-shared select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.rc-x {
  color: var(--text-dim);
  font-weight: 700;
  padding-bottom: 0.45rem;
}
.rc-btn {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.rc-btn:hover {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
}
.rc-shared .rc-field-grow {
  flex: 1 1 13rem;
  min-width: 10rem;
}
.rc-shared select {
  width: 100%;
  max-width: 100%;
}
/* 44px-class tap targets on interactive controls (UX gate) */
.rc-tabs button,
.rc-btn,
.rc-seg button,
.rc-chipbtn,
.rc-shared input[type="text"],
.rc-panel input[type="text"],
.rc-shared select,
.rc-panel select {
  min-height: 44px;
}

/* ---------- panels ---------- */
.rc-panel {
  padding: 1rem;
}
.rc-panel > p:first-child {
  margin-top: 0;
}
.rc-big {
  font-size: 1.9rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0.15rem 0 0.3rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.rc-sub {
  font-size: 0.92rem;
  color: var(--text-dim);
  margin: 0.2rem 0 0.5rem;
  font-variant-numeric: tabular-nums;
}
.rc-note {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0.5rem 0 0;
}
.rc-note:empty {
  display: none;
}
.rc-chip:empty {
  display: none;
}
.rc-chip:not([hidden]) {
  display: inline-block;
}
.rc-chip {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  margin-top: 0.55rem;
  border: 1px solid color-mix(in srgb, var(--rc-warn) 45%, var(--border));
  color: var(--rc-warn);
  background: color-mix(in srgb, var(--rc-warn) 9%, var(--surface));
}

/* ---------- fit-mode segmented control ---------- */
.rc-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.rc-row .rc-field input[type="text"] {
  width: 6rem;
}
.rc-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  margin: 0 0 0.4rem;
}
.rc-seg button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.42rem 0.8rem;
  background: var(--surface-2);
  color: var(--text-dim);
  border: none;
  cursor: pointer;
}
.rc-seg button + button {
  border-left: 1px solid var(--border);
}
.rc-seg button.on {
  background: color-mix(in srgb, var(--primary) 16%, var(--surface-2));
  color: var(--primary);
}
.rc-seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ---------- percentage chips ---------- */
.rc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.5rem 0 0.8rem;
}
.rc-chipbtn {
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent);
  cursor: pointer;
}
.rc-chipbtn:hover {
  border-color: var(--accent);
}
.rc-panel input.rc-pct-in {
  width: 6rem;
}

/* ---------- tables (ladder + social spec) ---------- */
.rc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  margin-top: 0.55rem;
}
.rc-table th,
.rc-table td {
  text-align: left;
  padding: 0.36rem 0.55rem;
  border-bottom: 1px solid var(--border);
}
.rc-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}
.rc-table td {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rc-table tr:last-child td {
  border-bottom: none;
}
.rc-table tr.rc-source td {
  color: var(--primary);
  font-weight: 700;
}
.rc-table tr.rc-up td {
  color: var(--text-dim);
}
.rc-table tr.rc-up td:last-child {
  color: var(--rc-warn);
}
.rc-table tr.rc-down td:last-child {
  color: var(--rc-ok);
}
.rc-tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.rc-tablewrap .rc-table {
  min-width: 34rem;
}

/* ---------- social panel result cards ---------- */
.rc-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  margin: 0.7rem 0;
}
@media (min-width: 46rem) {
  .rc-cards {
    grid-template-columns: 1fr 1fr;
  }
}
.rc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.65rem 0.8rem;
}
.rc-card .rc-cardtitle {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.35rem;
}
.rc-card p {
  margin: 0.2rem 0;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.rc-spec {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0.2rem 0 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- will-it-fit verdict ---------- */
.rc-verdict {
  font-size: 1.7rem;
  font-weight: 750;
  margin: 0.3rem 0;
  color: var(--text);
}
.rc-detail {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.55;
  max-width: 46rem;
}

/* ---------- article polish ---------- */
.prose table {
  font-variant-numeric: tabular-nums;
}
.prose table code {
  white-space: nowrap;
}
/* Long inline code (FFmpeg expressions, formulas) must wrap, not overflow
   narrow viewports — anywhere-breaks only fire when the token can't fit. */
.prose code {
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .rc-panel {
    padding: 0.75rem;
  }
  /* font/padding may shrink for space, but min-height stays ≥44px — the
     tap-target floor applies on the viewport that needs it most. */
  .rc-tabs button {
    font-size: 0.76rem;
    padding: 0.65rem 0.65rem;
  }
  .rc-big {
    font-size: 1.5rem;
  }
  .rc-verdict {
    font-size: 1.35rem;
  }
}
