/* [spot_price_chart] — server-rendered SVG, see includes/templates/spot-price-chart.php.
   .is-interactive is added by src/spotPriceChart.ts. */

.elberegner-spc {
    position: relative;
    margin: 0 0 1.5em;
    color: #444;
}

/* rtl on the scroller makes it start scrolled to the newest months; ltr restored inside. */
.elberegner-spc__scroll {
    overflow-x: auto;
    direction: rtl;
}

.elberegner-spc__track {
    direction: ltr;
}

/* Scales between 60% and 80% of the natural width (--spc-w, in viewBox units). */
.elberegner-spc__svg {
    display: block;
    width: 100%;
    min-width: calc(var(--spc-w) * 0.6px);
    max-width: calc(var(--spc-w) * 0.8px);
    margin: 0 auto;
    height: auto;
    font-family: inherit;
}

/* Without container queries the y labels simply scroll with the chart. */
.elberegner-spc__yaxis {
    display: none;
}

.elberegner-spc__yaxis-bg {
    fill: var(--spc-bg, #fff);
}

.elberegner-spc__yaxis-bg--low {
    opacity: 0;
}

.elberegner-spc.is-scrolled .elberegner-spc__yaxis-bg--low {
    opacity: 1;
}

@supports (width: 1cqw) {
    .elberegner-spc__scroll {
        container-type: inline-size;
    }

    /* Both SVGs share one grid cell; the y axis sticks to the left edge on top. */
    .elberegner-spc__track {
        display: grid;
        width: max-content;
        margin: 0 auto;
    }

    .elberegner-spc__svg,
    .elberegner-spc__yaxis {
        grid-area: 1 / 1;
        justify-self: start;
    }

    .elberegner-spc__svg {
        width: clamp(calc(var(--spc-w) * 0.6px), 100cqw, calc(var(--spc-w) * 0.8px));
        min-width: 0;
        max-width: none;
        margin: 0;
    }

    .elberegner-spc__yaxis {
        display: block;
        position: sticky;
        left: 0;
        z-index: 1;
        width: calc(clamp(calc(var(--spc-w) * 0.6px), 100cqw, calc(var(--spc-w) * 0.8px)) * var(--spc-left) / var(--spc-w));
        height: auto;
        pointer-events: none;
    }

    /* Fit: the chart takes the height its container leaves over (the embed page), up to
       80% of its natural size, so a fixed-height iframe never clips the caption. */
    .elberegner-spc--fit {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .elberegner-spc--fit .elberegner-spc__scroll {
        display: flex;
        flex: 1 1 0;
        min-height: 0;
        container-type: size;
    }

    /* flex: none, or the track shrinks to the scroller and the newest months overflow
       to the right, which an rtl scroller can't scroll to. */
    .elberegner-spc--fit .elberegner-spc__track {
        flex: none;
        margin: auto;
    }

    .elberegner-spc--fit .elberegner-spc__svg,
    .elberegner-spc--fit .elberegner-spc__yaxis {
        width: auto;
        height: min(100cqh, calc(var(--spc-h) * 0.8px));
    }
}

.elberegner-spc__bar--dk1,
.elberegner-spc__swatch--dk1 {
    fill: var(--spc-dk1);
    background: var(--spc-dk1);
}

.elberegner-spc__bar--dk2,
.elberegner-spc__swatch--dk2 {
    fill: var(--spc-dk2);
    background: var(--spc-dk2);
}

.elberegner-spc__bar {
    transition: opacity 0.25s;
}

.elberegner-spc__bar.is-hidden {
    opacity: 0;
}

.elberegner-spc__ticks {
    transition: opacity 0.25s;
}

.elberegner-spc__ticks.is-entering,
.elberegner-spc__ticks.is-leaving {
    opacity: 0;
}

.elberegner-spc__highlight {
    fill: currentColor;
    opacity: 0;
}

.elberegner-spc__highlight.is-active {
    opacity: 0.06;
}

.elberegner-spc__grid {
    stroke: #ececec;
    stroke-width: 1.5;
}

.elberegner-spc__axis {
    stroke: #d9d9d9;
    stroke-width: 1.5;
}

.elberegner-spc__y-label,
.elberegner-spc__x-label {
    fill: currentColor;
    font-size: 20px;
}

.elberegner-spc__title {
    margin: 0 0 0.5em;
    font-weight: 600;
    color: inherit;
}

.elberegner-spc__caption {
    text-align: left;
}

/* Toggles bottom left, the moms note bottom right. */
.elberegner-spc__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5em 1.5em;
    margin-top: 0.75em;
}

.elberegner-spc__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em 1.1em;
    margin: 0;
    padding: 0;
    list-style: none;
}

.elberegner-spc__legend li {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0;
}

.elberegner-spc__swatch {
    width: 0.9em;
    height: 0.9em;
    border-radius: 0.2em;
}

.elberegner-spc__note {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0 0 0 auto;
    font-size: 0.85em;
    color: #9ca3af;
}

.elberegner-spc__info {
    flex: none;
}

.elberegner-spc__note:focus {
    outline: none;
}

.elberegner-spc__note:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 0.25em;
}

/* Too narrow for the toggles and the note on one line (a phone): the note folds into its
   (i) icon and opens as a bubble on tap, hover or focus. Screen readers still read the text.
   Without container queries the note simply wraps below the toggles. */
.elberegner-spc__caption {
    container-type: inline-size;
}

@container (max-width: 28em) {
    .elberegner-spc__meta {
        flex-wrap: nowrap;
    }

    .elberegner-spc__note {
        position: relative;
        flex: none;
        /* A bigger tap target around the 14 px icon, without moving it. */
        margin: -0.5em -0.5em -0.5em auto;
        padding: 0.5em;
        cursor: pointer;
    }

    .elberegner-spc__note-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .elberegner-spc__note:hover .elberegner-spc__note-text,
    .elberegner-spc__note:focus .elberegner-spc__note-text {
        z-index: 2;
        right: 0;
        bottom: 100%;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
        padding: 0.45em 0.7em;
        border: 1px solid #e6e6e6;
        border-radius: 0.6em;
        background: #fff;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
        color: #444;
    }
}

/* "Powered by": a hairline fading out on each side, like the live-data footer. */
.elberegner-spc__credit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.25em 0 0;
    padding: 0;
}

.elberegner-spc__credit-line {
    /* Short, like the design; the live-data footer lets them fill the row. */
    flex: 0 1 4rem;
    height: 1px;
    background: linear-gradient(to right, transparent, #e5e7eb);
}

.elberegner-spc__credit-line--end {
    background: linear-gradient(to left, transparent, #e5e7eb);
}

.elberegner-spc__credit-text {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #d1d5db;
    white-space: nowrap;
}

.elberegner-spc__credit-text a {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.2s;
}

.elberegner-spc__credit-text a:hover {
    color: #4b5563;
}

/* Legend toggles: a checkbox in the area's colour with a white check, then the name.
   Doubled class so theme `button:hover` rules don't win. */
.elberegner-spc .elberegner-spc__toggle,
.elberegner-spc .elberegner-spc__toggle:hover,
.elberegner-spc .elberegner-spc__toggle:focus {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0.25em;
    background: none;
    box-shadow: none;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-transform: none;
    cursor: pointer;
    transition: color 0.15s;
}

.elberegner-spc .elberegner-spc__toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.elberegner-spc .elberegner-spc__toggle[aria-disabled="true"] {
    cursor: default;
}

.elberegner-spc__toggle .elberegner-spc__swatch {
    position: relative;
    width: 1.15em;
    height: 1.15em;
    border-radius: 0.28em;
}

.elberegner-spc__legend li > .elberegner-spc__swatch::after,
.elberegner-spc__toggle[aria-pressed="true"] .elberegner-spc__swatch::after {
    content: "";
    position: absolute;
    left: 34%;
    top: 14%;
    width: 28%;
    height: 54%;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.elberegner-spc .elberegner-spc__toggle[aria-pressed="false"] {
    color: #9ca3af;
}

.elberegner-spc__toggle[aria-pressed="false"] .elberegner-spc__swatch {
    background: #fff;
}

.elberegner-spc__toggle[aria-pressed="false"] .elberegner-spc__swatch--dk1 {
    box-shadow: inset 0 0 0 2px var(--spc-dk1);
}

.elberegner-spc__toggle[aria-pressed="false"] .elberegner-spc__swatch--dk2 {
    box-shadow: inset 0 0 0 2px var(--spc-dk2);
}

@media (prefers-reduced-motion: reduce) {
    .elberegner-spc .elberegner-spc__toggle {
        transition: none;
    }
}

/* Tooltip */
.elberegner-spc__tooltip {
    position: absolute;
    z-index: 2;
    transform: translate(-50%, calc(-100% - 10px));
    padding: 0.6em 0.75em;
    border: 1px solid #e6e6e6;
    border-radius: 0.6em;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    color: #333;
    font-size: 0.85em;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
}

.elberegner-spc__tooltip[hidden] {
    display: none;
}

.elberegner-spc__tooltip::after {
    content: "";
    position: absolute;
    left: var(--spc-arrow, 50%);
    bottom: -6px;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-right: 1px solid #e6e6e6;
    border-bottom: 1px solid #e6e6e6;
    background: #fff;
    transform: rotate(45deg);
}

.elberegner-spc__tooltip-month {
    margin-bottom: 0.3em;
    font-weight: 600;
}

.elberegner-spc__tooltip-rows {
    display: grid;
    grid-template-columns: auto auto auto;
    align-items: center;
    gap: 0.25em 0.5em;
}

.elberegner-spc__tooltip-value {
    margin-left: 0.75em;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .elberegner-spc__bar,
    .elberegner-spc__ticks {
        transition: none;
    }
}
