/* The shared tool library's look (PACE_PLAN §5a): the tool slots of a subsystem page, the explorer
   frame, controls, drawings, plots and the design instruments. Loaded only on pages with tools. */

.tool { container-type: inline-size; margin: 1.4rem 0 2rem; padding: clamp(12px, 2vw, 20px); border: 1px solid var(--line);
  border-radius: 14px; background: var(--card); }
.prose .tool .tool__title { margin: 0 0 12px; }
.tool__fallback { margin: 0; color: var(--dim); }
.prose .tool ul, .prose .tool ol { margin: 0; padding: 0; list-style: none; }
.prose .tool li::before { content: none; }
.prose .tool p { margin: 0; }
.prose .tool table { margin: 0; }

/* the explorer frame */
.xf { display: grid; gap: 14px; }
.xf__main, .xf__side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.xf__stage { border-radius: 10px; background: var(--mint-soft); overflow: hidden; }
.xf__svg { display: block; width: 100%; max-width: 760px; height: auto; margin: 0 auto; touch-action: manipulation; }
.xf__info { min-height: 2.9em; color: var(--dim); font-size: .9rem; line-height: 1.45; }
.xf__status { min-height: 4.4em; color: var(--ink); font-size: .95rem; line-height: 1.5; }
.xf__controls, .xf__mode { display: grid; gap: 14px; align-content: start; }
.xf__note { color: var(--teal-deep); font-size: .9rem; line-height: 1.45; }
.xf__note:empty { display: none; }
.xf__duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.xf__widget { margin: 0; text-align: center; }
.xf__widget svg { display: block; width: 100%; max-width: 160px; height: auto; margin: 0 auto; }
.xf__widget figcaption { margin-top: 4px; color: var(--dim); font-size: .8rem; line-height: 1.35; }
.xf__row { display: flex; flex-wrap: wrap; gap: 8px; }
.xf__readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: 10px 16px; margin: 0;
  padding-top: 10px; border-top: 1px solid var(--line); }
.xf__readout dt { color: var(--dim); font-size: .8rem; line-height: 1.3; }
.xf__readout dd { margin: 2px 0 0; color: var(--ink); font-size: .95rem; font-weight: 640; line-height: 1.35; font-variant-numeric: tabular-nums; }
.xf__notes, .gd__notes { color: var(--dim); font-size: .85rem; line-height: 1.5; }
.xf__plot { padding: 6px 8px 2px; background: var(--card); }
@container (min-width: 44rem) {
  .xf__side { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px 24px; }
  .xf__side .xf__readouts { padding-top: 0; border-top: 0; align-content: start; }
}

/* Transmission: keep the meshing pair and its three worked ratios in view together. */
.xf--gear-pair .xf__svg { max-width: 17rem; }
.pair__shafts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin: 0; padding: 0 12px 12px; text-align: center; font-size: .85rem; line-height: 1.4; }
.pair__shafts dt { font-weight: 650; }
.pair__shafts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.xf--gear-pair .xf__info { min-height: 0; }
.xf--gear-pair .xf__readouts { grid-template-columns: 1fr; align-content: start; gap: 10px; }
.xf--gear-pair .xf__readout + .xf__readout { padding-top: 10px; border-top: 1px solid var(--line); }
.xf--gear-pair .xf__readout dt strong { color: var(--ink); font-size: .98rem; }
.pair__definition { display: block; margin-top: 2px; }
.xf--gear-pair .xf__readout dd { color: var(--teal-deep); font-size: 1.05rem; }
.xf--gear-pair .xf__side { grid-template-columns: 1fr; padding-top: 12px; border-top: 1px solid var(--line); }
@container (min-width: 34rem) {
  .xf--gear-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; }
  .xf--gear-pair .xf__readouts { border-top: 0; padding: 0; }
  .xf--gear-pair .xf__side, .xf--gear-pair .xf__notes { grid-column: 1 / -1; }
  .xf--gear-pair .xf__controls { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
}

/* controls */
.ctl { display: grid; gap: 6px; min-width: 0; }
.ctl__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px; }
.ctl__label { color: var(--ink); font-size: .9rem; font-weight: 630; }
.ctl__value { color: var(--teal-deep); font-weight: 650; font-variant-numeric: tabular-nums; }
.ctl__range { width: 100%; min-height: 30px; margin: 0; accent-color: var(--teal); cursor: pointer; }
.ctl__hint { color: var(--dim); font-size: .8rem; line-height: 1.35; }
.ctl__select { min-height: 40px; padding: 4px 8px; border: 1px solid #748a79; border-radius: 7px; background: var(--card);
  color: var(--ink); font: inherit; font-size: .9rem; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; }
.seg__btn, .btn-tool { min-height: 40px; padding: 6px 12px; border: 1px solid #748a79; border-radius: 7px; background: var(--card);
  color: var(--ink); font: inherit; font-size: .9rem; font-weight: 620; cursor: pointer; }
.seg__btn:hover, .btn-tool:hover { border-color: var(--teal); background: var(--mint-soft); }
.seg__btn[aria-pressed="true"] { border-color: var(--teal); background: var(--mint); color: var(--teal-deep); box-shadow: inset 0 -2px var(--teal); }
.seg__btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-tool--primary { border-color: var(--teal); background: var(--teal); color: #fff; }
.btn-tool--primary:hover { background: var(--teal-deep); color: #fff; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.transport__speed { margin-left: 4px; color: var(--dim); font-size: .85rem; }
.seg__btn:focus-visible, .btn-tool:focus-visible, .ctl__select:focus-visible, .pedal:focus-visible, .plot__svg:focus-visible {
  outline: 3px solid var(--teal); outline-offset: 2px; }
.lever, .pedal { touch-action: none; cursor: grab; }
.lever.is-dragging { cursor: grabbing; }
.lever__gate { fill: none; stroke: #b9c5be; stroke-width: 9; stroke-linecap: round; }
.lever__mark { fill: var(--dim); font-size: 15px; font-weight: 650; }
.lever__knob { fill: var(--teal); stroke: #fff; stroke-width: 2.5; }
.pedal__floor { stroke: #b9c5be; stroke-width: 3; }
.pedal__pivot { fill: #6b7f75; }
.pedal__arm { stroke: #6b7f75; stroke-width: 7; stroke-linecap: round; }
.pedal__pad { fill: #34433c; }

/* drawing pieces */
.label { fill: var(--ink); font-size: 17px; font-weight: 600; }
.label--gear { fill: var(--teal-deep); font-weight: 750; }
.label--small { font-weight: 500; fill: var(--dim); }
.gear__body { fill: #e3e9e5; stroke: #5d7268; stroke-width: 1.2; }
.gear__hub { fill: #f6f7f2; stroke: #5d7268; stroke-width: 1.4; }
.gear__witness { stroke: #5d7268; stroke-width: 2.2; stroke-linecap: round; }
.gear__mark { fill: #b4532a; }
.gear-side__body { fill: #e3e9e5; stroke: #6b7f75; stroke-width: 1.1; }
.gear-side__teeth { fill: none; stroke: #6b7f75; stroke-width: 1; }
.shaft { fill: #bcc8c1; stroke: #6b7f75; stroke-width: 1; }
.shaft--hollow { fill: #cfd8d3; fill-opacity: .7; }
.flowbar { fill: var(--teal); opacity: 0; }
.flowbar.is-flow { opacity: .9; }
.dogs { fill: #8e9c94; }
.sleeve__band .gear-side__body { fill: #f1e2cc; stroke: #94673b; }
.sleeve__band .gear-side__teeth { stroke: #b48a5c; }
.idler .gear-side__body { fill-opacity: .8; stroke-dasharray: 3 2; }
.flywheel .gear-side__body { fill: #d3dbd6; }
.clutch-disc .gear-side__body { fill: #ead8b8; stroke: #8a6d45; }
.is-flow .gear-side__body, .is-flow.gear-side__body, .is-flow > .gear__body, .is-flow .gear__body { fill: var(--mint); stroke: var(--teal); stroke-width: 2; }
.is-flow .gear-side__teeth { stroke: var(--teal-deep); }
.shaft.is-flow { fill: var(--teal); }
.xf__part { cursor: help; }
.xf__part:focus { outline: none; }
.xf__part:focus-visible .gear-side__body, .xf__part:focus-visible .gear__body, .shaft.xf__part:focus-visible,
.xf__part:focus-visible .pls__arms, .dct__clutch.xf__part:focus-visible { stroke: #0b4f44; stroke-width: 3; }
.spring, .link__bar, .arrow { fill: none; stroke: #5d7268; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.damper__body, .damper__rod { fill: none; stroke: #5d7268; stroke-width: 2; }
.link__pin { fill: #f6f7f2; stroke: #5d7268; stroke-width: 1.5; }

/* the planetary set */
.pls__ring .gear__body { fill: #e3e9e5; }
.pls__sun .gear__body { fill: #dce7f1; stroke: #49708f; }
.pls__planet .gear__body { fill: #f2e6d4; stroke: #8a6d45; }
.pls__arms { fill: none; stroke: #94673b; stroke-width: 6; stroke-linejoin: round; opacity: .55; }
.pls__carrier.is-flow .pls__arms { stroke: var(--teal); opacity: .9; }
.is-held .gear__body, .pls__carrier.is-held .pls__arms { fill: #9aa7a0; stroke: #3f4d46; }
.pls__carrier.is-held .pls__arms { fill: none; opacity: .9; }
.pls__zero { stroke: #9aa7a0; stroke-width: 1.5; }
.pls__bar--sun { fill: #49708f; }
.pls__bar--carrier { fill: #94673b; }
.pls__bar--ring { fill: #5b8a5e; }

/* the dual clutch */
.dct__clutch { fill: #ead8b8; stroke: #8a6d45; stroke-width: 1.2; }
.dct__clutch.is-flow { stroke: var(--teal); stroke-width: 2.4; }
.dct__fill { fill: var(--teal); opacity: .75; pointer-events: none; }

/* the belt variator */
.cvt__sheave { fill: #e3e9e5; stroke: #6b7f75; stroke-width: 1.2; }
.cvt__spokes { stroke: #6b7f75; stroke-width: 2.4; stroke-linecap: round; }
.cvt__axle { fill: #6b7f75; }
.cvt__belt { fill: none; stroke: #34433c; stroke-width: 7; stroke-linejoin: round; }
.cvt__beltflow { fill: none; stroke: #ead8b8; stroke-width: 2; stroke-dasharray: 5 9; }
.cvt__cone { fill: #cfd8d3; stroke: #6b7f75; stroke-width: 1.2; }
.cvt__beltsec { fill: #34433c; }

/* plots */
.plot { width: 100%; }
.plot__svg { display: block; max-width: 100%; touch-action: pan-y; }
.plot__grid line { stroke: #e2e8e4; stroke-width: 1; }
.plot__ticks text { fill: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.plot__axis { fill: var(--ink); font-size: 13px; font-weight: 620; }
.plot__frame { fill: none; stroke: #c9d3cd; }
.plot__series { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.plot__label { font-size: 12px; font-weight: 750; }
.plot__marker { fill: #fff; stroke: #34433c; stroke-width: 2.4; }
.plot__note { fill: #34433c; font-size: 12px; font-weight: 650; }
.plot__line { stroke: #9aa7a0; stroke-width: 1.5; }
.plot__line.is-grip { stroke: #b4532a; stroke-dasharray: 6 4; }
.plot__note.is-grip { fill: #b4532a; }
.plot__line.is-now { stroke: var(--teal); stroke-width: 2; }
.plot__line.is-divide { stroke-dasharray: 3 3; }
.plot__cursor { stroke: #6b7f75; stroke-width: 1; stroke-dasharray: 2 3; }
.s-1 { stroke: #0f766e; fill: #0f766e; }
.s-2 { stroke: #2563eb; fill: #2563eb; }
.s-3 { stroke: #7c3aed; fill: #7c3aed; }
.s-4 { stroke: #c2410c; fill: #c2410c; }
.s-5 { stroke: #a16207; fill: #a16207; }
.plot__series.s-1, .plot__series.s-2, .plot__series.s-3, .plot__series.s-4, .plot__series.s-5 { fill: none; }
.plot__series.s-load { stroke: #1f2a24; stroke-width: 2.6; }
.plot__label.s-load { fill: #1f2a24; }
.plot__series.s-level { stroke: #7b8a82; stroke-dasharray: 6 5; }

/* the design instrument */
.gd { display: grid; gap: 16px; }
.gd__main, .gd__inputs { display: grid; gap: 12px; align-content: start; min-width: 0; }
.gd__set { display: grid; gap: 12px; margin: 0; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 10px; }
.gd__set legend { padding: 0 6px; color: var(--ink); font-size: .9rem; font-weight: 700; }
.gd__cursor { color: var(--dim); font-size: .85rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
.gd__warn { color: #9a3b2c; font-weight: 620; }
.gd__warn:empty { display: none; }
.gd__summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 10px 16px; margin: 0; }
.gd__summary dt { color: var(--dim); font-size: .8rem; }
.gd__summary dd { margin: 2px 0 0; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.gd__tables { display: grid; gap: 14px; }
.gd__table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.gd__table caption { padding-bottom: 4px; color: var(--ink); font-weight: 700; text-align: left; }
.gd__table th, .gd__table td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.gd__table thead th { color: var(--dim); font-size: .78rem; font-weight: 650; }
.gd__foot { color: var(--dim); font-size: .8rem; }
@container (min-width: 50rem) {
  .gd { grid-template-columns: minmax(0, 1.6fr) minmax(15rem, 1fr); }
  .gd__notes { grid-column: 1 / -1; }
  .gd__tables { grid-template-columns: 1fr 1fr; }
}

/* The engine sizing calculator: the reference engine's curves and the design's point. */
.plot__series.s-torque { stroke: #0b8f7f; }
.plot__series.s-power { stroke: #c2410c; }
.plot__series.s-design, .plot__line.is-design { stroke: #34433c; stroke-width: 1.8; stroke-dasharray: 6 5; }
.plot__marker.is-design { fill: #34433c; stroke: #fff; stroke-width: 2; }
.plot__label.s-torque, .plot__label.s-power { fill: #34433c; }

/* Subsystem pages, the reading parts (engine-reading.js groups the headings into sections). A row of
   alternatives, the h4 sections under one heading, stands side by side as cards: picture, name,
   text, plus and minus, and the picture's credit at the foot. */
.prose--subsystem :is(.engine-topic, .engine-section):has(> .engine-type) {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: stretch;
}
@media (min-width: 620px) {
  .prose--subsystem :is(.engine-topic, .engine-section):has(> .engine-type) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {   /* three or more alternatives: three in a row; exactly four: two rows of two, no gap */
  .prose--subsystem :is(.engine-topic, .engine-section):has(> .engine-type ~ .engine-type ~ .engine-type) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .prose--subsystem :is(.engine-topic, .engine-section):has(> .engine-type ~ .engine-type ~ .engine-type ~ .engine-type):not(:has(> .engine-type ~ .engine-type ~ .engine-type ~ .engine-type ~ .engine-type)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.prose--subsystem :is(.engine-topic, .engine-section):has(> .engine-type) > :not(.engine-type) { grid-column: 1 / -1; margin-bottom: 0; }
.prose--subsystem .engine-type {
  display: flex; flex-direction: column; margin: 0; padding: 14px 16px 16px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card);
}
.prose--subsystem .engine-type + .engine-type { margin-top: 0; }
.prose--subsystem .engine-type > h4 { margin: 0 0 8px; }
.prose--subsystem .engine-type p { font-size: .95rem; line-height: 1.55; }
.prose--subsystem .engine-type :is(.engine-reading-pair, .figure) { display: contents; }
.prose--subsystem .engine-type .figure__frame {
  order: -1; display: grid; place-items: center; aspect-ratio: 16 / 10; margin: 0 0 12px; overflow: hidden; background: #fbfcf8;
}
.prose--subsystem .engine-type .figure__frame img { width: 100%; height: 100%; object-fit: contain; }
.prose--subsystem .engine-type .figure__caption { order: 9; margin: auto 0 0; padding-top: 12px; font-size: .76rem; }
.prose--subsystem .engine-type ul { margin: 10px 0 0; }
.prose--subsystem .engine-type ul > li { margin: 0 0 6px; padding-left: 1.6rem; font-size: .92rem; line-height: 1.45; }
.prose--subsystem .engine-type ul > li::before {
  display: block; content: "+"; left: 0; top: -.08em; width: 1.15rem; height: auto; border-radius: 0; background: none;
  transform: none; color: var(--teal); font-size: 1.1rem; font-weight: 800; line-height: 1.3; text-align: center;
}
.prose--subsystem .engine-type ul > li:nth-child(2)::before { content: "−"; color: #a14622; }

/* "Try this" with folded answers (build.py: fold_answers). */
.prose--subsystem ol.tasks > li { margin-bottom: 8px; }
.task > summary { cursor: pointer; }
.task > summary::marker { color: var(--teal); }
.task > summary strong { color: var(--ink); }
.task__answer { margin: 8px 0 6px; padding: 10px 14px; border-left: 3px solid var(--teal); border-radius: 0 8px 8px 0; background: var(--mint-soft); }
.task:not([open]) > :not(summary) { display: none; }

/* A design instrument's readouts in named groups. */
.prose .tool .gd__group { margin: 8px 0 -4px; color: var(--teal-deep); font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }

/* A subsystem page's opening part: a list under a ### heading is a row of tiles with one anatomy,
   a marker, a short title and one line (what the subsystem must deliver; the page's steps). */
.prose--subsystem > .engine-section:first-of-type > .engine-topic > :is(ul, ol) {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.75rem), 1fr)); gap: 12px; margin: 12px 0 0;
}
.prose--subsystem > .engine-section:first-of-type > .engine-topic > :is(ul, ol) > li {
  margin: 0; padding: 44px 14px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  font-size: .92rem; line-height: 1.45;
}
.prose--subsystem > .engine-section:first-of-type > .engine-topic > ul > li::before { left: 18px; top: 19px; }
.prose--subsystem > .engine-section:first-of-type > .engine-topic > ol > li::before { left: 14px; top: 14px; }
.prose--subsystem > .engine-section:first-of-type > .engine-topic > :is(ul, ol) > li > strong:first-child {
  display: block; margin-bottom: 4px; color: var(--ink); font-size: 1rem;
}

/* The Engine page's opening: the picture starts beside the heading, so less space is left under the first paragraph. */
@media (min-width: 720px) {
  .page-fundamentals-engine > .engine-section:first-of-type > .engine-reading-pair > .figure { margin-top: calc(-1.12 * clamp(28px, 3.1vw, 40px) - 20px); }
}
