/* Decision-aware mathematical methods; scoped to the new section. */
.math-methods, .math-methods [id] { scroll-margin-top: 84px; }
.math-methods .math-lead { max-width: 780px; margin-top: 20px; font-size: clamp(18px, 2vw, 22px); line-height: 1.55; color: var(--muted); }
.math-route { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; list-style: none; padding: 0; margin: 28px 0; counter-reset: method; }
.math-route li { counter-increment: method; padding: 12px; border-top: 2px solid var(--teal-line); font: 500 13px/1.5 var(--sans); }
.math-route li::before { content: counter(method, decimal-leading-zero); display: block; margin-bottom: 4px; color: var(--teal-ink); font-family: var(--mono); }
.math-definition, .math-cert { padding: clamp(20px,3vw,32px); background: var(--teal-soft); border: 1px solid var(--teal-line); border-radius: 16px; }
.math-methods .math-kicker { margin: 0 0 12px; font: 600 12px/1.5 var(--sans); text-transform: uppercase; letter-spacing: .09em; color: var(--teal-ink); }
.math-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin: 24px 0; align-items: start; }
.math-card { min-width: 0; padding: clamp(20px,2.6vw,28px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.math-methods h3 { margin: 0 0 16px; font: 600 clamp(20px,2vw,25px)/1.3 var(--serif); color: var(--ink); }
.math-methods p { line-height: 1.7; }
.math-methods p + p { margin-top: 14px; }
.math-methods .math-note { font-size: 14px; color: var(--muted); line-height: 1.65; }
.math-methods .eq { max-width: 100%; overflow-x: auto; padding: 10px 2px; margin: 12px 0; }
.math-methods .eq .katex { font-size: 1.03em; }
.math-methods .katex-display { margin: .3em 0; }
.math-methods .katex-display > .katex { text-align: left; }
.math-definition .katex-display > .katex, .math-cert .katex-display > .katex { text-align: center; }
.math-result { padding: 14px; background: var(--teal-soft); border-radius: 8px; text-align: center; margin: 12px 0 18px; color: var(--teal-ink); }
.math-detail { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.math-detail summary { cursor: pointer; color: var(--teal-ink); font-weight: 600; line-height: 1.5; }
.math-detail[open] summary { margin-bottom: 14px; }
.math-evidence { margin-top: 34px; }
.math-table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; }
.math-evidence table { width: 100%; border-collapse: collapse; background: var(--surface); text-align: left; font-size: 14px; line-height: 1.6; }
.math-evidence th, .math-evidence td { padding: 18px; border-bottom: 1px solid var(--line); vertical-align: top; }
.math-evidence thead { background: var(--surface-2); }
.math-evidence tbody th { width: 21%; color: var(--ink); font-weight: 600; }
.math-evidence tr:last-child td, .math-evidence tr:last-child th { border-bottom: 0; }
.math-evidence td { width: 39.5%; }
@media (max-width: 850px) {
  .math-grid { grid-template-columns: 1fr; }
  .math-route { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 520px) {
  .math-route { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .math-methods .eq .katex { font-size: .9em; }
  .math-evidence table { min-width: 600px; }
}
@media print {
  .math-grid { display: block; }
  .math-card { margin-bottom: 16px; break-inside: avoid; }
  .math-table-scroll { overflow: visible; }
}

/* Symbol definitions shared with the standalone mathematical foundations page. */
.math-methods .sdf-symbols { margin: 16px 0; font-size: 15px; }
.math-methods .sdf-symbol-list { margin: 0; padding-left: 22px; }
.math-methods .sdf-symbol-list li + li { margin-top: 8px; }

.method-overview{list-style:none;padding:0;margin:28px 0;display:grid;gap:16px}
.method-overview li{display:flex;gap:18px;padding:18px 0;border-bottom:1px solid var(--line)}
.method-overview h3{font:600 19px/1.4 var(--sans);margin:0 0 5px}
.method-number{font:500 14px/1.8 var(--mono);color:var(--teal-ink);padding-top:3px}
.math-more{margin:24px 0;line-height:1.7}

/* ---------- Inline methods: definition, step rail, panels ---------- */
#mathematics > .wrap > .sec-head { margin-bottom: 36px; }
#mathematics math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; }

/* Definition: statement on the left, formula and symbols on the right */
#mathematics .math-definition {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: clamp(24px, 4vw, 56px); align-items: center;
  padding: clamp(24px, 3.6vw, 44px) clamp(24px, 3.6vw, 44px) clamp(24px, 3.6vw, 44px) clamp(28px, 4vw, 52px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
#mathematics .math-definition::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--teal); }
.math-definition-copy > p:not(.math-kicker) { font: 400 clamp(18px, 1.65vw, 21px)/1.7 var(--serif); color: var(--ink); }
.math-definition-formula { padding: 22px 24px 20px; background: var(--teal-soft); border: 1px solid var(--teal-line); border-radius: 16px; }
#mathematics .math-definition-formula .eq { margin: 0; padding: 6px 0 18px; text-align: center; }
#mathematics .math-definition-formula .eq math { font-size: 1.9em; color: var(--ink); }
.math-legend { margin: 0; padding-top: 16px; border-top: 1px solid var(--teal-line); display: grid; gap: 8px; }
.math-legend > div { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: baseline; gap: 10px; }
.math-legend dt { font: italic 500 17px/1.3 var(--serif); color: var(--teal-ink); text-align: center; }
.math-legend dd { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--text); }

/* Expand / collapse bar */
.math-expansion-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 36px 0 18px; color: var(--muted); font-size: 14px; }
.math-expansion-bar p { margin: 0; }
.math-toggle-all {
  flex-shrink: 0; padding: 9px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--ink); font: 600 13px/1 var(--sans); cursor: pointer;
}
.math-toggle-all:hover { border-color: var(--ink); }
.math-toggle-all .show-expanded { display: none; }
.math-toggle-all[aria-expanded="true"] .show-expanded { display: inline; }
.math-toggle-all[aria-expanded="true"] .show-collapsed { display: none; }

/* Step rail: numbered nodes on a line, one panel per step */
.method-accordion { position: relative; display: grid; gap: 14px; padding-left: 68px; }
.method-accordion::before { content: ""; position: absolute; left: 21px; top: 38px; bottom: 38px; width: 2px; border-radius: 2px; background: var(--teal-line); }
.method-step, .method-extra { position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.method-step::before { content: ""; position: absolute; left: -26px; top: 37px; width: 26px; height: 2px; background: var(--teal-line); }
.method-step:hover, .method-extra:hover { border-color: var(--line-strong); }
.method-step[open] { border-color: var(--teal-line); box-shadow: var(--shadow); }
.method-step > summary, .method-extra > summary { list-style: none; display: flex; align-items: center; gap: 18px; padding: 20px 24px; border-radius: 15px; cursor: pointer; }
.method-step > summary::-webkit-details-marker, .method-extra > summary::-webkit-details-marker, .math-detail > summary::-webkit-details-marker { display: none; }
.method-step > summary:focus-visible, .method-extra > summary:focus-visible, .math-detail > summary:focus-visible, .math-toggle-all:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.method-step[open] > summary, .method-extra[open] > summary { border-bottom: 1px solid var(--line); border-radius: 15px 15px 0 0; }
.method-step > summary > .method-number {
  position: absolute; left: -68px; top: 16px; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--bg-alt); border: 2px solid var(--teal-line); color: var(--teal-ink); font: 600 13px/1 var(--mono);
}
.method-step:hover > summary > .method-number { border-color: var(--teal); }
.method-step[open] > summary > .method-number { background: var(--teal); border-color: var(--teal); color: var(--on-accent); box-shadow: 0 0 0 5px var(--glow-teal); }
.method-summary-copy { flex: 1; min-width: 0; }
.method-summary-title { display: block; margin-bottom: 4px; color: var(--ink); font: 600 20px/1.4 var(--serif); }
.method-summary-description { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.65; }
.method-chevron { position: relative; flex: 0 0 32px; height: 32px; margin-left: auto; border: 1px solid var(--line); border-radius: 50%; color: var(--teal-ink); }
.method-chevron::before, .method-chevron::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 2px; margin: -1px 0 0 -6px; border-radius: 2px; background: currentColor; }
.method-chevron::after { transform: rotate(90deg); }
details[open] > summary > .method-chevron { background: var(--teal-soft); border-color: var(--teal-line); }
details[open] > summary > .method-chevron::after { transform: rotate(90deg) scaleX(0); }

/* Step body */
.method-step-body { min-width: 0; padding: 26px 32px 32px; }
.method-step-body > p, .method-step-body > h3, .method-step-body > .eq, .method-step-body > .math-note,
.math-card > p, .math-card > .eq, .math-detail > p, .math-detail > .eq, .math-detail > .math-result { max-width: 780px; }
.method-step-body p { font-size: 16px; color: var(--text); }
.method-step-body h3 { margin: 0 0 18px; }
.method-step-body .math-card { border: 0; padding: 0; background: transparent; }
#mathematics .method-step-body .eq[data-display] {
  margin: 16px 0; padding: 12px 22px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 0 12px 12px 0;
}
#mathematics .method-step-body .eq[data-display] + .eq[data-display] { margin-top: -8px; }
#mathematics .method-step-body .eq math[display="block"] { margin: .35em 0; text-align: center; font-size: 1.14em; color: var(--ink); }
#mathematics .method-step-body .math-note { padding-left: 14px; border-left: 2px solid var(--line-strong); font-size: 13.5px; line-height: 1.7; color: var(--muted); }
#mathematics .math-result { max-width: 780px; margin: 8px 0 18px; padding: 14px; background: var(--teal-soft); border: 1px solid var(--teal-line); border-radius: 12px; }
#mathematics .math-result math { font-size: 1.3em; }

/* Nested disclosures */
#mathematics .math-detail { margin-top: 22px; padding: 0 20px; border: 1px solid var(--line); border-radius: 12px; }
#mathematics .math-detail > summary {
  list-style: none; display: flex; align-items: center; gap: 12px; margin: 0 -20px; padding: 14px 20px;
  border-radius: 11px; color: var(--teal-ink); font: 600 15px/1.5 var(--sans); cursor: pointer;
}
#mathematics .math-detail > summary:hover { background: var(--surface-2); }
#mathematics .math-detail > summary::before { content: ""; flex: 0 0 7px; height: 7px; margin: 0 2px 0 3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
#mathematics .math-detail[open] > summary { margin-bottom: 18px; border-bottom: 1px solid var(--line); border-radius: 11px 11px 0 0; }
#mathematics .math-detail[open] > summary::before { transform: translateY(-2px) rotate(45deg); }
#mathematics .math-detail[open] > :last-child { margin-bottom: 20px; }
#mathematics .math-detail .math-kicker { margin-bottom: 6px; }

/* Worked example with a to-scale number line */
.math-example { margin-top: 24px; padding: 22px 24px 24px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.math-example h4 { margin: 0 0 14px; font: 600 17px/1.4 var(--sans); color: var(--ink); }
.math-example > p { max-width: 780px; }
.math-numberline { margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.math-numberline-scroll { overflow-x: auto; padding: 10px 12px 0; }
.math-numberline svg { display: block; width: 100%; min-width: 560px; height: auto; }
.math-numberline figcaption { padding: 8px 16px 12px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.math-numberline text { font: 500 12px var(--sans); fill: var(--text); }
.math-numberline .nl-quiet { font-size: 11px; fill: var(--muted); }
.math-numberline .nl-num { font-family: var(--mono); font-size: 11.5px; }
.math-numberline .nl-band { fill: var(--teal-soft); }
.math-numberline .nl-axis { stroke: var(--line-strong); stroke-width: 2; }
.math-numberline .nl-tau { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 4; }
.math-numberline .nl-gap { stroke: var(--muted); stroke-width: 1.25; fill: none; }
.math-numberline .nl-shift { stroke: var(--coral); stroke-width: 1.75; fill: none; }
.math-numberline .nl-arrow { fill: var(--coral); }
.math-numberline .nl-h { fill: var(--teal); stroke: var(--surface); stroke-width: 2; }
.math-numberline .nl-c { fill: var(--coral); stroke: var(--surface); stroke-width: 2; }
.math-numberline .nl-coral { fill: var(--coral-ink); }
.math-numberline .nl-teal { fill: var(--teal-ink); }

/* Outcome tiles */
.math-contrast { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 780px; margin: 24px 0; }
.math-contrast > div { position: relative; overflow: hidden; padding: 22px 22px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.math-contrast > div::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--teal); }
.math-contrast > div:first-child::before { background: var(--coral); }
.math-contrast strong { display: block; margin-bottom: 8px; font: 600 34px/1.1 var(--serif); letter-spacing: -.01em; color: var(--ink); }

/* Secondary panels and the results table */
.method-extra { margin: 14px 0 0 68px; }
.method-accordion + .method-extra { margin-top: 28px; }
.method-extra > summary { padding: 16px 24px; color: var(--ink); font: 600 16px/1.5 var(--sans); }
#mathematics .math-evidence thead th { font: 600 12px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#mathematics .math-evidence th, #mathematics .math-evidence td { padding: 16px 18px; }

@media (prefers-reduced-motion: no-preference) {
  .method-step, .method-extra, .method-step > summary > .method-number, .method-chevron { transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, color .18s ease; }
  .method-chevron::after, #mathematics .math-detail > summary::before { transition: transform .18s ease; }
}
@media (max-width: 860px) {
  #mathematics .math-definition { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  #mathematics > .wrap > .sec-head { margin-bottom: 28px; }
  .math-expansion-bar { align-items: flex-start; gap: 12px; }
  .method-accordion { padding-left: 0; }
  .method-accordion::before, .method-step::before { display: none; }
  .method-extra { margin-left: 0; }
  .method-step > summary, .method-extra > summary { align-items: flex-start; gap: 12px; padding: 16px; }
  .method-step > summary > .method-number { position: static; flex: 0 0 34px; width: 34px; height: 34px; font-size: 12px; background: var(--surface); }
  .method-step[open] > summary > .method-number { background: var(--teal); box-shadow: none; }
  .method-summary-title { font-size: 18px; }
  .method-step-body { padding: 20px 16px 24px; }
  #mathematics .method-step-body .eq[data-display] { padding: 10px 12px; }
  #mathematics .method-step-body .eq math[display="block"] { font-size: 1em; }
  .math-example { padding: 18px 16px 20px; }
  .math-contrast { grid-template-columns: 1fr; }
}
@media print {
  .method-accordion { padding-left: 0; }
  .method-accordion::before, .method-step::before, .method-chevron { display: none; }
  .method-extra { margin-left: 0; }
}
