/* Help inside the info bubbles (templates/_info.html): small diagrams and animations that teach
   faster than words. Loaded after app.css. Colours are the app.css tokens, so both themes work;
   every animation stops under prefers-reduced-motion. */

/* placement: a bubble near the right edge opens leftwards */
details.info.end .info-panel { left: auto; right: -10px; }
.info-panel { max-height: min(78vh, 640px); overflow-y: auto; }
.info-panel h4 { font: 600 .74rem/1.3 var(--font-display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .6rem 0 .2rem; }
.info-panel dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .6rem; margin: .3rem 0; }
.info-panel dt { font-weight: 600; } .info-panel dd { margin: 0; }
.info-panel kbd { font: .78rem var(--font-mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; background: var(--bg); }
.info-panel code { background: var(--chip); padding: 0 .25rem; border-radius: 4px; }
.info-ex span { white-space: pre-wrap; }
@media (max-width: 640px) { details.info.end .info-panel { right: .5rem; left: .5rem; } .info-panel { max-height: 62vh; } }
/* a bubble inside a heading or a table header keeps body text */
h1 details.info, h2 details.info, h3 details.info, th details.info { font: 400 1rem/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
details.info { margin-left: .15rem; }

/* svg diagrams: lines in the ink colour, the critical path in the accent */
svg.hd { display: block; width: 100%; height: auto; max-height: 120px; color: var(--ink); }
.hd .hd-e { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.hd .hd-n rect, .hd .hd-n circle, .hd-views .hd-n rect { fill: var(--card); stroke: var(--muted); stroke-width: 1.4; }
.hd .hd-n.crit rect { stroke: var(--accent); stroke-width: 2; }
.hd .hd-crit { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 5 4; animation: hd-flow 1.2s linear infinite; }
@keyframes hd-flow { to { stroke-dashoffset: -18; } }
.hd .hd-t text, .hd text.hd-t { fill: var(--ink); font: 10px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; text-anchor: middle; }
.hd text.hd-t.s { font-size: 8.5px; }
.hd .hd-q, .hd-views .hd-q { fill: var(--accent); font: 700 9px var(--font-mono); text-anchor: middle; }
.hd .hd-std { fill: color-mix(in srgb, #a78bfa 22%, var(--card)); stroke: #a78bfa; stroke-width: 1.6; }
.hd .hd-pulse { stroke: #a78bfa; stroke-dasharray: 4 4; animation: hd-flow 1.2s linear infinite; }
.hd .hd-cur { fill: none; stroke: var(--accent); stroke-width: 2.4; }
.hd .hd-wo { fill: color-mix(in srgb, var(--accent) 16%, var(--card)); stroke: var(--accent); stroke-width: 1.2; }
.hd-cap { color: var(--muted); font-size: .76rem; margin-top: .3rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.hd-sw { display: inline-block; width: 16px; height: 0; border-top: 2.4px dashed var(--accent); }

/* the four views as thumbnails */
.hd-views { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.hd-views.two { grid-template-columns: 1fr 1fr; }
.hd-views figure { margin: 0; text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: .25rem; }
.hd-views figure.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.hd-views svg { width: 100%; height: auto; display: block; }
.hd-views .hd-e { fill: none; stroke: var(--muted); stroke-width: 1.4; }
.hd-views .hd-bar { fill: var(--muted); } .hd-views .hd-bar.crit { fill: var(--accent); }
.hd-views .hd-slack { fill: var(--muted); opacity: .25; }
.hd-views .hd-n-one { fill: var(--card); stroke: var(--accent); stroke-width: 1.6; }
.hd-views figcaption { font-size: .7rem; color: var(--muted); margin-top: .15rem; line-height: 1.25; }

/* the batch table: the cursor walks down, the last value turns red */
.hd-bt { font: .78rem var(--font-mono); }
.hd-btr { display: grid; grid-template-columns: 1fr 1fr 1.4rem; align-items: center; gap: .3rem; padding: .2rem .35rem; border-bottom: 1px solid var(--line); }
.hd-bth { font: 600 .72rem/1.2 -apple-system, BlinkMacSystemFont, sans-serif; color: var(--muted); }
.hd-bth i { font-style: normal; font-weight: 400; } .hd-bth small { font-weight: 400; }
.hd-cell { display: inline-block; min-width: 2.6rem; padding: 0 .3rem; border-radius: 4px; }
.hd-tk { color: var(--ok); }
.hd-btr.r1 .hd-cell { animation: hd-cur 6s infinite; } .hd-btr.r2 .hd-cell { animation: hd-cur 6s 2s infinite; }
.hd-btr.r3 .hd-cell { animation: hd-red 6s infinite; } .hd-btr.r3 .hd-tk { color: var(--err); animation: hd-show 6s infinite; }
.hd-btr.r3 { animation: hd-row 6s infinite; }
@keyframes hd-cur { 0%, 33% { box-shadow: 0 0 0 1.5px var(--accent); } 34%, 100% { box-shadow: none; } }
@keyframes hd-red { 0%, 66% { color: transparent; box-shadow: none; } 67%, 72% { color: var(--ink); box-shadow: 0 0 0 1.5px var(--accent); } 73%, 100% { color: var(--err); box-shadow: 0 0 0 1.5px var(--err); } }
@keyframes hd-row { 0%, 72% { background: transparent; } 73%, 100% { background: color-mix(in srgb, var(--err) 14%, transparent); } }
@keyframes hd-show { 0%, 72% { opacity: 0; } 73%, 100% { opacity: 1; } }

/* limits on a number line */
.hd-line { position: relative; height: 34px; margin: 1.1rem .6rem .2rem; border-bottom: 1.5px solid var(--muted); }
.hd-band { position: absolute; bottom: -4px; height: 8px; background: color-mix(in srgb, var(--ok) 40%, transparent); border: 1px solid var(--ok); border-radius: 3px; }
.hd-tick { position: absolute; bottom: -7px; width: 1.5px; height: 14px; background: var(--ok); }
.hd-pt { position: absolute; bottom: 6px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; font: 600 .74rem var(--font-mono); }
.hd-pt::after { content: ""; width: 10px; height: 10px; border-radius: 50%; margin-top: 2px; }
.hd-pt.ok { color: var(--ok); } .hd-pt.ok::after { background: var(--ok); }
.hd-pt.bad { color: var(--err); animation: hd-blink 2s infinite; } .hd-pt.bad::after { background: var(--err); }
@keyframes hd-blink { 0%, 60% { opacity: 1; } 80% { opacity: .35; } 100% { opacity: 1; } }

/* laptop and phone: the photo arrow travels */
.devsvg.hd { max-width: 240px; color: var(--ink); }
.hd .hd-photo { stroke: var(--accent); stroke-dasharray: 6 5; animation: hd-flow 1.2s linear infinite reverse; }

/* a label inside an assembly */
.hd-nest .hd-box { border: 1.5px dashed var(--muted); border-radius: 8px; padding: .45rem .55rem; display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; }
.hd-k { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hd-nest .hd-in { margin-left: .8rem; }

/* work instruction -> work orders */
.hd-wo { display: flex; align-items: center; gap: .5rem; }
.hd-doc { border: 1.4px solid var(--muted); border-radius: 5px; padding: .3rem .4rem; display: flex; flex-direction: column; gap: 3px; font-size: .74rem; min-width: 5.5rem; background: var(--card); }
.hd-doc b { font: 600 .74rem var(--font-mono); } .hd-doc i { display: block; height: 3px; border-radius: 2px; background: var(--line); }
.hd-doc small { color: var(--muted); }
.hd-doc.wo { border-color: var(--accent); }
.hd-wo > .hd-doc > span, .hd-wos > span { font-size: .68rem; color: var(--muted); }
.hd-wos { display: flex; flex-direction: column; gap: .3rem; }
.hd-arrows { color: var(--accent); font-size: 1.3rem; }
.hd-prog { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; } .hd-prog i { display: block; height: 100%; background: var(--accent); }

/* NCR path */
.hd-steps { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; font-size: .76rem; }
.hd-chip { border: 1px solid var(--line); border-radius: 999px; padding: .05rem .5rem; white-space: nowrap; }
.hd-chip.bad { color: var(--err); border-color: var(--err); } .hd-chip.warn { color: var(--warn); border-color: var(--warn); }
.hd-arr { color: var(--muted); }
.hd-disp { display: inline-flex; flex-wrap: wrap; gap: .2rem; }
.hd-disp i { font-style: normal; border: 1px solid var(--accent); color: var(--accent); border-radius: 4px; padding: 0 .3rem; font-size: .7rem; animation: hd-pick 5s infinite; }
.hd-disp i:nth-child(2) { animation-delay: 1s; } .hd-disp i:nth-child(3) { animation-delay: 2s; } .hd-disp i:nth-child(4) { animation-delay: 3s; } .hd-disp i:nth-child(5) { animation-delay: 4s; }
@keyframes hd-pick { 0%, 18% { background: var(--accent); color: var(--accent-ink); } 22%, 100% { background: transparent; color: var(--accent); } }

/* units vs stock, places */
.hd-two { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.hd-two > div { display: flex; flex-direction: column; gap: .2rem; font-size: .76rem; }
.hd-two small { color: var(--muted); }
.hd-meter { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; } .hd-meter i { display: block; height: 100%; background: var(--accent); }
.hd-tree { font-size: .8rem; display: flex; flex-direction: column; gap: .2rem; } .hd-tree small { color: var(--muted); }
.hd-tree .d1 { padding-left: 1rem; } .hd-tree .d2 { padding-left: 2rem; }

@media (prefers-reduced-motion: reduce) {
  .hd .hd-crit, .hd .hd-pulse, .hd .hd-photo, .hd-pt.bad, .hd-disp i { animation: none; }
  .hd-btr.r1 .hd-cell, .hd-btr.r2 .hd-cell { animation: none; }
  .hd-btr.r3, .hd-btr.r3 .hd-cell, .hd-btr.r3 .hd-tk { animation: none; }
  .hd-btr.r3 { background: color-mix(in srgb, var(--err) 14%, transparent); } .hd-btr.r3 .hd-cell { color: var(--err); }
}

/* a bubble that sits at the right of a box, with no line of its own */
.hb-r { float: right; margin: .1rem 0 0 .4rem; position: relative; z-index: 2; }

/* the block editor's bubbles (wi-editor.js help()) */
.ed-qrow { display: flex; align-items: center; gap: .3rem; }
.ed-qrow .ed-q { flex: 1; min-width: 0; }
.ed-qrow details.info { flex: none; margin: 0 .3rem; }
.ed-tb > details.info { margin: 0 .4rem; align-self: center; }
.ed-help { margin-top: .3rem; text-align: right; }
.blkhead details.info, .co-top details.info, .ref-hd details.info, .stephd details.info, .ed-figbar details.info { flex: none; }
.stephd details.info { font-size: 1rem; }
