/*
    The heat pump page - wp.xhtml (issue #711).

    Summary before detail, as the air and reporting pages: the pump's state in one card, a card per
    circuit with its own controls, the day as a strip of runs, one chart, the counters, and the
    rest folded away. Heating is the dashboard's heat pump red, hot water the house blue, outside
    the good green, so a colour means the same thing on every card, strip and line.

    Built on the dashboard's tokens (--flow-* in animation.css). Loaded from
    common/commonHead.xhtml; identical in both modules.
*/

.hp {
    --hp-heating: var(--flow-heat);
    --hp-heating-bg: #fbe8ea;
    --hp-water: #1f7fc9;
    --hp-water-bg: #e2f0fb;
    --hp-outside: var(--flow-good);
    --hp-run: var(--flow-good);
    --hp-run-bg: var(--flow-good-bg);
    --hp-bad: #c5303e;
    --hp-bad-bg: #fbe8ea;
    --hp-accent: var(--flow-house);
    --hp-accent-bg: #e8f0fd;
    display: grid;
    gap: 14px;
    margin-bottom: 1.5rem;
    color: var(--flow-ink);
    font-variant-numeric: tabular-nums;
}

.hp h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.hp-card {
    min-width: 0;
    background: var(--flow-card);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(20, 30, 60, 0.06), 0 4px 14px rgba(20, 30, 60, 0.05);
    color: var(--flow-ink);
}

.hp-c-heating { color: var(--hp-heating); }
.hp-c-water { color: var(--hp-water); }
.hp-c-outside { color: var(--hp-outside); }

.hp-dot {
    display: inline-block;
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--flow-ink-faint);
}

.hp-dot-run { background: var(--hp-run); }
.hp-dot-bad { background: var(--hp-bad); }
.hp-dot-off, .hp-dot-none { background: var(--flow-track); }
.hp-dot-heating { background: var(--hp-heating); }
.hp-dot-water { background: var(--hp-water); }

/* ── the state card ─────────────────────────────────────────────────── */

.hp-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 22px;
    padding: 14px 16px;
    border-left: 4px solid var(--flow-ink-faint);
}

.hp-hero.hp-tone-run { border-left-color: var(--hp-run); }
.hp-hero.hp-tone-bad { border-left-color: var(--hp-bad); }
.hp-hero.hp-tone-none { border-left-color: var(--flow-track); }

.hp-hero-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 320px;
    min-width: 0;
}

.hp-hero-main > .hp-dot { width: 11px; height: 11px; }
.hp-hero-main > .hp-dot-run { box-shadow: 0 0 0 4px var(--hp-run-bg); }
.hp-hero-main > .hp-dot-bad { box-shadow: 0 0 0 4px var(--hp-bad-bg); }

.hp-hero-state {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
}

.hp-tone-bad .hp-hero-state { color: var(--hp-bad); }
.hp-tone-none .hp-hero-state { color: var(--flow-ink-soft); }

.hp-hero-state small {
    margin-left: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--flow-ink-soft);
}

.hp-hero-sub {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--flow-ink-soft);
}

.hp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hp-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--flow-rule);
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

/* ── the two circuits ───────────────────────────────────────────────── */

.hp-circuits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.hp-circ {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    border-top: 3px solid var(--hp-heating);
}

.hp-circ-water { border-top-color: var(--hp-water); }

.hp-circ-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hp-pill {
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--flow-rule);
    color: var(--flow-ink-soft);
    font-size: 11.5px;
    font-weight: 500;
}

.hp-pill-on {
    background: var(--hp-run-bg);
    color: var(--hp-run);
}

.hp-lead {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 22px;
}

.hp-val {
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
}

.hp-val-small { font-size: 22px; }

.hp-val small {
    margin-left: 3px;
    font-size: 13px;
    font-weight: 500;
    color: var(--flow-ink-soft);
}

.hp-what {
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--flow-ink-soft);
}

.hp-tank {
    position: relative;
    flex: none;
    width: 34px;
    height: 74px;
    overflow: hidden;
    border: 2px solid var(--flow-track);
    border-radius: 8px 8px 10px 10px;
    background: var(--flow-rule);
}

.hp-tank i {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, var(--hp-water), #6aa9d8);
}

.hp-tank b, .hp-tank em {
    position: absolute;
    left: -2px;
    right: -2px;
    opacity: 0.6;
}

.hp-tank b { border-top: 2px dashed var(--flow-ink); }
.hp-tank em { border-top: 1px dotted var(--flow-ink); }

.hp-tankkey {
    margin-top: 3px;
    font-size: 10.5px;
    line-height: 1.6;
    color: var(--flow-ink-soft);
}

.hp-minis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--flow-rule);
}

.hp-minis div {
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
}

.hp-minis span {
    display: block;
    font-size: 10.5px;
    font-weight: 400;
    color: var(--flow-ink-soft);
}

.hp-ctls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid var(--flow-rule);
}

.hp-ctl {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.hp-full { grid-column: 1 / -1; }

.hp-ctl-l {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    color: var(--flow-ink-soft);
}

.hp-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.hp-hint {
    font-size: 11px;
    color: var(--flow-ink-soft);
}

.hp-pending {
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--flow-warn-bg);
    color: var(--flow-warn);
    font-size: 11.5px;
}

body .hp input.hp-input {
    width: 80px;
}

/* the mode buttons: one segmented control, the reported mode filled */
.hp-seg {
    display: inline-flex;
    flex-wrap: wrap;
    align-self: flex-start;
    overflow: hidden;
    border: 1px solid var(--flow-track);
    border-radius: 6px;
}

body .hp input.hp-seg-btn {
    margin: 0;
    padding: 5px 12px;
    border: 0;
    border-right: 1px solid var(--flow-track);
    border-radius: 0;
    background: var(--flow-card);
    color: var(--flow-ink);
    font-size: 12.5px;
    cursor: pointer;
}

body .hp input.hp-seg-btn:last-child { border-right: 0; }
body .hp input.hp-seg-btn:hover { background: var(--flow-rule); }
body .hp .hp-seg-heating input.hp-seg-btn.on { background: var(--hp-heating); color: #fff; }
body .hp .hp-seg-water input.hp-seg-btn.on { background: var(--hp-water); color: #fff; }

.hp-step {
    display: inline-flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid var(--flow-track);
    border-radius: 6px;
}

body .hp input.hp-step-btn {
    margin: 0;
    padding: 3px 10px;
    border: 0;
    border-radius: 0;
    background: var(--flow-rule);
    color: var(--flow-ink-soft);
    cursor: pointer;
}

body .hp input.hp-step-input {
    width: 64px;
    margin: 0;
    padding: 3px 6px;
    border: 0;
    border-radius: 0;
    background: var(--flow-card);
    color: var(--flow-ink);
    text-align: center;
}

/* ── the strip of the day ───────────────────────────────────────────── */

.hp-strip { padding: 12px 14px; }

.hp-strip-h, .hp-chart-h {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 12px;
}

.hp-strip-sum {
    font-size: 12px;
    color: var(--flow-ink-soft);
}

.hp-strip-bar {
    position: relative;
    height: 22px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--flow-rule);
}

.hp-block {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 2px;
}

.hp-block-water { background: var(--hp-water); }
.hp-block-heating { background: var(--hp-heating); }
.hp-block-unknown { background: var(--flow-ink-faint); }

.hp-block-gap {
    border-radius: 0;
    background: repeating-linear-gradient(
        45deg, var(--flow-track) 0 3px, transparent 3px 6px);
}

.hp-strip-ticks {
    position: relative;
    height: 16px;
    margin-top: 3px;
    font-size: 10px;
    color: var(--flow-ink-soft);
}

.hp-strip-ticks span {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

.hp-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--flow-ink-soft);
}

.hp-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.hp-sw {
    position: static;
    display: inline-block;
    width: 12px;
    height: 8px;
    border-radius: 2px;
}

/* ── the chart and its tiles ────────────────────────────────────────── */

.hp-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    gap: 8px;
}

.hp-tile {
    display: flex;
    flex-direction: column;
    padding: 9px 11px;
    border-top: 3px solid var(--flow-track);
}

a.hp-tile:hover {
    color: var(--flow-ink);
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(20, 30, 60, 0.08), 0 6px 20px rgba(20, 30, 60, 0.1);
}

.hp-tile-on { outline: 2px solid var(--hp-accent); outline-offset: -2px; }
.hp-tile-na { opacity: 0.6; }

.hp-tile-k {
    font-size: 11px;
    color: var(--flow-ink-soft);
}

.hp-tile-v {
    margin-top: 2px;
    font-size: 19px;
    font-weight: 600;
}

.hp-tile-v small {
    font-size: 11px;
    font-weight: 500;
    color: var(--flow-ink-soft);
}

.hp-tile-v-na {
    padding-top: 3px;
    font-size: 14px;
}

.hp-tile-t {
    font-size: 10.5px;
    color: var(--flow-ink-soft);
}

.hp-chartcard { padding: 14px; }

.hp-seg-small a {
    padding: 3px 11px;
    border-right: 1px solid var(--flow-track);
    color: var(--flow-ink-soft);
    font-size: 12px;
}

.hp-seg-small a:last-child { border-right: 0; }
.hp-seg-small a:hover { text-decoration: none; background: var(--flow-rule); }

.hp-seg-small a.on {
    background: var(--hp-accent-bg);
    color: var(--hp-accent);
    font-weight: 500;
}

/* ── yield and wear ─────────────────────────────────────────────────── */

.hp-sect {
    padding: 2px 2px 0;
    color: var(--hp-accent);
    font-size: 15px;
    font-weight: 600;
}

.hp-sect span {
    margin-left: 8px;
    color: var(--flow-ink-soft);
    font-size: 12px;
    font-weight: 400;
}

.hp-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.hp-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 11px 13px;
}

.hp-kpi-l {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--flow-ink-soft);
}

.hp-kpi-v {
    font-size: 21px;
    font-weight: 600;
}

.hp-kpi-v small {
    margin-left: 3px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--flow-ink-soft);
}

.hp-kpi-d {
    font-size: 11px;
    color: var(--flow-ink-soft);
}

/* ── the PV rule and the folds ──────────────────────────────────────── */

.hp-pv {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin: 0;
    padding: 12px 14px;
}

.hp-pv-l {
    font-size: 13.5px;
    font-weight: 600;
}

.hp-pv-text {
    flex: 1 1 300px;
    min-width: 0;
    margin: 0;
    font-size: 12.5px;
    color: var(--flow-ink-soft);
}

.hp-fold summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 11px 14px;
    list-style: none;
    font-size: 12.5px;
    cursor: pointer;
}

.hp-fold summary::-webkit-details-marker { display: none; }

.hp-fold summary::before {
    content: "▸";
    color: var(--flow-ink-soft);
    transition: transform 0.15s;
}

.hp-fold[open] summary::before { transform: rotate(90deg); }

.hp-fold summary b {
    font-size: 13.5px;
    font-weight: 600;
}

.hp-fold-m { color: var(--flow-ink-soft); }

.hp-fold-body {
    padding: 0 14px 14px;
    overflow-x: auto;
}

.hp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.hp-table th {
    padding: 7px 9px;
    background: var(--flow-rule);
    color: var(--flow-ink-soft);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.hp-table td {
    padding: 7px 9px;
    border-top: 1px solid var(--flow-rule);
}

.hp-mono { font-family: ui-monospace, monospace; }

.hp-dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px 18px;
}

.hp-dl div {
    font-size: 12.5px;
    font-weight: 500;
}

.hp-dl span {
    display: block;
    font-size: 10.5px;
    font-weight: 400;
    color: var(--flow-ink-soft);
}

@media (max-width: 560px) {
    .hp-ctls { grid-template-columns: 1fr; }
    .hp-minis { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .hp-fold summary::before { transition: none; }
}
