/* ==============================================
   Historical Rates Page Styles
   /electricity-prices-by-state/historical/
   ============================================== */

/* ---- Stat cards (1990 vs 2026 comparison) ---- */
.hist-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin: 32px 0 8px;
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius);
    overflow: hidden;
}
.hist-stat-item {
    padding: 28px 24px;
    text-align: center;
    border-right: 1px solid var(--ec-border-light);
    position: relative;
}
.hist-stat-item:nth-child(even) { background: var(--ec-surface-alt); }
.hist-stat-item:last-child { border-right: none; }
.hist-stat-item:nth-child(1)::after,
.hist-stat-item:nth-child(3)::after {
    content: '→';
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--ec-text-muted);
    z-index: 1;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ec-border-light);
}
.hist-stat-value {
    font-size: clamp(28px, 3.5vw, 42px);
    font-weight: 800;
    color: var(--ec-accent);
    line-height: 1;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.hist-stat-value--current { color: var(--ec-text); }
.hist-stat-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--ec-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
@media (max-width: 640px) {
    .hist-stat-grid { grid-template-columns: 1fr 1fr; }
    .hist-stat-item { padding: 20px 16px; }
    .hist-stat-item:nth-child(1),
    .hist-stat-item:nth-child(2) { border-bottom: 1px solid var(--ec-border-light); }
    .hist-stat-item:nth-child(2) { border-right: none; }
    .hist-stat-item:nth-child(3)::after { display: none; }
    .hist-stat-value { font-size: clamp(24px, 6vw, 32px); }
}

/* ---- Chart ---- */
.hist-chart-wrap {
    border: 1px solid var(--ec-border);
    border-radius: var(--ec-radius);
    background: #fff;
    padding: 28px 24px 20px;
    margin: 8px 0 0;
    position: relative;
}
.hist-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.hist-chart-legend {
    display: flex;
    gap: 20px;
}
.hist-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ec-text-secondary);
}
.hist-chart-legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}
.hist-chart-legend-line--res { background: #7c3aed; }
.hist-chart-legend-line--com { background: #0ea5e9; }
.hist-chart-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 2.2 / 1;
    min-height: 280px;
}
.hist-chart-canvas svg {
    width: 100%;
    height: 100%;
    display: block;
}
.hist-chart-tooltip {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    background: #1f2937;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.12s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transform: translate(-50%, -110%);
}
.hist-chart-tooltip.is-visible { opacity: 1; }
.hist-chart-tooltip strong { font-weight: 700; }
.hist-chart-tooltip .tt-res { color: #c4b5fd; }
.hist-chart-tooltip .tt-com { color: #7dd3fc; }
.hist-chart-source {
    font-size: 13px;
    color: var(--ec-text-muted);
    margin-top: 14px;
    text-align: center;
}
.hist-chart-source a { color: var(--ec-accent); text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 640px) {
    .hist-chart-wrap { padding: 20px 16px 16px; }
    .hist-chart-canvas { aspect-ratio: 1.5 / 1; min-height: 220px; }
}

/* ---- Era cards (fix missing hist-era-* variants) ---- */
.hist-era-card { display: flex; flex-direction: column; gap: 8px; padding: 28px; border-radius: 14px; border: 1px solid; }
.hist-era-card--red { border-color: #fecaca; background: linear-gradient(180deg, #fff1f2 0%, #fff 100%); }
.hist-era-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hist-era-name { font-size: clamp(20px, 2.2vw, 24px); font-weight: 700; margin: 0; padding: 0; color: #1f1f1f; }
.hist-era-rate { font-size: 15px; font-weight: 700; color: #9ca3af; white-space: nowrap; }

/* ---- Table context column ---- */
.ec-table .ec-col-context {
    font-size: 14px;
    color: var(--ec-text-dim);
    font-style: italic;
    max-width: 260px;
    line-height: 1.5;
}
.ec-table thead th.ec-col-context {
    font-style: normal;
}
.ec-table thead th { position: sticky; top: 0; z-index: 2; }
.ec-rate-change { font-weight: 600; font-size: 14px; white-space: nowrap; }
.ec-rate-change--up { color: #dc2626; }
.ec-rate-change--down { color: #16a34a; }
.ec-table-highlight td { background: #f0fdf4 !important; font-weight: 700; }
.ec-table-highlight td:first-child { position: relative; }
.ec-table-highlight td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--ec-accent);
}

/* ---- Structural analysis section ---- */
.hist-structure-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 28px 0;
}
.hist-structure-card {
    border: 1px solid var(--ec-border);
    border-radius: 14px;
    padding: 28px 24px;
    position: relative;
}
.hist-structure-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 14px;
}
.hist-structure-card:nth-child(1) .hist-structure-num { background: #7c3aed; }
.hist-structure-card:nth-child(1) { border-top: 3px solid #7c3aed; }
.hist-structure-card:nth-child(2) .hist-structure-num { background: #f59e0b; }
.hist-structure-card:nth-child(2) { border-top: 3px solid #f59e0b; }
.hist-structure-card:nth-child(3) .hist-structure-num { background: #0ea5e9; }
.hist-structure-card:nth-child(3) { border-top: 3px solid #0ea5e9; }
.hist-structure-card h4 {
    font-size: 18px;
    font-weight: 700;
    color: #1f1f1f;
    margin: 0 0 10px;
    padding: 0;
}
.hist-structure-card p {
    font-size: 15px;
    color: var(--ec-text-dim);
    margin: 0;
    line-height: 1.7;
}
.hist-structure-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--ec-border-light);
}
.hist-structure-stat-val {
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}
.hist-structure-stat-label {
    font-size: 13px;
    color: var(--ec-text-muted);
}
@media (max-width: 768px) {
    .hist-structure-grid { grid-template-columns: 1fr; }
}

/* ---- Bill composition bar ---- */
.hist-bill-bar-wrap { margin: 28px 0; }
.hist-bill-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--ec-text-dim);
    margin-bottom: 8px;
}
.hist-bill-bar {
    display: flex;
    width: 100%;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
}
.hist-bill-bar span {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}
.hist-bill-bar-legend {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.hist-bill-bar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ec-text-secondary);
}
.hist-bill-bar-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
