/* Thermal via array calculator: one screen for the calculator, details below */
.case-page .tv-hero { padding: calc(var(--nav-h) + 22px) 0 14px; }
.tv-hero .case-tag { margin-bottom: 10px; }
.tv-hero h1 { font-size: clamp(26px, 2.8vw, 38px); }
.tv-lede { color: var(--on-night-2); font-size: 15.5px; max-width: 52em; margin-top: 8px; }

.tv-band { background: var(--hero-bg); color: var(--on-night); padding: 0 0 48px; scroll-margin-top: var(--nav-h); }
.tv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.tv-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }

/* key results */
.tv-kpis { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.15fr 1fr; gap: 8px; }
.tv-kpi { background: var(--night-2); border: 1px solid var(--night-line); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tv-kpi span { font: 500 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--on-night-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-kpi b { font: 500 15px var(--mono); color: var(--on-night); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-kpi-main b { font: 400 26px/1.1 var(--serif); color: #fff; }
.tv-kpi small { font: 400 10.5px var(--mono); color: var(--on-night-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-kpi-main { justify-content: center; }

.tv-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--night-line); border-radius: 999px; padding: 3px; background: rgba(17,27,54,.6); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 13px; border-radius: 999px; font-size: 13px; color: var(--on-night-2); cursor: pointer; transition: background .2s, color .2s; white-space: nowrap; }
.seg input:checked + span { background: var(--blue); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--blue-2); outline-offset: 2px; }
.seg-sm span { padding: 5px 11px; font-size: 12.5px; }

/* the visual: sized to fit the screen with the panel beside it */
.tv-stagebox { position: relative; height: clamp(280px, calc(100vh - 400px), 640px); }
.tv-stage { position: absolute; inset: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--night-line);
  background: radial-gradient(120% 90% at 50% 30%, #121c3a, #080e1e 70%); }
.tv-stage[hidden] { display: none; }
.tv-3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.tv-3d canvas.grabbing { cursor: grabbing; }
.tv-3d-hint { position: absolute; left: 12px; bottom: 8px; margin: 0; font: 400 10.5px var(--mono); color: var(--on-night-2); opacity: .7; pointer-events: none; }
.tv-xs canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tv-xs svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#tv-xsec text { font-family: var(--mono); }
.tv-maps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 12px 30px; align-items: start; align-content: center; }
.tv-maps figure { margin: 0; min-width: 0; }
.tv-maps canvas { display: block; width: 100%; border-radius: 4px; cursor: crosshair; }
.tv-maps figcaption { font: 400 11px var(--mono); color: var(--on-night-2); margin-top: 4px; text-align: center; }
.tv-map-read { position: absolute; left: 0; right: 0; bottom: 8px; margin: 0; font: 400 11.5px var(--mono); color: var(--on-night); text-align: center; }

/* one-line legend */
.tv-legend { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; font: 400 11.5px var(--mono); color: var(--on-night-2); }
.lg { display: inline-flex; align-items: center; gap: 8px; }
.ramp { display: block; width: 120px; height: 7px; border-radius: 4px; }
.ramp.thermal { background: linear-gradient(90deg, #222660, #3e2478, #782878, #d2463c, #f5a03c, #fff0be); }
.tv-keys { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.tv-keys li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tv-keys i { display: inline-block; flex: none; }
.tv-keys i.k-conv { width: 9px; height: 9px; border-radius: 50%; background: #f5a03c; }
.tv-keys i.k-rad { width: 16px; height: 11px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,236,190,.95), rgba(255,236,190,0)); }
.tv-keys i.k-cond { width: 6px; height: 6px; border-radius: 50%; background: #ffe2a8; }
.tv-case { margin-left: auto; }

/* compact input panel: fits beside the visual without scrolling */
.tv-panel { background: var(--night-2); border: 1px solid var(--night-line); border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 11px; position: sticky; top: calc(var(--nav-h) + 12px); }
.tv-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 10px; }
.tv-2 label, .tv-1 { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--on-night-2); }
.tv-panel input[type=number], .tv-panel select {
  font: 400 13px var(--mono); color: var(--on-night); background: rgba(8,14,30,.6); width: 100%;
  border: 1px solid rgba(169,192,234,.2); border-radius: 7px; padding: 5px 8px; }
.tv-panel select { font-family: var(--sans); }
.tv-panel input:focus-visible, .tv-panel select:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 1px; }
.tv-panel input:invalid { border-color: rgba(255,107,90,.6); }
.ctl { display: flex; flex-direction: column; gap: 4px; }
.ctl label { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--on-night-2); }
.ctl label b { font: 500 12px var(--mono); color: var(--on-night); }
.ctl input[type=range] { width: 100%; accent-color: var(--blue-2); margin: 0; }
.tv-seg { align-self: flex-start; }
.tv-check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--on-night-2); }
.tv-check input { accent-color: var(--blue-2); }
.tv-more { border-top: 1px solid var(--night-line); padding-top: 9px; }
.tv-more summary { cursor: pointer; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--on-night-2); }
.tv-more[open] { display: flex; flex-direction: column; gap: 10px; }
.tv-more[open] summary { margin-bottom: 2px; }
.tv-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--night-line); padding-top: 9px; }
.tv-status { margin: 0; font: 400 11px/1.35 var(--mono); }
.tv-status.ok { color: #7be0b0; } .tv-status.bad { color: #ff9585; } .tv-status.busy { color: #f3c77a; }
.tv-reset { font: 500 12px var(--sans); color: var(--on-night-2); background: none; border: 1px solid var(--night-line); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.tv-reset:hover { color: #fff; }

/* details below the fold */
.tv-details { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 36px; }
.tv-h3 { font: 500 11px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--on-night-2); margin: 0 0 10px; }
.tv-note { font-size: 13px; color: var(--on-night-2); margin: 8px 0 0; }
.tv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tv-table th, .tv-table td { padding: 8px 10px; border-top: 1px solid var(--night-line); text-align: right; white-space: nowrap; }
.tv-table thead th { font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--on-night-2); border-top: 0; }
.tv-table tbody th { text-align: left; font-weight: 400; color: var(--on-night-2); }
.tv-table td { font: 500 13.5px var(--mono); color: var(--on-night); }
.tv-table td.sel { background: rgba(90,128,200,.16); }
.tv-table td.delta { color: var(--blue-3); }
.tv-read { margin: 14px 0 0; }
.tv-read div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--night-line); }
.tv-read dt { font-size: 13px; color: var(--on-night-2); }
.tv-read dd { font: 500 12.5px var(--mono); color: var(--on-night); text-align: right; margin: 0; }
.tv-chart { position: relative; width: 100%; }
.tv-chart svg { display: block; width: 100%; height: auto; }
.tv-chart text { font-family: var(--mono); }
.tv-tip { position: absolute; pointer-events: none; background: var(--night-2); border: 1px solid var(--night-line); border-radius: 8px;
  padding: 8px 10px; font: 400 12px/1.5 var(--mono); color: var(--on-night); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.tv-tip[hidden] { display: none; }
.tv-tip span { color: var(--on-night-2); }

.tv-vtable { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 8px 0 18px; }
.tv-vtable th, .tv-vtable td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.tv-vtable th { font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-top: 0; }
.tv-vtable td:last-child { font-family: var(--mono); font-size: 13px; }

/* animated flow along the section's arrows and vias */
.tv-flowline { stroke-dasharray: 7 5; animation: tv-flow 1.1s linear infinite; }
.tv-flowline.tv-fast { stroke-dasharray: 3 6; animation: tv-flow-f .6s linear infinite; }
@keyframes tv-flow { to { stroke-dashoffset: -12; } }
@keyframes tv-flow-f { to { stroke-dashoffset: -9; } }
@media (prefers-reduced-motion: reduce) { .tv-flowline { animation: none; } }

@media (max-width: 1060px) {
  .tv-grid { grid-template-columns: 1fr; }
  .tv-panel { position: static; }
  .tv-stagebox { height: min(62vw, 520px); }
  .tv-details { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tv-kpis { grid-template-columns: 1fr 1fr; }
  .tv-kpi-main { grid-column: 1 / -1; }
  .tv-stagebox { height: 78vw; }
  .tv-maps { grid-template-columns: 1fr 1fr; }
  .tv-case { margin-left: 0; }
}
