.error-message {
    color: #a00;
}

.dof-chart {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    /* min-height: 90vh; */
    /* padding-inline: 12px; */
}

.dof-chart[data-chart-type="bar-vertical"],
.dof-chart[data-chart-type="bar-horizontal"],
.dof-chart[data-chart-type="line-single"],
.dof-chart[data-chart-type="line-multi"] {
    height: auto;
}

/* ECharts needs an explicit height on the div it mounts into. */
.dof-bar-inner,
.dof-line-inner {
    min-width: 250px;
    height: clamp(400px, 30vh, 600px);
}

/* bar-horizontal.js sets its own height from the category count. */
.dof-bar-inner--horizontal {
    height: auto;
}

/* Room for the legend below the plot. */
.dof-line-inner--multi {
    height: clamp(440px, 34vh, 660px);
}

.dof-chart-title {
    text-align: center;
    text-wrap: balance;
}
.dof-chart-subtitle {
    text-align: center;
    color: #555;
    margin-bottom: 12px;
    text-wrap: balance;
}
.dof-chart-source {
    text-align: center;
    text-wrap: balance;
    font-size: 0.78em;
    color: #888;
    margin-top: 8px;
}

/* Download-data button, bottom right under the chart.
   A flow-level row rather than an absolutely positioned corner: the source note
   above it is centred and can wrap to two lines, and an overlay would land on
   top of it on narrow screens. */
.dof-chart-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.dof-chart-download {
    font: inherit;
    font-size: 0.78em;
    line-height: 1.4;
    color: #1c4647;
    background: transparent;
    border: 1px solid #1c4647;
    border-radius: 3px;
    padding: 4px 10px;
    cursor: pointer;
    transition:
        color 0.2s ease,
        border-color 0.15s ease,
        background-color 0.15s ease;
}

.dof-chart-download:hover,
.dof-chart-download:focus-visible {
    color: #faf4f3;
    border-color: #1c4647;
    background: #1c4647;
}

/* Nothing to click on paper. */
@media print {
    .dof-chart-actions {
        display: none;
    }
}

/* Loading spinner */
.dof-chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.dof-chart-loading::after {
    content: "";
    width: 36px;
    height: 36px;
    border: 4px solid #ddd;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: dof-spin 0.75s linear infinite;
}

@keyframes dof-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error box */
.dof-chart-error {
    border: 2px solid #c62828;
    color: #c62828;
    background: #fff5f5;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
    .dof-chart {
        min-height: 50vh;
    }
}

@media (max-width: 480px) {
    .dof-bar-inner,
    .dof-line-inner {
        height: 350px;
    }
    .dof-bar-inner--horizontal {
        height: auto;
    }
    .dof-line-inner--multi {
        height: 420px;
    }
}
