/* ============================================================================
   formula-calc.css  -  Worked-formula calculators (see formula-calc.js)
   Colour tokens come from the shared :root palette of each lesson page; the
   per-term colours are the fc-1..fc-6 formula palette in course-components.css.
   ============================================================================ */
.fx-calc {
  margin: 14px 0 28px; padding: 14px 16px; text-align: left;
  background: linear-gradient(180deg, var(--very-light-teal, #E6F3F0), #fff);
  border: 1px solid #d6e8e4; border-radius: 10px;
  font-family: 'Open Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.55; color: var(--text, #2D3436);
}
.fx-calc * { box-sizing: border-box; }
.fx-calc .fx-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 4px; }
.fx-calc .fx-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.fx-calc .fx-kicker { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: #5a6a68; font-weight: 700; }
.fx-calc h5 { font-size: 14.5px; color: var(--dark-teal, #065C50); font-weight: 700; margin: 0; line-height: 1.35; }
.fx-calc .fx-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.fx-calc .fx-btns button {
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 14px;
  border: 1px solid var(--teal, #0B7B6B); background: #fff; color: var(--dark-teal, #065C50); cursor: pointer; line-height: 1.3;
}
.fx-calc .fx-btns button:hover { background: var(--very-light-teal, #E6F3F0); }
.fx-calc .fx-btns button.active { background: var(--teal, #0B7B6B); color: #fff; }
.fx-calc .fx-lead { font-size: 12.5px; color: var(--text-light, #555); margin: 0 0 10px; }

/* introduction at the top of a calculator (def.intro, rendered by
   formula-calc.js) or of another interactive tool on the lesson page
   (<div class="fx-intro"> directly under the tool's title) */
.fx-intro {
  font-family: 'Open Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13.5px; line-height: 1.6; color: var(--text, #2D3436); text-align: left;
  margin: 0 0 16px;
}
.fx-calc .fx-intro { margin: 6px 0 12px; }
.fx-calc .fx-intro + .fx-lead { margin-top: -4px; }
.fx-intro sub { font-size: 75%; line-height: 0; }

/* inputs */
.fx-calc .fx-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 10px; }
.fx-calc .fx-modes { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.fx-calc .fx-inputs.fx-cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fx-calc .fx-in {
  background: #fff; border: 1px solid #e3edea; border-left: 4px solid var(--c, #999);
  border-radius: 8px; padding: 8px 10px; transition: box-shadow .15s; min-width: 0;
}
.fx-calc .fx-in.is-hot, .fx-calc .fx-cell.is-hot { box-shadow: 0 0 0 2px var(--c); }
.fx-calc .fx-in label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text, #2D3436); margin-bottom: 5px; line-height: 1.35; }
.fx-calc .fx-in label b { font-family: 'Georgia', serif; font-size: 15px; color: var(--c); margin-right: 6px; font-weight: 700; }
.fx-calc .fx-ctl { display: flex; align-items: center; gap: 8px; }
.fx-calc .fx-ctl input[type=range] { flex: 1 1 auto; min-width: 0; margin: 0; height: 22px; }
.fx-calc input[type=number], .fx-calc select {
  font-family: inherit; font-size: 14px; padding: 5px 7px; border: 1px solid #c8d4d2; border-radius: 6px;
  background: #fff; color: var(--text, #2D3436);
}
.fx-calc .fx-ctl input[type=number] { width: 92px; flex: 0 0 auto; }
.fx-calc .fx-in select { width: 100%; }
.fx-calc input[type=number]:focus, .fx-calc select:focus { outline: none; border-color: var(--c, #0B7B6B); box-shadow: 0 0 0 2px rgba(11,123,107,.18); }
.fx-calc .fx-attach { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.fx-calc .fx-attach label { flex: 0 0 auto; font-size: 11.5px; font-weight: 600; color: #5a6a68; margin: 0; }
.fx-calc .fx-attach select { flex: 1 1 auto; min-width: 0; width: auto; font-size: 13px; padding: 3px 6px; }
.fx-calc .fx-hint { font-size: 11.5px; color: var(--text-light, #555); margin-top: 4px; line-height: 1.4; }

/* table layout (2x2 tables, strata) */
/* The wrapper, not the table, takes the negative margin that offsets the border
   spacing, so the table fits its wrapper without a horizontal scroll bar. */
.fx-calc .fx-tablewrap { overflow-x: auto; margin: 0 -6px 10px; }
.fx-calc .fx-table { border-collapse: separate; border-spacing: 6px; margin: 0; font-size: 13px; }
.fx-calc .fx-table th { font-size: 12px; font-weight: 700; color: var(--dark-teal, #065C50); text-align: center; padding: 2px 6px; white-space: normal; }
.fx-calc .fx-table th[scope=row] { text-align: right; }
.fx-calc .fx-cell {
  background: #fff; border: 1px solid #e3edea; border-top: 3px solid var(--c, #999); border-radius: 8px;
  padding: 6px 8px; min-width: 116px; vertical-align: top; transition: box-shadow .15s;
}
.fx-calc .fx-cell label { display: block; font-size: 11.5px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; white-space: nowrap; }
.fx-calc .fx-cell label b { font-family: 'Georgia', serif; font-size: 14px; color: var(--c); font-weight: 700; }
.fx-calc .fx-cell input { width: 100%; min-width: 80px; }
.fx-calc .fx-tot { text-align: center; font-family: 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 13px; color: #5a6a68; padding: 4px 8px; }

/* output */
.fx-calc .fx-out {
  display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: 14px; align-items: start;
  background: #fff; border: 1px solid #e3edea; border-radius: 8px; padding: 12px;
}
.fx-calc .fx-res { display: flex; flex-direction: column; gap: 10px; padding-right: 12px; border-right: 1px solid #e3edea; }
.fx-calc .fx-r { text-align: center; }
.fx-calc .fx-r .lbl { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: #5a6a68; line-height: 1.35; }
.fx-calc .fx-r .lbl sub { text-transform: none; }
.fx-calc .fx-r .num { display: block; font-size: 25px; font-weight: 700; color: var(--c, #0B7B6B); font-family: 'SFMono-Regular', Menlo, Consolas, monospace; line-height: 1.25; white-space: nowrap; }
.fx-calc .fx-r .sub { display: block; font-size: 11.5px; color: var(--text-light, #555); margin-top: 1px; line-height: 1.35; }
.fx-calc .fx-work { min-width: 0; }
.fx-calc .fx-steps { font-family: 'Georgia', serif; font-size: 14.5px; line-height: 1.8; overflow-wrap: anywhere; }
.fx-calc .fx-steps .ln { display: block; }
.fx-calc .fx-steps .ln.ans b { color: var(--teal, #0B7B6B); }
.fx-calc .fx-v { font-weight: 700; }
.fx-calc .fx-note { font-size: 12.5px; color: var(--text-light, #555); margin-top: 6px; line-height: 1.55; }
.fx-calc .fx-note:empty { display: none; }
.fx-calc .fx-err { font-family: 'Open Sans', sans-serif; font-size: 13px; color: var(--accent, #CC0033); }
@media (max-width: 600px) {
  .fx-calc { padding: 12px; }
  .fx-calc .fx-out { grid-template-columns: 1fr; }
  .fx-calc .fx-res { padding-right: 0; border-right: none; padding-bottom: 10px; border-bottom: 1px solid #e3edea; flex-direction: row; flex-wrap: wrap; justify-content: space-around; }
  .fx-calc .fx-r .num { font-size: 22px; }
  .fx-calc .fx-tablewrap { margin: 0 -4px 10px; }
  .fx-calc .fx-table { border-spacing: 4px; margin: 0; }
  .fx-calc .fx-table th { white-space: normal; padding: 2px; font-size: 11px; }
  .fx-calc .fx-cell { min-width: 84px; padding: 5px 6px; }
  .fx-calc .fx-cell label { white-space: normal; }
  .fx-calc .fx-cell input { min-width: 64px; }
  .fx-calc .fx-tot { padding: 2px 4px; font-size: 12px; }
  .fx-calc .fx-inputs, .fx-calc .fx-inputs.fx-cols2 { grid-template-columns: 1fr; }
}

/* tracing: formula terms that match the hovered input */
.formula-sym.fx-tracing { color: #C9D3D6; }
.formula-sym.fx-tracing [style*="color"]:not(.fx-hot) { color: #C9D3D6 !important; }
.formula-sym.fx-tracing .fx-hot { background: #F1F5F4; border-radius: 4px; box-shadow: 0 0 0 2px #F1F5F4; }
.formula-plain.fx-tracing [class^="fc-"], .formula-plain.fx-tracing [class*=" fc-"] { color: #B8C4C7; }
.formula-plain.fx-tracing .fx-hot { background: #F1F5F4; border-radius: 4px; box-shadow: 0 0 0 2px #F1F5F4; }
.formula-plain.fx-tracing .fc-1.fx-hot { color: #0B7B6B; }
.formula-plain.fx-tracing .fc-2.fx-hot { color: #C2410C; }
.formula-plain.fx-tracing .fc-3.fx-hot { color: #6D28D9; }
.formula-plain.fx-tracing .fc-4.fx-hot { color: #1D4ED8; }
.formula-plain.fx-tracing .fc-5.fx-hot { color: #BE185D; }
.formula-plain.fx-tracing .fc-6.fx-hot { color: #047857; }

/* new worked-example tables scroll sideways on narrow screens */
.fx-tablescroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
.fx-tablescroll > .data-table { margin: 0; min-width: 460px; }

/* ── Worked examples ──────────────────────────────────────────────────────────
   Worked examples use a neutral grey surface so that the colour-coded terms,
   which follow each formula's palette (fc-1..fc-6), stay legible. */
.info-box.worked-example, .scenario-card.worked-example {
  background: #F3F4F6; border: 0; border-left: 4px solid #94A3B8; box-shadow: none;
  border-radius: var(--radius, 12px);
}
.info-box.worked-example h4, .scenario-card.worked-example h4,
.scenario-card.worked-example .scenario-title { color: var(--dark-teal, #065C50); }
.worked-example .reflection-q { color: var(--text, #2D3436); font-style: normal; }
.worked-example .data-table tr:nth-child(even) { background: #E8EBEE; }
.worked-example .data-table td { background: transparent; }
.fc-gold { color: #A16207; font-weight: 600; }
