.secant-figure {
  grid-area: sketch;
  width: 100%;
  max-width: 38rem;
  min-width: 0;
  margin: 0;
  justify-self: center;
  align-self: end;
  color: var(--ink);
}

.secant-plot { display: block; width: 100%; height: auto; user-select: none; }
.secant-axes { stroke: var(--muted); stroke-width: 1.1; }
.secant-ticks { opacity: .65; }
.secant-projections { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 5; opacity: .64; }
.secant-projection-b { stroke: var(--accent-dark); }
.secant-labels { fill: var(--ink-soft); font: italic 18px/1 Georgia, serif; }
.secant-x-b, .secant-y-b { fill: var(--accent-dark); }
.secant-gap { fill: var(--accent); fill-opacity: .11; }
.secant-curve { stroke: currentColor; stroke-width: 2.9; stroke-linecap: round; }
.secant-tangent-guide { stroke: var(--muted); stroke-width: 1.55; stroke-linecap: round; }
.secant-line { stroke: var(--accent-dark); stroke-width: 2.15; }
.secant-anchor { fill: var(--ink); stroke: var(--accent-pale); stroke-width: 2; }
.secant-halo { fill: var(--accent-dark); fill-opacity: .12; stroke: var(--accent-dark); stroke-opacity: .68; }
.secant-dot { fill: var(--accent-dark); stroke: var(--accent-pale); stroke-width: 2; }
.secant-handle { touch-action: none; }
.secant-figure:has(.secant-control:not([hidden])) .secant-handle { cursor: grab; }
.secant-figure .secant-handle:active { cursor: grabbing; }
.secant-figure[data-tangent] .secant-dot { fill: none; stroke: var(--accent-dark); }
.secant-figure[data-tangent] :is(.secant-projection-b, .secant-height-a, .secant-tangent-guide) { opacity: 0; }
.secant-function-label { fill: currentColor; font: italic 21px Georgia, serif; }
.secant-figure[data-tangent] :is(.secant-curve, .secant-function-label) {
  color: color-mix(in srgb, var(--ink) 68%, var(--accent-pale));
}
.secant-slope-triangle { pointer-events: none; visibility: hidden; }
.secant-figure[data-tangent] .secant-slope-triangle { visibility: visible; }
.secant-triangle-legs {
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 1.25;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}
.secant-figure[data-tangent] .secant-triangle-legs { stroke-dashoffset: 0; }
.secant-slope-triangle text {
  opacity: 0;
  fill: var(--ink);
  stroke: var(--accent-pale);
  stroke-width: 3px;
  paint-order: stroke;
  font: italic 19px Georgia, serif;
}
.secant-figure[data-tangent] .secant-slope-triangle text { opacity: 1; }

.secant-figure figcaption {
  max-width: 30rem;
  margin: .7rem auto 0;
  color: var(--ink-soft);
}
.secant-control:not([hidden]) {
  --control-surface: color-mix(in srgb, var(--paper-strong) 52%, var(--accent-pale));
  display: flex;
  align-items: center;
  gap: clamp(.75rem, 2.5vw, 1.75rem);
  padding: .65rem clamp(.8rem, 2vw, 1.25rem) .45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--control-surface);
}
.secant-slider-group { display: grid; min-width: 0; flex: 1; }
.secant-range {
  --thumb-size: 16px;
  --guide-width: 20px;
  --guide-inset: calc(var(--thumb-size) / 2 + 2px);
  --thumb-center: calc(var(--thumb-size) / 2 + (100% - var(--thumb-size)) * var(--secant-position));
  --fill-end: var(--thumb-center);
  position: relative;
  display: grid;
}
.secant-guide-visible {
  --fill-end: calc(var(--thumb-center) - var(--guide-inset) - var(--guide-width));
}
.secant-thumb-path {
  position: absolute;
  inset: 0 calc(var(--thumb-size) / 2);
  overflow: hidden;
  pointer-events: none;
}
.secant-chevrons {
  position: absolute;
  left: calc(100% * var(--secant-position));
  top: 50%;
  width: var(--guide-width);
  height: 16px;
  transform: translate(calc(-100% - var(--guide-inset)), -50%);
  opacity: 0;
  transition-property: none;
  fill: none;
  stroke: var(--accent-dark);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.secant-chevrons path:first-child { opacity: .65; }
.secant-guide-visible .secant-chevrons { opacity: 1; }
.secant-figure[data-tangent] .secant-chevrons { visibility: hidden; }
.secant-control label, .secant-info { font: 600 1rem/1.25 system-ui, sans-serif; }
.secant-control label { color: var(--ink); cursor: pointer; }
.secant-arrived, .secant-figure[data-tangent] .secant-instruction { display: none; }
.secant-figure[data-tangent] .secant-arrived { display: inline; color: var(--accent-dark); }
.secant-figure input[type=range] {
  appearance: none;
  min-width: 0;
  width: 100%;
  height: 2.35rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: .25rem;
  background: transparent;
  accent-color: var(--accent-dark);
  cursor: pointer;
  --secant-track: linear-gradient(to right,
    var(--accent-dark) var(--fill-end),
    transparent var(--fill-end) var(--thumb-center),
    var(--line) var(--thumb-center)
  );
}
.secant-figure input::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--secant-track); }
.secant-figure input::-moz-range-track { height: 3px; border-radius: 2px; background: var(--secant-track); }
.secant-figure input::-webkit-slider-thumb {
  appearance: none;
  width: var(--thumb-size);
  height: var(--thumb-size);
  margin-top: -6.5px;
  border: 2px solid var(--accent-pale);
  border-radius: 50%;
  background: var(--accent-dark);
  box-shadow: 0 0 0 1px var(--accent-dark);
}
.secant-figure input::-moz-range-thumb {
  box-sizing: border-box;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border: 2px solid var(--accent-pale);
  border-radius: 50%;
  background: var(--accent-dark);
  box-shadow: 0 0 0 1px var(--accent-dark);
}
.secant-info {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: .45rem;
  margin-left: auto;
  padding: .4rem .65rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.secant-info:hover, .secant-info:focus-visible { color: var(--accent-dark); }
.secant-info-invited {
  border-color: var(--accent-dark);
  color: var(--accent-dark);
  background: color-mix(in srgb, var(--accent-dark) 6%, var(--control-surface));
}
.secant-info svg { width: 1rem; height: 1rem; color: var(--accent-dark); }
.secant-info[aria-expanded="true"] svg { transform: rotate(180deg); }
.secant-figure :is(button,input):focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 3px; }
.secant-range input:focus-visible { outline-offset: -2px; }
.secant-explanation {
  grid-area: explanation;
  justify-self: center;
  box-sizing: border-box;
  width: min(100%, 30rem);
  margin: .55rem 0 0;
  padding: .4rem .9rem .45rem;
  border-inline-start: 2px solid var(--accent-dark);
  color: var(--ink-soft);
  line-height: 1.55;
  text-wrap: pretty;
}
.secant-explanation strong { color: var(--ink); }
.secant-explanation h2 { margin: 0 0 .35rem; font-size: 1.3rem; }
.secant-explanation p { margin: 0; }
.secant-explanation p + p { margin-top: .5rem; }
@media (prefers-reduced-motion: no-preference) {
  .secant-chevrons { transition: opacity .24s ease-out; }
  .secant-guide-visible .secant-chevrons path { animation: secant-flow .78s ease-in-out .2s; }
  .secant-guide-visible .secant-chevrons path:last-child { animation-delay: .32s; }
  @keyframes secant-flow {
    45% { opacity: 1; transform: translateX(-2px); }
  }
  .secant-info-invited { animation: secant-info-cue .75s ease-out .42s; }
  @keyframes secant-info-cue {
    40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-dark) 20%, transparent); }
  }
  .secant-height-a, .secant-projection-b, .secant-tangent-guide { transition: opacity 190ms ease-in-out; }
  .secant-curve, .secant-function-label { transition: color 190ms ease-in-out; }
  .secant-slope-triangle { transition: visibility 0s linear 150ms; }
  .secant-triangle-legs { transition: stroke-dashoffset 150ms ease-out; }
  .secant-slope-triangle text { transition: opacity 120ms ease-out; }
  .secant-figure[data-tangent] .secant-slope-triangle { transition-delay: 0s; }
  .secant-figure[data-tangent] .secant-triangle-legs {
    transition: stroke-dashoffset 420ms cubic-bezier(.2, .65, .35, 1);
  }
  .secant-figure[data-tangent] .secant-slope-triangle text { transition: opacity 180ms ease-out 420ms; }
  .secant-waiting .secant-plot { opacity: 0; }
  .secant-intro :is(.secant-axis-x, .secant-axis-y, .secant-curve, .secant-tangent-guide, .secant-line) {
    stroke-dasharray: 1 1;
    animation: secant-curve-in var(--draw-time) cubic-bezier(.27,.52,.38,1) var(--start-at) both;
  }
  .secant-axis-x { --start-at: 0ms; --draw-time: 380ms; }
  .secant-axis-y { --start-at: 360ms; --draw-time: 360ms; }
  .secant-curve { --start-at: 760ms; --draw-time: 830ms; }
  .secant-tangent-guide { --start-at: 1640ms; --draw-time: 380ms; }
  .secant-line { --start-at: 2140ms; --draw-time: 590ms; }
  .secant-intro :is(.secant-arrow-x, .secant-arrow-y, .secant-ticks, .secant-anchor, .secant-handle, .secant-labels, .secant-projections, .secant-gap, .secant-function-label) {
    animation: secant-geometry-in 280ms ease-out var(--start-at) backwards;
  }
  .secant-arrow-x { --start-at: 340ms; }
  .secant-arrow-y, .secant-ticks { --start-at: 680ms; }
  .secant-anchor { --start-at: 1500ms; }
  .secant-function-label { --start-at: 1480ms; }
  .secant-handle, .secant-labels, .secant-projections { --start-at: 2010ms; }
  .secant-gap { --start-at: 2560ms; }
  .secant-info svg { transition: transform 160ms ease-out; }
  .secant-explanation:not([hidden]) { animation: secant-explain-in 170ms ease-out both; }
}
@keyframes secant-curve-in { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes secant-geometry-in { from { opacity: 0; } }
@keyframes secant-explain-in { from { transform: translateY(-.2rem); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .secant-plot, .secant-plot * { transition-property: none; }
}

@media (max-width: 32rem) {
  .secant-labels { font-size: 20px; }
  .secant-figure figcaption { padding-inline: 0; }
  .secant-control:not([hidden]) { gap: .65rem; }
}
@media (forced-colors: active) {
  .secant-figure input[type=range], .secant-figure input::-webkit-slider-thumb { appearance: auto; }
  .secant-curve, .secant-anchor { stroke: CanvasText; }
  .secant-line, .secant-halo, .secant-dot { stroke: Highlight; }
}
