/* Functions interactive demos — shared styles.
   Layers on the global /style.css. Widgets are inline SVG + vanilla JS,
   mounted from elements carrying a data-fn="..." attribute. Mirrors trig.css. */

:root {
  --parent: #7c8aa5;   /* muted slate — the untransformed parent (ghost) */
  --image:  #3b6fe0;   /* blue  — the transformed curve */
  --anchor: #ff8a3d;   /* orange — the draggable move-handle */
  --aV: #2fbf71;       /* green — vertical params (a, k) */
  --aH: #a06bff;       /* purple — horizontal params (b, h) */
}

.edu-wide { max-width: 820px; }

/* breadcrumb (matches the other maths pages) */
.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; }

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

.fn-stage { display: flex; justify-content: center; }
svg.fn-svg {
  width: 100%; height: auto; max-width: 600px; display: block;
  touch-action: none; /* handle drags without scrolling the page */
  user-select: none; -webkit-user-select: none;
}

/* SVG primitives */
.f-grid { stroke: rgba(255,255,255,.06); stroke-width: 1; }
.f-axis { stroke: rgba(255,255,255,.28); stroke-width: 1.5; }
.f-tick-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.f-parent { fill: none; stroke: var(--parent); stroke-width: 2.5; stroke-dasharray: 6 6; opacity: .8; }
.f-log { fill: none; stroke: var(--aV); stroke-width: 3; stroke-linecap: round; }
.f-bar { fill: var(--image); opacity: .85; }
.f-sumline { fill: none; stroke: var(--aV); stroke-width: 2.5; }
.f-sumdot { fill: var(--aV); stroke: var(--bg-bot); stroke-width: 1.5; }
.f-asympt { stroke: var(--aV); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .6; }
.f-image  { fill: none; stroke: var(--image);  stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.f-asymp  { stroke: rgba(255,138,61,.35); stroke-width: 1.5; stroke-dasharray: 3 5; }
.f-cross  { stroke: rgba(255,138,61,.4); stroke-width: 1; stroke-dasharray: 4 4; }
.f-anchor-lbl { fill: var(--anchor); font-size: 13px; font-weight: 700; font-family: inherit; }

/* polynomials & rationals */
.f-hole { fill: var(--bg-bot); stroke: var(--image); stroke-width: 2.5; }
.f-handle circle.dot.den { fill: var(--anchor); }
.p-flag { text-align: center; font-size: 14px; font-weight: 700; margin: 8px 0 0; min-height: 1.4em; color: var(--aV); opacity: 0; transition: opacity .15s; }
.p-flag.show { opacity: 1; }

/* parabola marks */
.f-sym { stroke: rgba(160,107,255,.45); stroke-width: 1.5; stroke-dasharray: 5 5; }
.f-root { fill: var(--aV); stroke: var(--bg-bot); stroke-width: 1.5; }
.f-yint { fill: var(--anchor); stroke: var(--bg-bot); stroke-width: 1.5; }
.f-handle.shape .dot.shape { fill: var(--aH); }

/* three-forms panel */
.pforms { margin: 14px 0 4px; display: grid; gap: 8px; }
.pform { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.pform-tag { font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; min-width: 96px; }
.pform-eq { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pform-eq.none { color: var(--muted); font-weight: 600; font-size: 15px; }

/* draggable move-handle */
.f-handle { cursor: grab; }
.f-handle:active { cursor: grabbing; }
.f-handle circle.hit { fill: transparent; }
.f-handle circle.dot { fill: var(--anchor); stroke: var(--bg-bot); stroke-width: 2.5; }

/* equation readout */
.fn-eq {
  text-align: center; font-size: 22px; line-height: 1.6; margin: 16px 0 6px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border); overflow-x: auto;
}
.fn-eq sup { font-size: .7em; }
.fn-eq .frac { font-size: .78em; }

/* parameter chips */
.fn-params { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.pchip {
  flex: 1 1 auto; min-width: 120px; text-align: center; padding: 9px 10px;
  border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border);
}
.pchip .pv { font-size: 18px; font-weight: 800; }
.pchip .pn { display: block; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.pchip .pe { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; min-height: 1em; }
.pchip.v .pv { color: var(--aV); } .pchip.h .pv { color: var(--aH); }

/* parent-function picker */
.fn-parents { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; }
.fn-parents .lbl { width: 100%; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }

/* controls (reuse trig button look) */
.fn-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin-top: 16px; }
.fbtn {
  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;
}
.fbtn:hover { border-color: var(--accent); transform: translateY(-1px); }
.fbtn.on { border-color: var(--accent); background: var(--accent-soft); }
.fbtn.mono { font-size: 16px; min-width: 52px; }

.fn-slider { flex: 1 1 240px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.fn-slider .sl-name { min-width: 116px; color: var(--ink); }
.fn-slider .sl-name b { font-weight: 800; }
.fn-slider .sl-name.v b { color: var(--aV); } .fn-slider .sl-name.h b { color: var(--aH); }
.fn-slider input[type=range] { flex: 1; min-width: 0; width: 0; accent-color: var(--accent); height: 28px; }
.fn-slider .sl-val { min-width: 42px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

/* formula / fraction helpers (shared look with trig.css) */
.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); }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 .16em; }
.frac > .num { padding: 0 .5em .06em; }
.frac > .den { padding: .06em .5em 0; border-top: 2px solid currentColor; }

/* lines & linear systems */
.f-image-line { stroke-width: 3.5; stroke-linecap: round; }
.f-image-line.l1 { stroke: var(--image); }
.f-image-line.l2 { stroke: var(--aV); }
.l-leg { stroke: rgba(255,255,255,.45); stroke-width: 1.5; stroke-dasharray: 4 4; }
.l-leg-lbl { fill: var(--muted); font-size: 12px; font-weight: 700; font-family: inherit; }
.l-leg-lbl.mid { fill: var(--aH); }
.l-sol { fill: var(--aH); stroke: var(--bg-bot); stroke-width: 2; }
.l-sol-lbl { fill: var(--aH); font-size: 13px; font-weight: 800; font-family: inherit; }
.l-mid { fill: var(--aH); stroke: var(--bg-bot); stroke-width: 1.5; }
.f-handle .dot.l1 { fill: var(--image); } .f-handle .dot.l2 { fill: var(--aV); } .f-handle .dot.pt { fill: var(--anchor); }
.f-anchor-lbl.l1 { fill: var(--image); } .f-anchor-lbl.l2 { fill: var(--aV); } .f-anchor-lbl.pt { fill: var(--anchor); }
.fn-eq.lin { display: grid; gap: 6px; font-size: 20px; }
.lin-row { font-variant-numeric: tabular-nums; font-weight: 700; }
.lin-row.l1 { color: var(--image); } .lin-row.l2 { color: var(--aV); }

/* "what to notice" callout boxes */
.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.v { border-color: rgba(47,191,113,.4); }
.usebox.h { border-color: rgba(160,107,255,.4); }
