/* Calculus interactive demos — shared styles. Layers on the global /style.css.
   Inline SVG + vanilla JS, mounted from elements with data-calc="...". */

:root {
  --curve: #3b6fe0;    /* blue  — the function */
  --secant: #ff8a3d;   /* orange — the secant (moving) */
  --tangent: #2fbf71;  /* green  — the tangent (the limit) */
}

.edu-wide { max-width: 820px; }
.crumbs { font-size: 13px; color: var(--muted); margin: -6px 0 18px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { opacity: .5; margin: 0 7px; }

.calc-demo { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 18px 18px 20px; margin: 18px 0 26px; }
.calc-demo h3 { margin: 0 0 4px; font-size: 18px; }
.calc-demo .demo-hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

.calc-stage { display: flex; justify-content: center; }
svg.calc-svg { width: 100%; height: auto; max-width: 560px; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }

.c-axis { stroke: rgba(255,255,255,.28); stroke-width: 1.5; }
.c-grid { stroke: rgba(255,255,255,.06); stroke-width: 1; }
.c-curve { fill: none; stroke: var(--curve); stroke-width: 3.5; stroke-linecap: round; }
.c-tangent { stroke: var(--tangent); stroke-width: 2.5; stroke-dasharray: 7 5; opacity: .9; }
.c-secant { stroke: var(--secant); stroke-width: 3; }
.c-run { stroke: rgba(255,255,255,.4); stroke-width: 1.5; stroke-dasharray: 4 4; }
.c-rise { stroke: rgba(255,255,255,.4); stroke-width: 1.5; stroke-dasharray: 4 4; }

.c-handle { cursor: grab; } .c-handle:active { cursor: grabbing; }
.c-handle circle.hit { fill: transparent; }
.c-handle circle.dot { stroke: var(--bg-bot); stroke-width: 2.5; }
.c-handle circle.dot.p { fill: var(--tangent); }
.c-handle circle.dot.q { fill: var(--secant); }
.c-handle circle.dot.ab { fill: var(--curve); }

/* Riemann strips */
.c-rect { fill: rgba(255,138,61,.28); stroke: var(--secant); stroke-width: 1; }
.c-rect.neg { fill: rgba(160,107,255,.28); stroke: #a06bff; }
.c-lbl { fill: var(--ink); font-size: 14px; font-weight: 700; font-family: inherit; }

/* readout */
.calc-read { margin: 16px 0 4px; }
.calc-eq { text-align: center; font-size: 20px; line-height: 1.7; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); overflow-x: auto; }
.calc-eq2 { text-align: center; font-size: 16px; margin-top: 8px; color: var(--ink); }
.calc-read .mut { color: var(--muted); font-size: .85em; }
.calc-read .sec { color: var(--secant); } .calc-read .tan { color: var(--tangent); }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 .16em; font-size: .8em; }
.frac > .num { padding: 0 .5em .06em; } .frac > .den { padding: .06em .5em 0; border-top: 2px solid currentColor; }

/* function picker + controls (shared look) */
.calc-parents { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; align-items: center; }
.calc-parents .lbl { width: 100%; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.calc-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin-top: 14px; }
.cbtn { appearance: none; cursor: pointer; border: 1px solid var(--border); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 650; padding: 9px 13px; border-radius: 10px; transition: border-color .12s, background .12s, transform .1s; }
.cbtn:hover { border-color: var(--accent); transform: translateY(-1px); }
.cbtn.on { border-color: var(--accent); background: var(--accent-soft); }
.cbtn.mono { font-size: 15px; }
.calc-slider { flex: 1 1 240px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.calc-slider .sl-name { color: var(--ink); } .calc-slider .sl-name b { color: var(--secant); }
.calc-slider input[type=range] { flex: 1; min-width: 0; width: 0; accent-color: var(--accent); height: 28px; }
.calc-slider .sl-val { min-width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--secant); }

.formula { background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 14px 0; font-size: 17px; line-height: 1.9; overflow-x: auto; }
.formula b { color: var(--accent); }
.usegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
@media (max-width: 540px) { .usegrid { grid-template-columns: 1fr; } }
.usebox { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: rgba(255,255,255,.03); }
.usebox h4 { margin: 0 0 6px; font-size: 15px; }
.usebox.sec { border-color: rgba(255,138,61,.4); }
.usebox.tan { border-color: rgba(47,191,113,.4); }

/* limits */
.c-vline { stroke: rgba(160,107,255,.5); stroke-width: 1.5; stroke-dasharray: 5 5; }
.c-hole { fill: var(--bg-bot); stroke: var(--curve); stroke-width: 2.5; }
.c-closed { fill: var(--curve); stroke: var(--bg-bot); stroke-width: 1.5; }
.c-app { stroke: var(--bg-bot); stroke-width: 1.5; }
.c-app.l { fill: var(--tangent); } .c-app.r { fill: var(--secant); }
.lim-cell { display: inline-block; min-width: 46%; padding: 2px 4px; }
.lim-cell.l b { color: var(--tangent); } .lim-cell.r b { color: var(--secant); }
.lim-tablewrap { display: flex; gap: 12px; justify-content: center; margin: 12px 0 4px; flex-wrap: wrap; }
.lim-table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.lim-table caption { font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: .04em; }
.lim-table th, .lim-table td { border: 1px solid var(--border); padding: 5px 14px; text-align: right; }
.lim-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.lim-table tbody td:last-child { color: var(--tangent); font-weight: 700; }
