/* IMECA3D — Enclosure Heat-Rise Calculator (loaded after snap-fit.css, which holds the shared form/result styles).
   Script: src/js/heat.js. Server analysis: netlify/functions/heat/. */

.ht--busy .sf-verdict { opacity: 0.75; transition: opacity 0.2s; }
.ht--empty .ht-section, .ht--empty .ht-chart, .ht--empty .ht-paths, .ht--empty .sf-nums, .ht--empty .sf-checks, .ht--empty .ht-mat { display: none; }
.ht-status { margin: -4px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--light); }

/* section view */
.ht-section { border-radius: 12px; background: var(--light); padding: 6px; }
.ht-section svg { display: block; width: 100%; height: auto; }
.ht-outline { fill: none; stroke: var(--text); stroke-width: 1.5; }
.ht-board { stroke: var(--text); stroke-width: 1; }
.ht-surface { fill: #C9B79C; }
.ht-lab { fill: var(--text-2); font: 600 12px var(--font-body); }
.ht-lab--b { fill: var(--text); font-size: 13px; }
.ht-flow { stroke: #2563EB; stroke-width: 2.5; fill: none; }
.ht-arrowhead { fill: #2563EB; }
.ht-sun { stroke: #F59E0B; stroke-width: 2; fill: none; }
.ht-sunhead { fill: #F59E0B; }

/* heat paths */
.ht-paths h3, .ht-chart h3, .ht-mat h3 { margin-bottom: 10px; font-family: var(--font-head); font-size: 1rem; font-weight: 600; }
.ht-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--light-2); }
.ht-bar span, .ht-legend i { display: block; }
.ht-bar--conv { background: #F07A2E; }
.ht-bar--rad { background: #C2410C; }
.ht-bar--vent { background: #2563EB; }
.ht-bar--contact { background: #A8A29E; }
.ht-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 0.82rem; color: var(--text-2); }
.ht-legend li { display: flex; align-items: center; gap: 6px; }
.ht-legend i { width: 12px; height: 12px; border-radius: 3px; }

/* chart */
.ht-chart svg { display: block; width: 100%; height: auto; }
.ht-grid { stroke: var(--light-2); stroke-width: 1; }
.ht-ax { fill: var(--text-3); font: 11px var(--font-body); }
.ht-line { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.ht-line--air { stroke: #C2410C; stroke-width: 2.8; }
.ht-line--board { stroke: #7C3AED; }
.ht-line--wall { stroke: #0EA5E9; stroke-dasharray: 5 3; }
.ht-limit { stroke: #B91C1C; stroke-width: 1.5; stroke-dasharray: 6 4; }
.ht-on { fill: rgba(240,122,46,0.10); }
.ht-k { width: 16px !important; height: 3px !important; border-radius: 2px; }
.ht-k--air { background: #C2410C; }
.ht-k--board { background: #7C3AED; }
.ht-k--wall { background: #0EA5E9; }
.ht-k--limit { background: #B91C1C; }
.ht-k--on { height: 10px !important; background: rgba(240,122,46,0.25); }
.ht-chart .sf-note { margin-top: 6px; }

.ht-mat .sf-check { margin: 0; }

/* three-way choices on one row (two rows on phones) */
.ht .sf-seg:has(label:nth-child(3)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ht .sf-seg span { padding: 9px 6px; font-size: 0.84rem; }
@media (max-width: 420px) { .ht .sf-seg:has(label:nth-child(3)) { grid-template-columns: 1fr 1fr; } }
.ht-cap { margin: 4px 4px 0; font-size: 0.78rem; color: var(--text-3); text-align: center; }

/* ---------- "My CAD file" mode (heat-cad.js + vendor/thermal3d.min.js) ---------- */
.ht-modes { grid-column: 1 / -1; max-width: 560px; }
.ht-modes .sf-seg { grid-template-columns: 1fr 1fr !important; }
.hc { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 20px; align-items: start;
  padding: 20px; border-radius: 20px; background: var(--frost-bg); border: 1px solid var(--frost-border); }
.hc[hidden], .hc [hidden] { display: none !important; }
.hc-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hc-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 260px; padding: 24px;
  border: 2px dashed var(--text-3); border-radius: 16px; background: #fff; text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.hc-drop:hover, .hc-drop.is-over { border-color: var(--accent); background: #FFF7F1; }
.hc-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.hc-drop .icon { width: 32px; height: 32px; color: var(--accent); }
.hc-drop b { font-family: var(--font-head); font-size: 1.05rem; }
.hc-drop span { max-width: 460px; font-size: 0.86rem; color: var(--text-2); }
.hc-drop--small { min-height: 0; flex-direction: row; padding: 10px 14px; gap: 10px; text-align: left; }
.hc-drop--small span { display: none; }
.hc-drop--small .icon { width: 20px; height: 20px; }
.hc-drop--small b { font-size: 0.92rem; }
.hc-stage { display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: linear-gradient(#F6F8FB, #E6EBF1); }
.hc-view { position: relative; height: min(68vh, 600px); min-height: 340px; }
.hc-view canvas { display: block; width: 100% !important; height: 100% !important; }
.hc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 12px; background: #fff; border-top: 1px solid var(--light-2); font-size: 0.84rem; }
.hc-bar label { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.hc-bar select { padding: 4px 8px; font-size: 0.84rem; }
.hc-sec { flex: 1 1 120px; accent-color: var(--accent); }
.hc-reset { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 6px 10px; border: 1px solid var(--light-2); border-radius: 8px; background: #fff; font: inherit; color: var(--text); cursor: pointer; }
.hc-reset .icon { width: 15px; height: 15px; }
.hc-status { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--light); }
.hc-status--warn { background: #FEF3C7; color: #78350F; }
.hc-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; max-height: calc(min(68vh, 600px) + 110px); overflow: auto; padding-right: 2px; }
.hc-file { margin: 0 0 6px; font-weight: 600; word-break: break-all; }
.hc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
.hc-facts div { padding: 6px 9px; border-radius: 8px; background: #fff; }
.hc-facts dt { font-size: 0.72rem; color: var(--text-3); }
.hc-facts dd { margin: 0; font-weight: 600; font-size: 0.88rem; }
.hc-warn { margin: 6px 0 0; padding: 8px 10px; border-radius: 8px; background: #FEF3C7; color: #78350F; font-size: 0.84rem; }
.hc-side > .sf-label { margin-bottom: -4px; }
.hc-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.hc-tools button { display: flex; align-items: center; gap: 7px; padding: 9px 10px; border: 1px solid var(--light-2); border-radius: 10px; background: #fff; font: 600 0.84rem var(--font-body); color: var(--text); cursor: pointer; text-align: left; }
.hc-tools button .icon { width: 17px; height: 17px; flex: none; }
.hc-tools button:hover { border-color: var(--text-3); }
.hc-tools button[aria-pressed="true"] { border-color: var(--accent); background: #FFF1E7; box-shadow: 0 0 0 2px rgba(240,122,46,0.25); }
.hc-tools [data-tool="source"] .icon { color: #DC2626; } .hc-tools [data-tool="board"] .icon { color: #15803D; } .hc-tools [data-tool="vent"] .icon { color: #2563EB; }
.hc-tools [data-tool="fin"] .icon { color: #7C3AED; } .hc-tools [data-tool="mount"] .icon { color: #57534E; }
.hc-brush { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; }
.hc-brush label { display: flex; flex: 1; align-items: center; gap: 8px; }
.hc-brush input { flex: 1; accent-color: var(--accent); }
.hc-hint { margin: 0; }
.hc-marks { display: flex; flex-direction: column; gap: 8px; }
.hc-mark { padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--light-2); border-left: 4px solid var(--hc-c, var(--text-3)); }
.hc-mark.is-sel { box-shadow: 0 0 0 2px rgba(250,204,21,0.8); }
.hc-mark--source { --hc-c: #DC2626; } .hc-mark--board { --hc-c: #15803D; } .hc-mark--vent { --hc-c: #2563EB; } .hc-mark--fin { --hc-c: #7C3AED; } .hc-mark--mount { --hc-c: #57534E; }
.hc-mark__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--hc-c); }
.hc-del { margin-left: auto; width: 28px; height: 28px; border: 0; border-radius: 8px; background: var(--light); font-size: 1.1rem; line-height: 1; color: var(--text-2); cursor: pointer; }
.hc-del:hover { background: #FEE2E2; color: #B91C1C; }
.hc-mark .sf-field { margin-bottom: 8px; }
.hc-mark .sf-row { align-items: end; }
.hc-mark .sf-hint { margin: 0 0 8px; }
.hc-meas { margin: 0 0 8px; font-size: 0.86rem; color: var(--text-2); }
.hc-link { padding: 0; border: 0; background: none; font: 600 0.84rem var(--font-body); color: #C2410C; cursor: pointer; text-decoration: underline; }
.hc-pad { margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: #ECFEFF; }
.hc-pad .sf-label { margin: 0 0 6px; font-size: 0.84rem; }
.hc-rot { padding: 9px 12px; margin-bottom: 8px; font-size: 0.84rem; }
/* labels on the 3D model */
.t3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.t3-tag { position: absolute; left: 0; top: 0; margin: -30px 0 0 8px; padding: 3px 8px; border-radius: 6px; background: rgba(17,24,39,0.86); color: #fff;
  font: 600 12px var(--font-body); white-space: nowrap; pointer-events: auto; cursor: pointer; will-change: transform; }
.t3-tag::before { content: ""; position: absolute; left: -8px; bottom: -6px; width: 8px; height: 8px; border-left: 2px solid rgba(17,24,39,0.86); border-bottom: 2px solid rgba(17,24,39,0.86); }
.t3-tag--source { background: #B91C1C; } .t3-tag--board { background: #166534; } .t3-tag--vent { background: #1D4ED8; } .t3-tag--fin { background: #6D28D9; }
.t3-tag.is-sel { outline: 2px solid #FACC15; }
/* part temperatures (CAD mode) */
.ht-section--list { padding: 14px 16px; }
.ht-section--list h3 { margin-bottom: 8px; font-family: var(--font-head); font-size: 1rem; font-weight: 600; }
.ht-parts { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ht-parts li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: #fff; font-size: 0.88rem; }
.ht-parts i { width: 14px; height: 14px; border-radius: 4px; }
.ht-parts b { font-family: var(--font-head); }
.ht-parts li.is-over { box-shadow: inset 3px 0 0 #B91C1C; }
@media (max-width: 1000px) {
  .hc { grid-template-columns: 1fr; padding: 14px; }
  .hc-side { max-height: none; overflow: visible; }
  .hc-view { height: 60vh; min-height: 300px; }
}
.t3-labels--pass .t3-tag { pointer-events: none; opacity: 0.75; }
/* name field of a heat source (same look as the number fields) */
.hc-mark input[type="text"] { width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 10px; background: #fff; font: inherit; color: var(--text); }
.hc-mark input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194,65,12,0.15); }
.hc-mark .sf-unit input, .hc-mark select { padding-top: 8px; padding-bottom: 8px; }
/* part tree of an assembly (CAD mode) */
.hc-parts { display: flex; flex-direction: column; gap: 6px; }
.hc-parts > .sf-hint { margin: 0; }
.hc-tree { display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 0; list-style: none; max-height: 420px; overflow: auto; }
.hc-part, .hc-group { padding: 5px 8px 5px calc(8px + var(--d, 0) * 14px); border-radius: 8px; background: #fff; border: 1px solid var(--light-2); }
.hc-group { background: var(--light); }
.hc-part.is-sel { border-color: #FACC15; box-shadow: 0 0 0 2px rgba(250,204,21,0.45); }
.hc-part__row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hc-part__row b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.84rem; }
.hc-part__name { flex: 1; min-width: 0; padding: 2px 0; border: 0; background: none; font: 600 0.84rem var(--font-body); color: var(--text); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.hc-part__name:hover { text-decoration: underline; }
.hc-part__row select { flex: none; width: 46%; max-width: 190px; padding: 5px 8px; font-size: 0.8rem; }
.hc-part__more { margin-top: 6px; }
.hc-part__more .sf-field { margin-bottom: 6px; }
.hc-part__more .sf-row { align-items: end; }
.hc-part__more .hc-meas, .hc-part__more .sf-hint { margin: 0 0 4px; font-size: 0.8rem; }
.hc-role { flex: none; width: 10px; height: 10px; border-radius: 3px; background: #F07A2E; }
.hc-role--board { background: #15803D; } .hc-role--component { background: #DC2626; } .hc-role--battery { background: #CA8A04; }
.hc-role--heatsink { background: #94A3B8; } .hc-role--fan { background: #2563EB; } .hc-role--ignore { background: #D6D3D1; }
.t3-tag--component { background: #B91C1C; } .t3-tag--battery { background: #A16207; } .t3-tag--heatsink { background: #475569; } .t3-tag--fan { background: #1D4ED8; }
/* CFD simulation offer under the result */
.ht-cfd { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--light); border-left: 4px solid #2563EB; }
.ht-cfd p { margin: 0; font-size: 0.9rem; }
