/* Theoria Weekly — Math Lab
   Click any chart point (or a dotted number in the text) to see how the number is built,
   try your own inputs, and see the sources. Uses the site's tokens from site.css. */

/* ---- triggers in the article ---- */
.ml-pt { cursor: pointer; outline: none; }
.ml-pt .mk { transition: transform 200ms var(--ease-out), filter 200ms; transform-box: fill-box; transform-origin: center; }
.ml-pt:hover .mk, .ml-pt:focus-visible .mk { transform: scale(1.45); }
rect.mk { transform-origin: left center !important; }
.ml-pt:hover rect.mk, .ml-pt:focus-visible rect.mk { transform: scaleY(1.25); filter: brightness(1.08); }
.ml-pt:focus-visible .hit { stroke: var(--brick-500); stroke-width: 2; }
.ml-pt.is-live .mk { animation: ml-beat 1.4s var(--ease-out) infinite; }
@keyframes ml-beat { 50% { transform: scale(1.7); } }
.ml-chart { position: relative; }

.ml-tip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink-900); color: var(--paper); font: 500 13px/1.4 var(--sans);
  padding: 8px 12px; transform: translate(-50%, calc(-100% - 14px)); white-space: nowrap; box-shadow: var(--shadow-3); opacity: 0; transition: opacity 150ms; }
.ml-tip.on { opacity: 1; }
.ml-tip b { font-family: var(--display); font-weight: 800; font-size: 15px; margin-left: 4px; }
.ml-tip em { display: block; font-style: normal; color: var(--brick-200); font-weight: 600; font-size: 12px; margin-top: 2px; }

.ml-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 16px; }
.ml-open { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 18px 0 6px; background: var(--white); color: var(--ink-900);
  border: 2px solid var(--ink-900); font: 600 15px var(--sans); cursor: pointer; transition: background 200ms, color 200ms; }
.ml-open:hover { background: var(--ink-900); color: var(--paper); }
.ml-f { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--brick-500); color: #fff; font: italic 700 18px/1 Georgia, serif; flex: none; }
.ml-hint { font-size: 13px; color: var(--ink-500); }

.ml-num { color: inherit; text-decoration: none; border-bottom: 2px dotted var(--brick-400); font-variant-numeric: tabular-nums; cursor: pointer; transition: background 150ms; }
.ml-num:hover, .ml-num:focus-visible { background: var(--brick-100); color: var(--brick-700); }
.ml-num-sample { border-bottom: 2px dotted var(--brick-400); }
.ml-intro { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; align-items: start; margin: 8px 0 0; padding: 16px 18px; background: var(--ink-100); }
.ml-intro p { margin: 0 !important; font-size: 16px !important; line-height: 1.55 !important; }

.legend i.ring2 { width: 14px; height: 14px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink-400); }
.legend i.dot2 { width: 14px; height: 14px; border-radius: 50%; background: var(--brick-500); }

.ml-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.ml-fact { display: grid; gap: 2px; text-align: left; padding: 14px 16px; background: var(--white); border: 0; box-shadow: var(--shadow-1); font: inherit; color: inherit; }
button.ml-fact { cursor: pointer; transition: box-shadow 200ms, transform 200ms; }
button.ml-fact:hover, button.ml-fact:focus-visible { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.ml-fact b { font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; color: var(--ink-900); font-variant-numeric: tabular-nums; }
button.ml-fact b { color: var(--brick-500); }
.ml-fact span { font-size: 13px; color: var(--ink-500); line-height: 1.35; }
@media (max-width: 720px) { .ml-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- panel ---- */
.ml-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(23,25,30,.42); opacity: 0; pointer-events: none; transition: opacity 300ms; }
.ml-open-state .ml-scrim { opacity: 1; pointer-events: auto; }
@media (min-width: 1280px) { .ml-open-state .ml-scrim { background: rgba(23,25,30,.12); } }
.ml-panel { position: fixed; z-index: 80; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--paper); color: var(--ink-900);
  display: flex; flex-direction: column; transform: translateX(104%); transition: transform 450ms var(--ease-out); box-shadow: -16px 0 48px rgba(23,25,30,.18);
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.ml-open-state .ml-panel { transform: none; }
@media (max-width: 720px) {
  .ml-panel { top: auto; left: 0; width: 100%; height: 92%; transform: translateY(104%); padding-left: env(safe-area-inset-left, 0px); }
  .ml-open-state { overflow: hidden; }
}
.ml-head { background: var(--ink-900); color: var(--paper); padding: 18px 20px 16px; display: grid; gap: 12px; }
.ml-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ml-k { margin: 0; font: 600 12px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brick-200); }
.ml-head h2 { margin: 8px 0 0; font-size: 24px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; color: var(--paper); }
.ml-x { flex: none; width: 40px; height: 40px; border: 2px solid var(--ink-600); background: transparent; color: var(--paper); font: 500 22px/1 var(--sans); cursor: pointer; }
.ml-x:hover { border-color: var(--paper); }
.ml-pick { display: flex; gap: 8px; align-items: center; }
.ml-pick select { flex: 1; min-width: 0; min-height: 40px; background: var(--ink-800); color: var(--paper); border: 1px solid var(--ink-600); font: 500 14px var(--sans); padding: 0 10px; }
.ml-pick button { width: 40px; height: 40px; flex: none; background: var(--ink-800); color: var(--paper); border: 1px solid var(--ink-600); font: 600 16px var(--sans); cursor: pointer; }
.ml-pick button:hover { border-color: var(--paper); }
.ml-tabs { display: flex; border-bottom: 1px solid var(--ink-200); padding: 0 20px; background: var(--white); }
.ml-tabs button { font: 600 14px var(--sans); color: var(--ink-500); background: none; border: 0; border-bottom: 3px solid transparent; padding: 14px 10px 11px; margin-right: 6px; cursor: pointer; }
.ml-tabs button[aria-selected="true"] { color: var(--ink-900); border-bottom-color: var(--brick-500); }
.ml-body { flex: 1; overflow-y: auto; padding: 22px 20px 40px; font-size: 16px; line-height: 1.55; }
.ml-answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.ml-answer b { font-family: var(--display); font-size: 52px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; color: var(--brick-500); font-variant-numeric: tabular-nums; }
.ml-answer span { font-size: 15px; color: var(--ink-600); }
.ml-est { display: inline-block; margin-top: 10px; }
.ml-why { margin: 14px 0 18px; color: var(--ink-700); }
.ml-why b { color: var(--ink-900); font-weight: 600; }
.ml-ctrl { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.ml-btn { min-height: 42px; padding: 0 16px; font: 600 14px var(--sans); cursor: pointer; border: 2px solid var(--ink-900); background: var(--ink-900); color: var(--paper); }
.ml-btn.ghost { background: transparent; color: var(--ink-900); }
.ml-btn:hover { background: var(--brick-500); border-color: var(--brick-500); color: #fff; }
.ml-steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.ml-step { position: relative; padding: 0 0 20px 40px; transition: opacity 300ms; }
.ml-step::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; background: var(--ink-900); color: var(--paper); font: 800 13px/26px var(--display); text-align: center; }
.ml-step:not(:last-child)::after { content: ""; position: absolute; left: 12.5px; top: 30px; bottom: 4px; width: 1px; background: var(--ink-300); }
.ml-step.pending { opacity: .15; }
.ml-say { font-weight: 600; font-size: 15px; line-height: 1.35; margin: 2px 0 8px; }
.ml-eq { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ml-c { display: inline-grid; padding: 5px 9px; background: var(--white); box-shadow: var(--shadow-1); transition: opacity 280ms, transform 350ms var(--ease-out), box-shadow 200ms; }
.ml-c b { font: 700 15px var(--sans); font-variant-numeric: tabular-nums; }
.ml-c small { font-size: 11px; line-height: 1.25; color: var(--ink-500); }
.ml-c.ref { box-shadow: inset 0 0 0 1px var(--ink-400); background: var(--ink-100); }
.ml-c.lit { box-shadow: inset 0 0 0 2px var(--brick-500); }
.ml-c.res { background: var(--ink-900); box-shadow: none; } .ml-c.res b { color: var(--paper); } .ml-c.res small { color: var(--ink-300); }
.ml-c.res.final { background: var(--brick-500); } .ml-c.res.final small { color: var(--brick-100); }
.ml-o { font: 700 17px var(--sans); color: var(--brick-500); transition: opacity 280ms; }
.ml-pre { opacity: 0; transform: translateY(8px); }
.ml-box { margin-top: 8px; padding: 16px; background: var(--white); box-shadow: var(--shadow-1); }
.ml-box h3 { margin: 0 0 10px; font: 600 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-500); }
.ml-calc { display: flex; gap: 8px; align-items: center; }
.ml-calc code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 500 13.5px ui-monospace, Menlo, Consolas, monospace; background: var(--ink-100); padding: 9px 10px; }
.ml-verified { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; margin-top: 16px; font-size: 14px; color: var(--ink-600); }
.ml-verified i { width: 24px; height: 24px; background: var(--ink-900); color: var(--paper); display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 13px; }

.ml-try > p { margin: 0 0 14px; color: var(--ink-600); }
.ml-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ml-presets button { font: 600 13px var(--sans); background: transparent; border: 1px dashed var(--brick-400); color: var(--brick-700); padding: 7px 10px; cursor: pointer; }
.ml-presets button:hover { background: var(--brick-100); }
.ml-field { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--ink-200); }
.ml-field label { font-weight: 600; font-size: 14px; line-height: 1.3; }
.ml-field label small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-500); }
.ml-in { display: flex; align-items: center; background: var(--white); border: 1px solid var(--ink-300); padding: 0 10px; }
.ml-in:focus-within { border-color: var(--ink-900); box-shadow: 0 0 0 1px var(--ink-900); }
.ml-in input { width: 100%; min-width: 0; border: 0; background: transparent; font: 700 15px var(--sans); color: var(--ink-900); padding: 9px 4px; text-align: right; font-variant-numeric: tabular-nums; }
.ml-in input:focus { outline: none; }
.ml-in span { font-size: 13px; color: var(--ink-500); white-space: nowrap; }
.ml-field.changed .ml-in { border-color: var(--brick-500); background: var(--brick-100); }
.ml-live { margin-top: 16px; padding: 18px; background: var(--ink-900); color: var(--paper); }
.ml-live .big { font-family: var(--display); font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.ml-live .vs { font-size: 14px; color: var(--ink-300); margin-top: 8px; }
.ml-live .f { font: 500 13px ui-monospace, Menlo, Consolas, monospace; color: var(--brick-200); margin-top: 8px; overflow-x: auto; white-space: nowrap; }

.ml-src { list-style: none; margin: 0 0 18px; padding: 0; }
.ml-src li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--ink-200); }
.ml-src .w { font-weight: 600; font-size: 14px; } .ml-src .v { font-weight: 700; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.ml-src .s { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink-600); }
.ml-notes h3 { margin: 22px 0 8px; font: 600 12px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-500); }
.ml-notes p { margin: 0 0 10px; font-size: 14.5px; color: var(--ink-700); }
@media (prefers-reduced-motion: reduce) { .ml-panel, .ml-scrim, .ml-c, .ml-step, .ml-pt .mk { transition: none !important; animation: none !important; } }
@media print { .ml-bar, .ml-intro, .ml-panel, .ml-scrim, .ml-tip { display: none !important; } .ml-num { border: 0; } }
