/* Electricity consumption TV monitor. Counted use only. */
:root {
    --ec-pub-primary: #0d9668;
    --ec-pub-heading: #0f3d2e;
    --ec-pub-text: #2d3d36;
    --ec-pub-muted: #5c6e66;
    --ec-pub-border: #d7ebe3;
    --ec-pub-bg: #f3faf7;
}

html:has(body.page-electricity-public),
body.page-electricity-public {
    height: 100vh;
    height: 100dvh;
}

body.page-electricity-public {
    margin: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--ec-pub-text);
    background:
        radial-gradient(1100px 380px at 8% 0%, rgba(13, 150, 104, 0.14), transparent 60%),
        linear-gradient(180deg, #f7fcfa 0%, var(--ec-pub-bg) 100%);
}

body.page-electricity-public #loading-outline-progress,
body.page-electricity-public #loading-outline-bar {
    display: none;
}

body.page-electricity-public .header {
    flex-shrink: 0;
}

.ec-pub-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: clamp(8px, 1.4vh, 16px) clamp(12px, 2.4vw, 32px) clamp(8px, 1.6vh, 16px);
}

.ec-pub-container {
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: clamp(8px, 1.2vh, 14px);
}

.ec-pub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    min-width: 0;
    min-height: min-content;
    flex-shrink: 0;
}

.ec-pub-header h1 {
    margin: 0;
    font-size: clamp(1.15rem, 0.9rem + 1.1vw, 1.7rem);
    letter-spacing: -0.03em;
    color: var(--ec-pub-heading);
}

.ec-pub-header p {
    margin: 2px 0 0;
    color: var(--ec-pub-muted);
    font-size: 0.92rem;
}

.ec-pub-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--ec-pub-border);
    color: var(--ec-pub-heading);
    font-size: 0.82rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.ec-pub-live {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 99px;
    background: var(--ec-pub-primary);
    box-shadow: 0 0 0 0 rgba(13, 150, 104, 0.45);
    animation: ec-pub-pulse 2.2s ease-out infinite;
}

.ec-pub-clock:empty,
.ec-pub-period:empty {
    display: none;
}

.ec-pub-stats {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
    min-width: 0;
    min-height: min-content;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--ec-pub-border);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 61, 46, 0.04);
}

.ec-pub-card,
.ec-pub-chart-card {
    background: #fff;
    border: 1px solid var(--ec-pub-border);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 61, 46, 0.04);
}

.ec-pub-stat {
    padding: clamp(10px, 1.4vh, 16px) clamp(14px, 1.6vw, 20px);
    background: transparent;
}

.ec-pub-stat:first-child {
    box-shadow: inset 3px 0 0 var(--ec-pub-primary);
}

.ec-pub-stat + .ec-pub-stat {
    background: #f6faf8;
    border-left: 1px solid var(--ec-pub-border);
}

.ec-pub-stat:first-child strong {
    font-size: clamp(1.8rem, 1.2rem + 1.8vw, 2.7rem);
}

.ec-pub-stat p,
.ec-pub-stat span {
    margin: 0;
    color: var(--ec-pub-muted);
    font-size: 0.82rem;
}

.ec-pub-stat strong {
    display: block;
    margin: 2px 0 2px;
    font-size: clamp(1.35rem, 0.9rem + 1.2vw, 1.9rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1.05;
    color: var(--ec-pub-heading);
}

.ec-pub-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    min-width: 0;
    min-height: min-content;
    flex-shrink: 0;
}

.ec-pub-card {
    position: relative;
    min-width: 0;
    padding: clamp(8px, 1.2vh, 14px) 12px;
}

.ec-pub-card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.95rem;
    color: var(--ec-pub-heading);
}

.ec-pub-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 99px;
    background: var(--ec-meter, var(--ec-pub-primary));
    flex-shrink: 0;
}

.ec-pub-card-total {
    margin: clamp(4px, 0.8vh, 10px) 0 2px;
    font-size: clamp(1.15rem, 0.9rem + 0.6vw, 1.5rem);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    color: var(--ec-pub-heading);
}

.ec-pub-share {
    height: 4px;
    margin: 8px 0 6px;
    border-radius: 99px;
    background: #e7f3ee;
    overflow: hidden;
}

.ec-pub-share > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--ec-meter, var(--ec-pub-primary));
    transition: width 0.7s ease;
}

.ec-pub-cards.is-ready .ec-pub-share > span {
    width: var(--ec-share, 0%);
}

.ec-pub-cards.is-ready .ec-pub-card {
    animation: ec-pub-rise 0.45s ease both;
}

.ec-pub-cards.is-ready .ec-pub-card:nth-child(2) { animation-delay: 0.06s; }
.ec-pub-cards.is-ready .ec-pub-card:nth-child(3) { animation-delay: 0.12s; }
.ec-pub-cards.is-ready .ec-pub-card:nth-child(4) { animation-delay: 0.18s; }

@keyframes ec-pub-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes ec-pub-pulse {
    0% { box-shadow: 0 0 0 0 rgba(13, 150, 104, 0.45); }
    70%, 100% { box-shadow: 0 0 0 8px rgba(13, 150, 104, 0); }
}

.ec-pub-card-total small {
    margin-left: 4px;
    font-size: 0.75rem;
    font-weight: 650;
    color: var(--ec-pub-muted);
}

.ec-pub-card-meta,
.ec-pub-chart-head p,
.ec-pub-chart-empty {
    margin: 0;
    color: var(--ec-pub-muted);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.ec-pub-card.is-empty .ec-pub-card-total {
    font-size: 1.2rem;
    color: var(--ec-pub-muted);
}

.ec-pub-chart-card {
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    padding: clamp(8px, 1.2vh, 14px) clamp(10px, 1.4vw, 16px) 8px;
}

.ec-pub-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.ec-pub-chart-head h2 {
    margin: 0 0 2px;
    font-size: 1rem;
    color: var(--ec-pub-heading);
}

.ec-pub-chart-avg {
    margin: 2px 0 0;
    color: var(--ec-pub-muted);
    font-size: 0.82rem;
    font-weight: 650;
}

.ec-pub-chart-avg:empty {
    display: none;
}

.ec-pub-chart-wrap {
    position: relative;
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.ec-pub-chart-wrap canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
}

.ec-pub-chart-wrap.is-empty canvas {
    visibility: hidden;
}

.ec-pub-chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ec-pub-chart-empty[hidden] {
    display: none;
}

.ec-pub-skel {
    display: block;
    height: 0.7rem;
    border-radius: 99px;
    background: linear-gradient(90deg, #e7f4ee 0%, #f7fbf9 45%, #e7f4ee 100%);
    background-size: 200% 100%;
    animation: ec-pub-shimmer 1.4s ease-in-out infinite;
}

.ec-pub-skel--title { width: 55%; }
.ec-pub-skel--total { width: 42%; height: 1.4rem; margin-top: 16px; }
.ec-pub-skel--meta { width: 70%; margin-top: 12px; }

@keyframes ec-pub-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@media (max-width: 1180px) {
    .ec-pub-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    body.page-electricity-public {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: auto;
    }

    .ec-pub-main {
        overflow: visible;
    }

    .ec-pub-container {
        height: auto;
        grid-template-rows: auto auto auto minmax(220px, 46vh);
    }

    .ec-pub-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .ec-pub-header p,
    #ec-pub-chart-hint {
        display: none;
    }

    .ec-pub-stats {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .ec-pub-stat {
        padding: 8px 10px;
    }

    .ec-pub-chart-head {
        flex-wrap: wrap;
    }

    .ec-pub-chart-wrap {
        min-height: 220px;
    }
}

@media (max-height: 760px) {
    .ec-pub-header p,
    #ec-pub-chart-hint {
        display: none;
    }

    .ec-pub-stat {
        padding: 8px 12px 6px;
    }
}

@media (max-width: 520px) {
    .ec-pub-stats,
    .ec-pub-cards {
        grid-template-columns: minmax(0, 1fr);
    }

    .ec-pub-stat + .ec-pub-stat {
        border-left: 0;
        border-top: 1px solid var(--ec-pub-border);
    }

    .ec-pub-badge {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ec-pub-skel,
    .ec-pub-live,
    .ec-pub-cards.is-ready .ec-pub-card {
        animation: none;
    }

    .ec-pub-share > span {
        transition: none;
        width: var(--ec-share, 0%);
    }
}
