/**
 * Stromkostenrechner
 *
 * Identisch gepflegt in Blocksy-Child und im MVC
 * (tempteria-mvc/public/assets/css/tools/electricity-calculator.css).
 * Aenderungen bitte immer in beide Dateien uebertragen.
 *
 * Farbquelle: erst Blocksy-Palette, dann MVC-Brandvariablen, dann Hex-Fallback.
 */

.ecalc {
    --ec-accent: var(--theme-palette-color-1, var(--brand-blue, #2872fa));
    --ec-energy: var(--brand-yellow, #ffd800);
    --ec-ink: var(--theme-headings-color, var(--ink, #1f1f1f));
    --ec-text: var(--theme-text-color, var(--muted, #5a5a5a));
    --ec-surface: var(--surface, #fff);
    --ec-surface-2: var(--surface-2, #f4f6fb);
    --ec-line: var(--border, #e5e7ea);
    --ec-radius: 16px;
    --ec-radius-sm: 10px;

    margin: 2.5rem 0;
    color: var(--ec-text);
    font-variant-numeric: tabular-nums;
    container-type: inline-size;
}

/* Dark Mode: MVC schaltet ueber data-theme, Blocksy ueber die Systemeinstellung. */
html[data-theme="dark"] .ecalc {
    --ec-surface: var(--surface, #111a2e);
    --ec-surface-2: var(--surface-2, #162038);
    --ec-line: var(--border, #1e2942);
    --ec-ink: var(--ink, #e8ecf4);
    --ec-text: var(--muted, #9aa7bd);
}

.ecalc *,
.ecalc *::before,
.ecalc *::after {
    box-sizing: border-box;
}

.ecalc__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@container (max-width: 720px) {
    .ecalc__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Fallback fuer Browser ohne Container-Queries */
@supports not (container-type: inline-size) {
    @media (max-width: 782px) {
        .ecalc__grid {
            grid-template-columns: minmax(0, 1fr);
        }
    }
}

.ecalc__panel {
    background: var(--ec-surface);
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    padding: 1.4rem;
}

.ecalc__legend {
    display: block;
    margin: 0 0 0.9rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ec-accent);
}

/* ------------------------------------------------------------ Geraete-Chips */

.ecalc__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}

.ecalc__chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.2;
    color: var(--ec-ink);
    background: var(--ec-surface-2);
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ecalc__chip:hover {
    border-color: var(--ec-accent);
}

.ecalc__chip[aria-pressed="true"] {
    background: var(--ec-accent);
    border-color: var(--ec-accent);
    color: #fff;
}

.ecalc__chip-watt {
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.65;
}

.ecalc__chip[aria-pressed="true"] .ecalc__chip-watt {
    opacity: 0.85;
}

.ecalc__chip--more {
    background: transparent;
    border: 1px dashed var(--ec-line);
    color: var(--ec-text);
    font-weight: 600;
}

.ecalc__chips[data-expanded="false"] .ecalc__chip[data-extra="true"] {
    display: none;
}

/* ------------------------------------------------------------ Eingabefelder */

.ecalc__fields {
    display: grid;
    gap: 1.1rem;
    margin-top: 1.2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--ec-line);
}

.ecalc__field > label,
.ecalc__field-head label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ec-ink);
}

.ecalc__field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.ecalc__input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--ec-ink);
    background: var(--ec-surface-2);
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ecalc__input--compact {
    width: 7.5rem;
    padding: 0.35rem 0.55rem;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 700;
}

.ecalc__input:focus-visible,
.ecalc__chip:focus-visible,
.ecalc__range:focus-visible {
    outline: 2px solid var(--ec-accent);
    outline-offset: 2px;
}

.ecalc__input:focus {
    border-color: var(--ec-accent);
}

.ecalc__unit {
    margin-left: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ec-text);
}

.ecalc__range {
    width: 100%;
    margin: 0.5rem 0 0;
    accent-color: var(--ec-accent);
    cursor: pointer;
}

.ecalc__scale {
    display: flex;
    justify-content: space-between;
    margin-top: 0.15rem;
    font-size: 0.7rem;
    opacity: 0.6;
}

.ecalc__hint {
    margin: 0.35rem 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
    opacity: 0.75;
}

.ecalc__error {
    margin: 0.9rem 0 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    color: var(--danger, #d63637);
    background: color-mix(in srgb, var(--danger, #d63637) 8%, transparent);
    border-radius: var(--ec-radius-sm);
}

.ecalc__error[hidden] {
    display: none;
}

/* ------------------------------------------------------------------ Ergebnis */

.ecalc__result {
    display: block;
    background: var(--ec-surface);
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    padding: 1.4rem;
}

.ecalc__headline {
    margin: 0 0 1.1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--ec-line);
}

.ecalc__headline-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ec-text);
}

.ecalc__headline-value {
    display: block;
    margin-top: 0.15rem;
    font-family: var(--font-head, inherit);
    font-size: clamp(2.4rem, 7cqi, 3.4rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.03em;
    color: var(--ec-ink);
}

.ecalc__headline-sub {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.85rem;
}

.ecalc__cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.ecalc__card {
    padding: 0.8rem;
    background: var(--ec-surface-2);
    border-radius: var(--ec-radius-sm);
}

.ecalc__card dt {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.7;
}

.ecalc__card dd {
    margin: 0.3rem 0 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ec-ink);
}

.ecalc__card-kwh {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.78rem;
    font-weight: 500;
    opacity: 0.7;
}

/* ------------------------------------------------ Signature: Vergleichsskala */

.ecalc__compare {
    margin-top: 1.3rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--ec-line);
}

.ecalc__compare-title {
    margin: 0 0 0.2rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ec-ink);
}

.ecalc__compare-note {
    margin: 0 0 0.9rem;
    font-size: 0.75rem;
    opacity: 0.7;
}

.ecalc__bars {
    display: grid;
    gap: 0.45rem;
    margin: 0;
}

.ecalc__bar {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr) 4.5rem;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.78rem;
}

.ecalc__bar-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ecalc__bar-track {
    height: 0.6rem;
    background: var(--ec-surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.ecalc__bar-fill {
    height: 100%;
    width: 0;
    background: color-mix(in srgb, var(--ec-accent) 35%, transparent);
    border-radius: 999px;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.ecalc__bar-value {
    text-align: right;
    font-weight: 600;
}

/* Das eigene Geraet ist der einzige Balken in Signalgelb — dort liegt die Betonung. */
.ecalc__bar--self {
    font-weight: 700;
    color: var(--ec-ink);
}

.ecalc__bar--self .ecalc__bar-fill {
    background: linear-gradient(90deg,
        var(--ec-energy) 0%,
        color-mix(in srgb, var(--ec-energy) 70%, #ff9d00) 100%);
}

.ecalc__bar--self .ecalc__bar-track {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ec-energy) 55%, transparent);
}

/* Fallback ohne color-mix */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .ecalc__bar-fill {
        background: #c3d5fb;
    }
    .ecalc__bar--self .ecalc__bar-fill {
        background: #ffd800;
    }
    .ecalc__error {
        background: #fdeaea;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ecalc *,
    .ecalc *::before,
    .ecalc *::after {
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================================
   Beitragsinhalt (.ec-prose)
   Analog zu .pg-prose beim Passwort-Generator, aber ueber die Tokens oben —
   damit Tabelle, Callout und FAQ im Dark Mode mitgehen.
   ========================================================================= */

.ec-prose {
    --ec-accent: var(--theme-palette-color-1, var(--brand-blue, #2872fa));
    --ec-energy: var(--brand-yellow, #ffd800);
    --ec-ink: var(--theme-headings-color, var(--ink, #1f1f1f));
    --ec-text: var(--theme-text-color, var(--muted, #5a5a5a));
    --ec-surface-2: var(--surface-2, #f7f8fb);
    --ec-line: var(--border, #e5e7ea);
    --ec-soft: var(--soft-blue, #eaf1ff);

    max-width: none;
    color: var(--ec-text);
}

html[data-theme="dark"] .ec-prose {
    --ec-surface-2: var(--surface-2, #162038);
    --ec-line: var(--border, #1e2942);
    --ec-ink: var(--ink, #e8ecf4);
    --ec-text: var(--muted, #9aa7bd);
    --ec-soft: var(--soft-blue, #14213f);
}

.ec-prose p {
    margin: 0 0 16px;
    line-height: 1.72;
    color: var(--ec-text);
}

.ec-prose h3 {
    margin: 0 0 8px;
    font-size: 17px;
    color: var(--ec-ink);
}

.ec-prose b,
.ec-prose strong {
    color: var(--ec-ink);
}

.ec-prose .ec-callout {
    margin: 26px 0;
    padding: 18px 22px;
    background: var(--ec-soft);
    border-left: 4px solid var(--ec-accent);
    border-radius: 0 12px 12px 0;
}

/* -------------------------------------------------------------- Gerätetabelle */

.ec-prose .ec-table-wrap {
    overflow-x: auto;
    margin: 0 0 8px;
}

.ec-prose .ec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.ec-prose .ec-table th {
    padding: 12px 14px;
    text-align: left;
    font-size: 12.5px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--ec-text);
    border-bottom: 1px solid var(--ec-line);
}

.ec-prose .ec-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--ec-line);
    color: var(--ec-text);
    white-space: nowrap;
}

.ec-prose .ec-table td:first-child {
    font-weight: 700;
    color: var(--ec-ink);
    white-space: normal;
}

/* Zahlenspalten rechtsbuendig — so sind die Betraege untereinander vergleichbar. */
.ec-prose .ec-table th:not(:first-child),
.ec-prose .ec-table td:not(:first-child) {
    text-align: right;
}

.ec-prose .ec-table td:last-child {
    font-weight: 700;
    color: var(--ec-ink);
}

.ec-prose .ec-table tr:last-child td {
    border-bottom: 0;
}

/* Dauerlaeufer: die Zeilen, um die es im Text geht. */
.ec-prose .ec-table tr.is-marked td:first-child {
    box-shadow: inset 3px 0 0 var(--ec-energy);
    padding-left: 18px;
}

/* ------------------------------------------------------------------ Vergleich */

.ec-prose .ec-compare {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 24px 0 8px;
}

.ec-prose .ec-compare-card {
    padding: 22px;
    background: var(--ec-surface-2);
    border: 1px solid var(--ec-line);
    border-radius: 15px;
}

.ec-prose .ec-compare-card p:last-child {
    margin: 0;
    font-size: 14.5px;
}

.ec-prose .ec-figure {
    margin-bottom: 12px !important;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ec-accent) !important;
}

/* ------------------------------------------------------------------------ FAQ */

.ec-prose .ec-faq details {
    border-bottom: 1px solid var(--ec-line);
}

.ec-prose .ec-faq summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 0;
    font-weight: 700;
    color: var(--ec-ink);
    cursor: pointer;
    list-style: none;
}

.ec-prose .ec-faq summary::-webkit-details-marker {
    display: none;
}

.ec-prose .ec-faq summary::after {
    content: "+";
    flex: 0 0 auto;
    font-size: 22px;
    font-weight: 400;
    color: var(--ec-accent);
    transition: transform 0.2s;
}

.ec-prose .ec-faq details[open] summary::after {
    transform: rotate(45deg);
}

.ec-prose .ec-faq details p {
    margin: 0 0 18px;
    padding-right: 36px;
}

@media (prefers-reduced-motion: reduce) {
    .ec-prose .ec-faq summary::after {
        transition: none;
    }
}
