/* The "moves freely" gap section (pages/partials/gap.html, js/fits.js, js/gap-live.js). Loaded after content.css. */
/* One block: the 3D ring and the magnified gap side by side, the gap slider and its verdict right under them. */
.fit.gapx { display: block; --gap-stick: #c8893b; --gap-weld: #d2382d; }
.gapx-head { max-width: 68ch; margin-bottom: var(--s4); }
.gapx-head h3 { font-size: var(--t-lg); }
.gapx-head p { color: var(--muted); font-size: var(--t-sm); margin: var(--s2) 0 0; }

.gapx-panel { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-areas: "live zoom" "ctl ctl"; border: 1px solid var(--line-strong); background: var(--surface); }
.gapx-panel > * { min-width: 0; }

/* the 3D ring */
.gapx .gaplive { grid-area: live; margin: 0; border: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.gapx .gaplive-view { position: relative; aspect-ratio: auto; flex: 1; min-height: 280px; }
.gapx .gaplive-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.gapx .gaplive-view canvas:active { cursor: grabbing; }
.gapx .gaplive figcaption { padding: var(--s2) var(--s3); border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--muted); }
.gapx-viewbtns { position: absolute; left: var(--s3); bottom: var(--s3); max-width: calc(100% - 2 * var(--s3)); }
.gapx-viewbtns.seg button { min-height: 30px; padding: .45rem .6rem .35rem; }

/* the magnified gap */
.gapx .gapx-zoom { grid-area: zoom; margin: 0; border: 0; display: flex; flex-direction: column; }
.gapx .gapx-zoom svg { flex: none; }
.gapx .gapx-zoom figcaption { flex: 1; align-content: center; }
.gapx .gapx-zoom figcaption { font-size: var(--t-xs); }
.gapx .gapx-zoom figcaption b { color: var(--ink); flex-basis: 100%; }
.gapx .g-stick { fill: var(--gap-stick); opacity: .8; }
.gapx .g-weld { fill: var(--gap-weld); }
.gapx .k-stick { background: var(--gap-stick); } .gapx .k-weld { background: var(--gap-weld); } .gapx .k-loose { background: var(--surface); }
.gapx .g-label, .gapx .g-part { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.gapx .g-part { font: 700 11px var(--font); letter-spacing: .08em; text-transform: uppercase; fill: var(--muted); stroke: var(--steel-fill); }
.gapx .g-label-stick { fill: color-mix(in srgb, var(--gap-stick) 60%, var(--ink)); }
.gapx .g-dim-stick { stroke: color-mix(in srgb, var(--gap-stick) 60%, var(--ink)); }
.gapx .g-label-free, .gapx[data-verdict=good] .gapx-sum b:last-child { fill: var(--ok); color: var(--ok); }
.gapx .g-dim-free { stroke: var(--ok); }
.gapx[data-verdict=mid] .g-label-free { fill: var(--warn); } .gapx[data-verdict=mid] .g-dim-free { stroke: var(--warn); }
.gapx .g-label-weld { fill: var(--err); }

/* the slider, the sum and the verdict */
.gapx-ctl { grid-area: ctl; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s3) var(--s6); align-items: start; padding: var(--s4); border-top: 1px solid var(--line-strong); background: color-mix(in oklch, var(--surface-2) 35%, var(--surface)); }
.gapx-range { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: var(--s1) var(--s3); grid-row: span 2; }
.gapx-range label { font-weight: 700; color: var(--ink); }
.gapx-range output { font: 700 var(--t-xl)/1 var(--mono); color: var(--ink); }
.gapx-range input { grid-column: 1 / -1; width: 100%; margin: var(--s2) 0 0; accent-color: var(--laser-ink); height: 28px; cursor: pointer; }
.gapx-scale { grid-column: 1 / -1; margin: 0 8px; }   /* 8 px: half the slider's thumb, so the zones sit under its travel */
.gapx-zones { display: flex; height: 18px; font: 700 10px/18px var(--font); letter-spacing: .06em; text-transform: uppercase; text-align: center; color: var(--surface); white-space: nowrap; }
.gapx-zones span { overflow: hidden; }
/* 0.05 to 0.8: welded up to 0.2, a twist at 0.25 and 0.3, free from 0.35 (edges halfway between steps) */
.gapx-zones .z-bad { flex: 0 0 23.333%; background: var(--err); }
.gapx-zones .z-mid { flex: 0 0 13.333%; background: var(--warn); }
.gapx-zones .z-good { flex: 1; background: var(--ok); }
.gapx-ticks { position: relative; height: 1.5rem; font: 500 var(--t-xs)/1 var(--mono); color: var(--muted); }
.gapx-ticks span { position: absolute; top: 7px; transform: translateX(-50%); }
.gapx-ticks span::before { content: ''; position: absolute; left: 50%; top: -7px; height: 5px; border-left: 1px solid var(--line-strong); }
.gapx-ticks span.ours { color: var(--ink); font-weight: 700; }
.gapx-ticks i { position: absolute; right: -8px; top: 22px; font-style: normal; }
.gapx-sum { margin: 0; font: 500 var(--t-sm)/1.4 var(--mono); color: var(--muted); }
.gapx-sum b { color: var(--ink); white-space: nowrap; }
.gapx[data-verdict=mid] .gapx-sum b:last-child { color: var(--warn); }
.gapx[data-verdict=bad] .gapx-sum b:last-child { color: var(--err); }
.gapx .fit-verdict { margin: 0; min-height: 5.6em; align-content: start; }
.gapx .fit-verdict b { font-size: var(--t-base); }
.gapx-note { margin: var(--s3) 0 0; font-size: var(--t-sm); color: var(--muted); max-width: 80ch; }
.gapx-note b { color: var(--ink); }

@media (max-width: 860px) {
  .gapx-panel { grid-template-columns: minmax(0, 1fr); grid-template-areas: "live" "ctl" "zoom"; }
  .gapx .gaplive { border-right: 0; }
  .gapx .gaplive-view { min-height: 0; aspect-ratio: 4 / 3; flex: none; }
  .gapx-ctl { grid-template-columns: minmax(0, 1fr); padding: var(--s3); border-bottom: 1px solid var(--line-strong); }
  .gapx-range { grid-row: auto; }
  .gapx .fit-verdict { min-height: 7em; }
  /* the drawing is about half size on a phone: larger type inside it */
  .gapx .g-label { font-size: 21px; stroke-width: 6px; } .gapx .g-part, .gapx .g-scale-t { font-size: 17px; }
  .gapx-viewbtns { left: var(--s2); bottom: var(--s2); max-width: calc(100% - 2 * var(--s2)); }
}
