/* The Tafel Equation (CHM2001, Lectures 5-6)
   Layout only - every colour comes from the model-shell palette at runtime, through inline styles
   and the --taf-* custom properties that the script sets on the model container. Same layout and
   slider style as current-and-charge.css (Faraday's law). */

.taf-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.taf-layout > * {
  min-width: 0;
}

/* Elements with their own display value would otherwise ignore the hidden attribute. */
.taf-layout [hidden] {
  display: none !important;
}

/* The key idea heads the results card. */
.taf-key {
  margin: 0 0 0.5rem;
  text-align: center;
  line-height: 1.2;
}

.taf-key-main {
  display: block;
  font-size: clamp(1.15rem, 2.6vw, 1.7rem);
  font-weight: 800;
}

.taf-key-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: clamp(0.95rem, 2.1vw, 1.12rem);
  font-weight: 600;
}

.taf-key:empty {
  display: none;
}

.taf-stage {
  display: block;
  width: 100%;
  height: 470px;
}

/* The verdict sits directly above the picture it explains. */
.taf-verdict {
  min-height: 5.6rem;           /* about the same height whatever it says, so the page does not jump */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.8rem;
  text-align: center;
  border: 3px solid;
  border-radius: 10px;
}

.taf-verdict-main {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
}

.taf-verdict-sub {
  display: block;
  font-size: 1.02rem;
  margin-top: 0.2rem;
  line-height: 1.45;
}

.taf-verdict-sub:empty {
  display: none;
}

/* The controls: one coloured strip directly under the picture. */
.taf-strip {
  margin: 0.4rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 3px solid var(--taf-red, red);
  border-radius: 12px;
  background: var(--taf-bg, #fff);
}

.taf-strip-head {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  text-align: center;
  text-wrap: balance;
}

/* The numbers substituted into each equation, updated live. */
.taf-calc {
  margin-top: 0.6rem;
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--taf-grid, #ccc);
  border-radius: 10px;
  font-size: 1.02rem;
}

.taf-calc:empty {
  display: none;
}

.taf-calc-row {
  display: grid;
  grid-template-columns: 9.6rem minmax(0, 1fr);
  gap: 0.3rem;
  margin: 0.15rem 0;
  line-height: 1.45;
}

.taf-bridge {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.8rem;
  border: 2px solid var(--taf-red, red);
  border-radius: 10px;
  background: var(--taf-red-t, #fff3f3);
  line-height: 1.5;
}

.taf-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.taf-tab {
  flex: 1 1 9rem;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  padding: 0.45rem 0.5rem;
  border: 2px solid;
  border-radius: 999px;
  cursor: pointer;
}

.taf-process {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 800;
}

.taf-process:empty {
  display: none;
}

.taf-guide {
  margin: 0 0 0.7rem;
  line-height: 1.5;
}

.taf-guide:empty {
  display: none;
}

.taf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.taf-row--centre {
  justify-content: center;
}

.taf-strong {
  font-weight: 800;
}

.taf-go {
  display: block;
  width: 100%;
  margin-top: 0.9rem;
  padding: 0.55rem 0.8rem;
  font: inherit;
  font-weight: 800;
  border: 2px solid;
  border-radius: 999px;
  cursor: pointer;
}

.taf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.3rem;
}

.taf-chips--centre {
  justify-content: center;
}

.taf-chip {
  font: inherit;
  font-size: 1rem;
  padding: 0.3rem 0.7rem;
  border: 2px solid;
  border-radius: 999px;
  cursor: pointer;
}

/* Slider: a dark outlined track, filled up to the thumb, and a large white thumb with a dark ring. */
.taf-slider {
  display: grid;
  grid-template-columns: 8.4rem minmax(0, 1fr) 5.6rem;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
}

.taf-slider label {
  font-weight: 800;
  font-size: 1.1rem;
}

.taf-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}

.taf-slider input[type="range"]::-webkit-slider-runnable-track {
  box-sizing: border-box;
  height: 16px;
  border: 2px solid var(--taf-fg, #000);
  border-radius: 8px;
  background: linear-gradient(to right, var(--taf-sl, #888) var(--p), var(--taf-trk, #ddd) var(--p));
}

.taf-slider input[type="range"]::-moz-range-track {
  box-sizing: border-box;
  height: 16px;
  border: 2px solid var(--taf-fg, #000);
  border-radius: 8px;
  background: linear-gradient(to right, var(--taf-sl, #888) var(--p), var(--taf-trk, #ddd) var(--p));
}

.taf-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  margin-top: -6px;
  border: 4px solid var(--taf-fg, #000);
  border-radius: 50%;
  background: var(--taf-bg, #fff);
}

.taf-slider input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  border: 4px solid var(--taf-fg, #000);
  border-radius: 50%;
  background: var(--taf-bg, #fff);
}

.taf-slider input[type="range"]:focus-visible {
  outline: 3px solid var(--taf-fg, #000);
  outline-offset: 3px;
  border-radius: 8px;
}

.taf-val {
  font-weight: 800;
  font-size: 1.1rem;
  text-align: right;
  white-space: nowrap;
}

.taf-small {
  margin: 0.5rem 0 0.1rem;
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.4;
}

.taf-small--left {
  text-align: left;
}

.taf-notes {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  line-height: 1.45;
}

.taf-notes li {
  margin: 0.25rem 0;
}

/* Test your knowledge */
.taf-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.taf-progress {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.taf-dot {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  border: 2px solid;
  display: inline-grid;
  place-items: center;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
}

.taf-dot[aria-current="true"] {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

.taf-score {
  font-weight: 800;
  font-size: 1rem;
}

.taf-task {
  margin: 0.6rem 0 0.2rem;
  font-size: 1.15rem;
  font-weight: 800;
}

.taf-intro {
  margin: 0 0 0.6rem;
  line-height: 1.5;
}

.taf-step {
  margin-bottom: 0.4rem;
  padding: 0.35rem 0.5rem;
  border: 2px solid;
  border-radius: 8px;
}

.taf-step-q {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.taf-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.3rem;
}

.taf-options button {
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  padding: 0.4rem 0.6rem;
  border: 2px solid;
  border-radius: 8px;
  cursor: pointer;
}

.taf-feedback {
  margin: 0.6rem 0 0;
  min-height: 2.6em;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .taf-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .taf-verdict-main {
    font-size: 1.2rem;
  }
}

@media (max-width: 560px) {
  .taf-slider {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "label value" "input input";
  }
  .taf-slider label { grid-area: label; }
  .taf-slider input { grid-area: input; }
  .taf-val { grid-area: value; }
  .taf-calc-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .taf-tab,
  .taf-chip {
    transition: none;
  }
}

/* The Butler–Volmer equation written out live (stage 1): each term with its value underneath; the back term is
   struck through once it falls below 1 % of the forward one. */
.taf-rates {
  display: block;
  width: 100%;
  height: 170px;
  margin: 0.6rem 0 0;
}

.taf-eqn {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--taf-grid, #ccc);
  border-radius: 10px;
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.4;
}

.taf-eqn:empty {
  display: none;
}

.taf-eq-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 0.25rem 0.4rem;
}

.taf-term {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border: 2px solid;
  border-radius: 8px;
  font-weight: 700;
}

.taf-term small {
  font-size: 0.85rem;
  font-weight: 800;
}

.taf-term--gone {
  opacity: 0.45;
}

.taf-term--gone .taf-term-f {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.taf-eq-note {
  margin: 0.45rem 0 0;
  font-size: 1rem;
}


/* ---------------- 2026: the equation, live (right-hand column) ---------------- */
.taf-live {
  margin: 0 0 0.6rem;
  padding: 0.55rem 0.75rem 0.6rem;
  border: 3px solid var(--taf-fg, #000);
  border-radius: 12px;
  background: var(--taf-bg, #fff);
  font-size: 1.05rem;
}

.model-card--results .taf-live {
  margin: 0.6rem 0 0;
}

.taf-live-title {
  font-weight: 800;
  font-size: 1.15rem;
}

.taf-half {
  margin: 0.25rem 0 0.1rem;
  font-weight: 700;
}

.taf-eqtab {
  border-collapse: collapse;
  margin: 0.2rem auto 0.4rem;
}

.taf-eqtab td {
  padding: 0.05rem 0.35rem;
  text-align: center;
  white-space: nowrap;
}

.taf-eqtab .taf-sym td {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.25;
}

.taf-eqtab .taf-num td {
  font-size: 1.35rem;
  font-weight: 700;
  border-top: 1px dashed var(--taf-grid, #bbb);
  padding-top: 0.2rem;
}

.taf-eqtab .taf-unit td {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.taf-terms {
  border-top: 2px solid var(--taf-red, red);
  padding-top: 0.3rem;
}

.taf-tline {
  margin: 0.25rem 0;
  font-size: 1.08rem;
  line-height: 1.4;
}

/* the back term, once below 1 %: struck through */
.taf-gone {
  opacity: 0.5;
}

.taf-gone .taf-tf {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.taf-tafel {
  margin: 0.35rem 0 0;
  padding: 0.35rem 0.55rem;
  border: 2px solid var(--taf-green, #2a7);
  border-radius: 8px;
  font-size: 1.05rem;
  line-height: 1.4;
}

.taf-flash {
  background: #fff1a8;
  color: inherit;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #e0b800;
}

.high-contrast .taf-flash {
  background: transparent;
  box-shadow: 0 0 0 2px currentColor;
}

.taf-so {
  margin: 0.45rem 0 0;
  padding: 0.4rem 0.6rem;
  border-left: 4px solid var(--taf-grid, #999);
  background: var(--taf-red-t, #f6f6f6);
  line-height: 1.45;
}

.taf-more {
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.65rem;
  border: 2px solid var(--taf-grid, #ccc);
  border-radius: 10px;
  font-size: 1.04rem;
}

.taf-more > summary {
  font-weight: 800;
  cursor: pointer;
}

.taf-more ul {
  margin: 0.35rem 0 0.2rem;
  padding-left: 1.1rem;
  line-height: 1.45;
}

.taf-more li {
  margin: 0.25rem 0;
}

.taf-more-text {
  margin: 0.35rem 0 0.15rem;
  line-height: 1.5;
}

.taf-work {
  margin-top: 0.45rem;
  font-size: 1rem;
}

.taf-work .taf-calc {
  margin: 0.3rem 0 0;
  padding: 0;
  border: 0;
}

.taf-work .taf-calc-row {
  grid-template-columns: 7.4rem minmax(0, 1fr);
}

.taf-go {
  font-size: 1.05rem;
}

.taf-intro,
.taf-step-q,
.taf-feedback {
  font-size: 1.04rem;
}

@media (max-width: 560px) {
  .taf-eqtab .taf-sym td,
  .taf-eqtab .taf-num td {
    font-size: 1.05rem;
  }
  .taf-work .taf-calc-row {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* round 4: the Tafel equation with its tag; Butler–Volmer in boxes underneath */
.taf-eqtab:empty,
.taf-so:empty {
  display: none;
}

.taf-terms {
  border-top: 0;
  padding-top: 0.1rem;
}

.taf-tafrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.7rem;
  margin: 0.4rem 0 0.6rem;
}

.taf-tafeq {
  font-size: 1.3rem;
  font-weight: 700;
}

.taf-status {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  font-size: 1.02rem;
  white-space: nowrap;
}

.high-contrast .taf-status {
  background: transparent !important;
  border: 2px solid currentColor;
}

.taf-bvhead {
  margin: 0.3rem 0 0.25rem;
  padding-top: 0.4rem;
  border-top: 2px solid var(--taf-red, red);
  font-weight: 800;
}

.taf-live .taf-eq-row {
  font-size: 1.08rem;
}

.taf-live .taf-eq-note {
  text-align: center;
  font-size: 1.04rem;
}
