/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright © 2026 Marcel Rymenhout and IniqDash contributors */
.iq-hb { container: hb / size; height: 100%; box-sizing: border-box; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; padding: 14px 16px; border-radius: var(--radius-device);
  color: var(--text-primary); font-family: var(--font); background: var(--device-surface); box-shadow: var(--device-shadow); overflow: hidden; }
.iq-hb__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.iq-hb__name { margin: 0; font-size: 14px; font-weight: var(--iq-fw-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-hb__state { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.iq-hb[data-state="charging"] .iq-hb__state { color: var(--success); }
.iq-hb[data-state="discharging"] .iq-hb__state { color: var(--warning); }
.iq-hb__main { display: flex; align-items: center; gap: 16px; min-height: 0; }
.iq-hb__cell { position: relative; flex: none; width: clamp(56px, 22cqw, 92px); height: min(100%, 150px); min-height: 80px; border-radius: 14px; border: 2px solid var(--border-primary); overflow: hidden; background: var(--surface-tertiary); --iq-hb-c: var(--success); }
.iq-hb__cell::before { content: ""; position: absolute; top: -7px; left: 32%; right: 32%; height: 6px; border-radius: 3px 3px 0 0; background: var(--border-primary); }
.iq-hb__cell[data-tone="mid"] { --iq-hb-c: var(--warning); } .iq-hb__cell[data-tone="low"] { --iq-hb-c: var(--danger); }
.iq-hb__fill { position: absolute; inset: auto 0 0; background: linear-gradient(0deg, var(--iq-hb-c), color-mix(in srgb, var(--iq-hb-c) 60%, transparent)); transition: height .6s ease; }
.iq-hb[data-state="charging"] .iq-hb__fill { animation: iq-hb-pulse 2.4s ease-in-out infinite; }
.iq-hb__res { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed var(--text-primary); opacity: .6; }
.iq-hb__res[hidden] { display: none; }
.iq-hb__pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(15px, 6cqmin, 22px); font-weight: 700; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.iq-hb__facts { display: grid; gap: 4px; min-width: 0; }
.iq-hb__facts p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-hb__kwh { font-size: clamp(15px, 6cqmin, 22px); font-weight: 700; }
.iq-hb__pw { font-size: 13px; color: var(--text-secondary); }
.iq-hb__time { font-size: 12.5px; color: var(--text-muted); }
.iq-hb__chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.iq-hb__chips li { display: grid; padding: 4px 9px; border-radius: 10px; background: var(--surface-tertiary); }
.iq-hb__chips span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.iq-hb__chips b { font-size: 12.5px; }
@keyframes iq-hb-pulse { 50% { filter: brightness(1.25); } }
@media (prefers-reduced-motion: reduce) { .iq-hb__fill { animation: none !important; transition: none; } }
/* RING presentation (variant 'ring'): the level as a ring with the state inside, then one row per fact */
.iq-hb__ring, .iq-hb__rows { display: none; }
.iq-hb[data-variant="ring"] { grid-template-rows: auto minmax(0, 1fr) auto; }
.iq-hb[data-variant="ring"] :is(.iq-hb__cell, .iq-hb__facts, .iq-hb__chips) { display: none; }
.iq-hb[data-variant="ring"] .iq-hb__head .iq-hb__state { display: none; }
.iq-hb[data-variant="ring"] .iq-hb__main { justify-content: center; }
.iq-hb[data-variant="ring"] .iq-hb__ring { display: grid; position: relative; height: 100%; max-height: 190px; aspect-ratio: 1; min-height: 0; }
.iq-hb__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.iq-hb__rt { fill: none; stroke: var(--surface-tertiary, rgba(127, 127, 127, .2)); stroke-width: 9; }
.iq-hb__ra { fill: none; stroke: var(--iq-hb-ring, var(--accent)); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .6s ease;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--iq-hb-ring, var(--accent)) 45%, transparent)); }
.iq-hb__rc { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px; }
.iq-hb__rp { font-size: clamp(20px, 9cqmin, 34px); font-weight: 600; letter-spacing: -.01em; }
.iq-hb__rs { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.iq-hb__rb { display: none; width: 14px; height: 14px; color: var(--iq-hb-ring, var(--accent)); }
.iq-hb__rb svg { width: 100%; height: 100%; }
.iq-hb[data-state="charging"] .iq-hb__rb { display: inline-block; }
.iq-hb[data-variant="ring"] .iq-hb__rows { display: grid; margin: 0; padding: 0; list-style: none; gap: 2px; }
.iq-hb__rows li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 5px 2px; font-size: 13px; }
.iq-hb__rows li + li { border-top: 1px solid var(--border-primary, rgba(127, 127, 127, .15)); }
.iq-hb__rows i { width: 18px; height: 18px; color: var(--text-secondary); }
.iq-hb__rows i svg { width: 100%; height: 100%; }
.iq-hb__rows span { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iq-hb__rows b { font-weight: 500; white-space: nowrap; }
@container hb (max-height: 300px) { .iq-hb__rows li:nth-child(n + 4) { display: none; } }
@container hb (max-height: 230px) { .iq-hb__rows li:nth-child(n + 3) { display: none; } }
