/* <nv-hos-compare> — HOS Monitoring System: one driver's day on an ELD log grid, without monitoring and with it.
   Markup and behaviour: hos-compare.js (header). Colours: token names of nv.css only, so both themes and the
   .nv-dark / .nv-light islands work. Size: the element is a block that fills its column; its height comes from its content —
   the log keeps the aspect of its viewBox, everything else is static text. A container query on the element itself picks the
   axis: ≥ 640 px the whole 24 h day, narrower the afternoon (12p–12a, the left of the log is cut off by
   preserveAspectRatio="xMaxYMid slice"), so the 42 minutes that matter stay wide enough to read on a phone.
   Only opacity and transform move; the divider moves by transform, the "after" side by clip-path set from --pos. */
nv-hos-compare { display: block; min-width: 0; container-type: inline-size; color: var(--nv-ink); font-family: var(--nv-font); }
nv-hos-compare .hc { position: relative; margin: 0; padding: clamp(14px, 3cqi, 22px); border-radius: var(--nv-r); overflow: hidden;
  background: radial-gradient(90% 60% at 100% 0%, color-mix(in srgb, var(--nv-hos) 11%, transparent), transparent 62%),
    linear-gradient(165deg, var(--nv-tile-2), var(--nv-tile) 48%, var(--nv-bg-2));
  box-shadow: inset 0 0 0 1px var(--nv-line-2); }

/* ── the two sides, named above the log (not clipped: both always read whole) ── */
nv-hos-compare .hc-heads { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
nv-hos-compare .hc-head { min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; transition: opacity var(--nv-dur) var(--nv-ease); }
nv-hos-compare .hc-head.hc-a { align-items: flex-end; text-align: right; }
nv-hos-compare .hc-tag { font: 650 10.5px/1 var(--nv-mono); letter-spacing: 0.1em; text-transform: uppercase; padding: 6px 9px 5px; border-radius: 7px; white-space: nowrap; }
nv-hos-compare .hc-b .hc-tag { color: color-mix(in srgb, var(--nv-bad) 80%, var(--nv-ink)); background: color-mix(in srgb, var(--nv-bad) 13%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nv-bad) 34%, transparent); }
nv-hos-compare .hc-a .hc-tag { color: color-mix(in srgb, var(--nv-hos) 80%, var(--nv-ink)); background: color-mix(in srgb, var(--nv-hos) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nv-hos) 38%, transparent); }
nv-hos-compare .hc-out { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.3; letter-spacing: -0.012em; text-wrap: balance; }
nv-hos-compare .hc-b .hc-out { color: var(--nv-bad); }
nv-hos-compare .hc-a .hc-out { color: var(--nv-ok); }

/* ── the stage: both logs in one cell; the "after" one is clipped from the left at --pos ── */
/* the divider rests where neither it nor the grip covers a label: 25 % of the whole day (between the 3a and 6a ticks),
   14.5 % of the afternoon (between the SB label and “0:42 left”) */
nv-hos-compare .hc-stage { --rest: 25%; --pos: var(--rest); position: relative; display: grid; border-radius: var(--nv-r-sm); overflow: hidden;
  touch-action: pan-y; -webkit-user-select: none; user-select: none; cursor: ew-resize; -webkit-tap-highlight-color: transparent; }
nv-hos-compare .hc-stage::after { content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--nv-line); pointer-events: none; }
nv-hos-compare .hc-layer { grid-area: 1 / 1; display: grid; grid-template-columns: 30px minmax(0, 1fr); padding: 8px 10px 8px 4px; min-width: 0; }
nv-hos-compare .hc-lb { background: var(--nv-bg-2); }
nv-hos-compare .hc-la { clip-path: inset(0 0 0 var(--pos)); background: radial-gradient(46% 70% at 74% 62%, color-mix(in srgb, var(--nv-hos) 15%, transparent), transparent 72%), var(--nv-tile-2); }
nv-hos-compare .hc-rows { display: grid; grid-template-rows: 28fr 50fr 50fr 50fr 50fr 4fr; font: 600 10.5px/1 var(--nv-mono); color: var(--nv-dim); letter-spacing: 0.04em; }
nv-hos-compare .hc-rows span { align-self: center; }
nv-hos-compare .hc-svg { display: block; width: 100%; height: auto; aspect-ratio: 960 / 232; overflow: hidden; }
nv-hos-compare .hc-svg path, nv-hos-compare .hc-svg rect, nv-hos-compare .hc-svg circle { vector-effect: non-scaling-stroke; }
nv-hos-compare .hc-svg text { font-family: var(--nv-mono); font-size: 19px; fill: var(--nv-dim); }
nv-hos-compare .hc-svg .hc-t { font-family: var(--nv-font); font-weight: 700; font-size: 21px; }
nv-hos-compare .hc-g1 { fill: none; stroke: var(--nv-line); stroke-width: 1; }
nv-hos-compare .hc-g2, nv-hos-compare .hc-fr { fill: none; stroke: var(--nv-line-2); stroke-width: 1; }
nv-hos-compare .hc-lim { fill: none; stroke: var(--nv-muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
nv-hos-compare .hc-duty { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
nv-hos-compare .hc-lb .hc-duty { stroke: var(--nv-muted); }
nv-hos-compare .hc-la .hc-duty { stroke: var(--nv-ink); }
nv-hos-compare .hc-viol { fill: none; stroke: var(--nv-bad); stroke-width: 9; stroke-linecap: round; }
/* label ink: the status colour pulled a fifth towards the ink, so small text keeps ≥ 4.5 : 1 over the tinted layers in both themes */
nv-hos-compare .hc-svg .hc-bad { fill: color-mix(in srgb, var(--nv-bad) 82%, var(--nv-ink)); }
nv-hos-compare .hc-svg .hc-warn { fill: color-mix(in srgb, var(--nv-warn) 82%, var(--nv-ink)); }
nv-hos-compare .hc-svg .hc-okt { fill: color-mix(in srgb, var(--nv-ok) 82%, var(--nv-ink)); }
nv-hos-compare .hc-svg .hc-inft { fill: color-mix(in srgb, var(--nv-info) 82%, var(--nv-ink)); }
nv-hos-compare .hc-m { stroke: var(--nv-tile-2); stroke-width: 2.5; }
nv-hos-compare .hc-m.w { fill: var(--nv-warn); }
nv-hos-compare .hc-m.k { fill: var(--nv-ok); }
nv-hos-compare .hc-m.i { fill: var(--nv-info); }
nv-hos-compare .hc-ring { fill: none; stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
nv-hos-compare .hc-ring.w { stroke: var(--nv-warn); }
nv-hos-compare .hc-ring.r { stroke: var(--nv-bad); }

/* the divider and its grip (in the SB row, which this day never uses, so the grip covers no line and no label); the range input over the stage is for the
   keyboard and screen readers (the script moves the divider by pointer) */
nv-hos-compare .hc-line { position: absolute; inset: 0; z-index: 2; transform: translateX(var(--pos)); pointer-events: none; }
nv-hos-compare .hc-line::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--nv-hos);
  box-shadow: 0 0 16px 2px color-mix(in srgb, var(--nv-hos) 55%, transparent); }
nv-hos-compare .hc-grip { position: absolute; left: 0; top: 44.5%; width: 44px; height: 44px; margin: -22px; border-radius: 50%; background: var(--nv-box);
  box-shadow: 0 0 0 2px var(--nv-hos), 0 8px 24px color-mix(in srgb, var(--nv-bg) 60%, transparent); }
nv-hos-compare .hc-grip::before, nv-hos-compare .hc-grip::after { content: ""; position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border: solid var(--nv-ink); border-width: 0 0 2.2px 2.2px; border-radius: 1px; }
nv-hos-compare .hc-grip::before { left: 13px; transform: rotate(45deg); }
nv-hos-compare .hc-grip::after { right: 13px; transform: rotate(-135deg); }
nv-hos-compare .hc-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
nv-hos-compare .hc-range:focus-visible ~ .hc-line .hc-grip { outline: 2px solid var(--nv-accent); outline-offset: 4px; }

/* ── what each side ends with (not clipped either) ── */
nv-hos-compare .hc-outs { display: grid; grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr); gap: 12px; margin-top: 12px; align-items: start; }
nv-hos-compare .hc-ob, nv-hos-compare .hc-oa { position: relative; min-width: 0; transition: opacity var(--nv-dur) var(--nv-ease); }
nv-hos-compare .hc-ob { padding: 12px 14px; border-radius: var(--nv-r-sm); background: color-mix(in srgb, var(--nv-bad) 6%, var(--nv-box)); box-shadow: inset 0 0 0 1px var(--nv-line); }
nv-hos-compare .hc-ob b { display: flex; align-items: center; gap: 8px; font-size: 14px; }
nv-hos-compare .hc-ob b svg { flex: none; color: var(--nv-dim); }
nv-hos-compare .hc-ob p { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--nv-muted); }
nv-hos-compare .hc-oa { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
nv-hos-compare .hc-beat { min-width: 0; transition: opacity 0.45s var(--nv-ease), transform 0.45s var(--nv-ease); }
nv-hos-compare .hc-alert { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 7px 8px; padding: 10px 12px 11px; border-radius: var(--nv-r-sm);
  background: color-mix(in srgb, var(--nv-warn) 9%, var(--nv-box)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--nv-warn) 36%, transparent); }
nv-hos-compare .hc-chip { font: 650 10px/1 var(--nv-mono); letter-spacing: 0.09em; text-transform: uppercase; padding: 5px 7px 4px; border-radius: 6px; white-space: nowrap;
  color: color-mix(in srgb, var(--nv-warn) 75%, var(--nv-ink)); background: color-mix(in srgb, var(--nv-warn) 12%, transparent); }
nv-hos-compare .hc-oa time { font: 500 11.5px/1 var(--nv-mono); color: var(--nv-muted); justify-self: end; font-variant-numeric: tabular-nums; }
nv-hos-compare .hc-alert p { grid-column: 1 / -1; margin: 0; font-size: 13px; line-height: 1.4; }
nv-hos-compare .hc-alert p b { font-weight: 700; }
nv-hos-compare .hc-step { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 3px 12px; font-size: 13px; line-height: 1.35; color: var(--nv-muted); }
nv-hos-compare .hc-step p { margin: 0; }
nv-hos-compare .hc-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--nv-info) 16%, transparent); color: var(--nv-info); }
nv-hos-compare .hc-done .hc-ic { background: color-mix(in srgb, var(--nv-ok) 18%, transparent); color: var(--nv-ok); }
nv-hos-compare .hc-done p { color: var(--nv-ok); font-weight: 650; }
nv-hos-compare .hc-cap { margin-top: 10px; font-size: 12.5px; line-height: 1.45; color: var(--nv-dim); }
nv-hos-compare .hc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the side the divider shows at the 11 h limit is the one in focus (set by the script; without it both read the same) */
nv-hos-compare .hc[data-side="after"] .hc-ob, nv-hos-compare .hc[data-side="before"] .hc-oa { opacity: 0.88; }
/* the replay of the "after" side during the opening sweep (script) */
nv-hos-compare .hc[data-replay] .hc-beat:not(.on) { opacity: 0.35; transform: none; }
nv-hos-compare .hc[data-replay] .hc-alert:not(.on) { opacity: 0.35; transform: none; }
nv-hos-compare .hc[data-replay] .hc-beat.on { opacity: 1; transform: none; }
nv-hos-compare .hc[data-ping] .hc-ring.w { animation: hc-ping 1.3s var(--nv-ease) 2; }
nv-hos-compare .hc[data-flash] .hc-ring.r { animation: hc-ping 1.1s var(--nv-ease); }
nv-hos-compare .hc[data-paused] * { animation-play-state: paused !important; }
@keyframes hc-ping { 0% { opacity: 0.95; transform: scale(0.7); } 100% { opacity: 0; transform: scale(2.6); } }

/* ── narrow: the afternoon only, the outcomes one under the other ── */
@container (max-width: 639.98px) {
  nv-hos-compare .hc-stage { --rest: 14.5%; }
  nv-hos-compare .hc-grip { width: 40px; height: 40px; margin: -20px; }
  nv-hos-compare .hc-dot { display: none; }
  nv-hos-compare .hc-svg { aspect-ratio: 480 / 232; }
  nv-hos-compare .hc-svg text { font-size: 18px; }
  nv-hos-compare .hc-svg .hc-t { font-size: 19px; }
  nv-hos-compare .hc-outs { grid-template-columns: minmax(0, 1fr); }
  nv-hos-compare .hc-layer { grid-template-columns: 26px minmax(0, 1fr); padding-right: 8px; }
}
@container (max-width: 459.98px) {
  nv-hos-compare .hc-sys { display: none; }
  nv-hos-compare .hc-svg text { font-size: 21px; }
  nv-hos-compare .hc-svg .hc-t { font-size: 22px; }
  nv-hos-compare .hc-out { font-size: 13px; }
  nv-hos-compare .hc-tag { letter-spacing: 0.08em; padding: 5px 7px 4px; }
}
@container (min-width: 900px) {
  nv-hos-compare .hc-svg text { font-size: 16px; }
  nv-hos-compare .hc-svg .hc-t { font-size: 17px; }
  nv-hos-compare .hc-rows { font-size: 12px; }
  nv-hos-compare .hc-layer { grid-template-columns: 36px minmax(0, 1fr); padding: 10px 14px 10px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  nv-hos-compare *, nv-hos-compare *::before, nv-hos-compare *::after { animation: none !important; transition: none !important; }
}

/* phones: no label under 11 px */
@media (max-width: 640px) {
  nv-hos-compare .hc-tag, nv-hos-compare .hc-chip, nv-hos-compare .hc-rows { font-size: 11px; }
}
