/* ===== Article Page ===== */

.article {
    overflow-x: clip;
}

.article__header {
    padding: calc(6rem + var(--section-padding)) 0 3rem;
    background: linear-gradient(160deg, #2a1b47 0%, var(--deep-purple) 40%, #1e1440 100%);
    color: var(--white);
}

.article__header .container {
    max-width: calc(740px + clamp(1.5rem, 4vw, 3rem) * 2);
}

.article__back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--light-purple);
    margin-bottom: 1.5rem;
    transition: color 0.2s ease;
}

.article__back:hover {
    color: var(--white);
}

.article__title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    max-width: 740px;
    margin-bottom: 1.25rem;
}

.article__meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

.article__separator {
    color: rgba(255, 255, 255, 0.3);
}

/* ===== Article Layout ===== */
.article__container {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 3rem;
    padding: var(--section-padding) 0;
    max-width: 960px;
    margin: 0 auto;
}

.article__container--no-toc {
    grid-template-columns: 1fr;
    max-width: 740px;
}

/* ===== Table of Contents ===== */
.article__toc {
    position: sticky;
    top: 100px;
    align-self: start;
}

.article__toc h4 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 1rem;
}

.toc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-nav li {
    margin-bottom: 0.25rem;
}

.toc-nav a {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.3rem 0;
    transition: color 0.2s ease;
    line-height: 1.4;
}

.toc-nav a:hover {
    color: var(--purple);
}

.toc-nav__sub {
    padding-left: 1rem;
}

/* ===== Article Body - Prose Styles ===== */
.article__body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-dark);
}

/* Prose reading column — text stays narrow, charts/embeds go full-width */
.article__body > p,
.article__body > h2,
.article__body > h3,
.article__body > ul,
.article__body > ol,
.article__body > blockquote,
.article__body > hr,
.article__body > .callout,
.article__body > .article-lede,
.article__body > .how-we-did-this,
.article__body > .footnotes {
    max-width: 740px;
    margin-left: auto;
    margin-right: auto;
}

.article__body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    color: var(--text-dark);
}

.article__body h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2rem 0 0.75rem;
    color: var(--text-dark);
}

.article__body p {
    margin-bottom: 1.25rem;
}

.article__body a {
    color: var(--purple);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

.article__body a:hover {
    color: var(--teal);
}

.article__body img {
    border-radius: 12px;
    margin: 1.5rem 0;
    width: 100%;
}

.article__body blockquote {
    border-left: 3px solid var(--purple);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.article__body ul,
.article__body ol {
    padding-left: 1.5rem;
    margin-bottom: 1.25rem;
}

.article__body li {
    margin-bottom: 0.4rem;
    line-height: 1.7;
}

.article__body ul {
    list-style: disc;
}

.article__body ol {
    list-style: decimal;
}

.article__body code {
    background: var(--off-white);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.article__body pre {
    background: var(--off-white);
    border: 1px solid rgba(82, 48, 139, 0.08);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.article__body pre code {
    background: none;
    padding: 0;
}

.article__body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

.article__body th,
.article__body td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(82, 48, 139, 0.08);
}

.article__body th {
    font-weight: 600;
    color: var(--purple);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
}

.article__body hr {
    border: none;
    border-top: 1px solid rgba(82, 48, 139, 0.1);
    margin: 2.5rem 0;
}

/* ===== Chart Embed Container ===== */
.chart-embed {
    background: var(--off-white);
    border: 1px solid rgba(82, 48, 139, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.chart-embed__title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.chart-embed__plot {
    min-height: 300px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .article__container {
        grid-template-columns: 1fr;
        padding-left: clamp(1.5rem, 4vw, 3rem);
        padding-right: clamp(1.5rem, 4vw, 3rem);
    }

    .article__toc {
        position: static;
        margin-bottom: 2rem;
        padding-bottom: 1.5rem;
        border-bottom: 1px solid rgba(82, 48, 139, 0.08);
    }
}

/* ===== Callout Box ===== */
.callout {
    background: var(--off-white);
    border: 1px solid rgba(82, 48, 139, 0.12);
    border-left: 3px solid var(--purple);
    border-radius: 8px;
    padding: 1.5rem 1.75rem 1.25rem;
    margin: 2rem 0;
}
.callout h4 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 0.75rem;
}
.callout p, .callout ul {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout ul { padding-left: 1.25rem; }
.callout li { margin-bottom: 0.5rem; }

/* ===== Article Lede (opening insight tile) ===== */
.article-lede {
    background: linear-gradient(135deg, rgba(82, 48, 139, 0.03) 0%, rgba(82, 48, 139, 0.07) 100%);
    border: 1px solid rgba(82, 48, 139, 0.1);
    border-radius: 12px;
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
}
.article-lede p {
    font-size: 1.12rem;
    line-height: 1.75;
    color: var(--text-dark);
}
.article-lede p:last-child { margin-bottom: 0; }

/* ===== Chart Pair (side-by-side) ===== */
.chart-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0 0;
}
.chart-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.4rem 0 1.5rem;
}
.chart-pair--horizontal { grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.chart-pair.chart-pair--horizontal img { width: 100%; height: auto; }
.chart-pair.chart-pair--horizontal img:first-child { width: 76.9%; display: block; margin: 0 auto; }
.chart-pair img {
    width: 100%; height: auto;
    border-radius: 8px;
    border: 1px solid rgba(82, 48, 139, 0.08);
    margin: 0;
}
.chart-frame { margin: 0; }
.chart-frame figcaption {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.chart-frame img {
    width: 100%; height: auto;
    border-radius: 8px;
    border: 1px solid rgba(82, 48, 139, 0.08);
    margin: 0;
}
.ldc-chart {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(82, 48, 139, 0.06);
    background: #FAFAFA;
}

/* ===== LDC Explorer (interactive dashboard) ===== */
.ldc-explorer {
    margin: 0;
}
.ldc-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    align-items: flex-end;
    background: var(--off-white);
    border: 1px solid rgba(82, 48, 139, 0.1);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.ldc-ctrl label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.ldc-ctrl select,
.ldc-ctrl input[type="number"] {
    font-size: 0.85rem;
    color: var(--text-dark);
    background: #fff;
    border: 1px solid rgba(82, 48, 139, 0.2);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    height: 32px;
    cursor: pointer;
    font-family: inherit;
}
.ldc-ctrl select:focus,
.ldc-ctrl input[type="number"]:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(82, 48, 139, 0.12);
}
.ldc-ctrl input[type="number"] { width: 82px; }
.ldc-ctrl--check label {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    padding-bottom: 4px;
}
.ldc-ctrl--check input[type="checkbox"] { cursor: pointer; }
@media (max-width: 640px) {
    .ldc-controls { gap: 0.5rem; }
    .ldc-ctrl select { width: 100%; }
}

/* ===== Section Commentary ===== */
.section-commentary {
    background: var(--off-white);
    border: 1px solid rgba(82, 48, 139, 0.08);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}
.section-commentary p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.section-commentary p:last-child { margin-bottom: 0; }

/* ===== Legend ===== */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(82, 48, 139, 0.1);
}
.legend-item { display: flex; align-items: flex-start; gap: 0.6rem; flex: 1 1 180px; }
.legend-swatches { display: flex; gap: 2px; margin-top: 3px; flex-shrink: 0; }
.legend-swatch { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.legend-text { font-size: 0.8rem; line-height: 1.5; color: var(--text-muted); }
.legend-text strong { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dark); margin-bottom: 1px; }

/* ===== Chart label & inline legend ===== */
.chart-label { font-size: 0.82rem; color: var(--text-muted); font-style: italic; margin: 1.5rem 0 0.5rem; }
.chart-legend { display: flex; gap: 1.25rem; margin-bottom: 0.75rem; font-size: 0.82rem; color: var(--text-muted); }
.chart-legend-item { display: flex; align-items: center; gap: 0.4rem; }
.chart-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ===== How We Did This (methodology box) ===== */
.how-we-did-this {
    background: var(--off-white);
    border: 1px solid rgba(82, 48, 139, 0.12);
    border-radius: 8px;
    padding: 1.5rem 1.75rem 1.25rem;
    margin: 2.5rem 0 1.5rem;
}
.how-we-did-this h3 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--purple);
    margin: 0 0 0.75rem;
}
.how-we-did-this p {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.how-we-did-this p:last-child { margin-bottom: 0; }
.how-we-did-this sup { font-size: 0.75em; }
.how-we-did-this__figure {
    margin: 1rem 0 0;
    padding: 0 2rem;
}
.how-we-did-this__figure figcaption {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.how-we-did-this img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid rgba(82, 48, 139, 0.12);
    margin: 0.75rem 0 0;
}
.how-we-did-this .how-we-did-this__figure img {
    border: none;
    margin: 0;
}

/* ===== Contact CTA box ===== */
.contact-cta {
    background: linear-gradient(135deg, rgba(82, 48, 139, 0.06) 0%, rgba(82, 48, 139, 0.03) 100%);
    border: 1px solid rgba(82, 48, 139, 0.2);
    border-left: 3px solid var(--purple);
    border-radius: 6px;
    padding: 1.1rem 1.4rem;
    margin: 1.5rem 0;
}
.contact-cta p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-dark);
}
.contact-cta a {
    color: var(--purple);
    font-weight: 600;
    text-decoration: none;
}
.contact-cta a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .chart-pair { grid-template-columns: 1fr; }
    .legend { flex-direction: column; }
}

/* ===== Battery Value Bar Chart ===== */
.value-bar-chart {
    display: flex;
    gap: 1.5rem;
    margin: 2rem 0 1.75rem;
    align-items: stretch;
}
.value-bar {
    width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-radius: 6px;
    overflow: hidden;
    min-height: 340px;
}
.value-bar--mini {
    min-height: 110px;
    margin: 1.5rem 0 2rem;
}
.value-bar__seg {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    color: white;
}
.value-bar__seg + .value-bar__seg {
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}
.value-bar__seg--cong   { background: #e8913a; flex: 10; }
.value-bar__seg--loss   { background: #cf7a25; flex: 10; }
.value-bar__seg--tariff { background: #f0a653; flex: 10; color: #4a2e00; }
.value-bar__seg--alpha  { background: #3a8c5a; flex: 22; }
.value-bar__seg--dev    { background: #52308B; flex: 36; }
.value-bar__seg--land   { background: #9ca3af; flex: 12; }
/* FTM/BTM dividing line — sits on top of developer margin segment */
.value-bar__seg--ftm-line {
    border-top: 2px dashed rgba(255, 255, 255, 0.75) !important;
}
/* Click interactivity */
.value-bar__seg[data-key] { cursor: pointer; transition: filter 0.12s ease; }
.value-bar__seg[data-key]:hover { filter: brightness(1.1); }
.value-bar__seg.vb-active {
    filter: brightness(1.2);
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: -2px;
    position: relative;
    z-index: 1;
}
/* Annotation column */
.value-bar-annot {
    width: 82px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}
.vba-group {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem 0.75rem;
    position: relative;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.vba-group::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 2px;
    border-radius: 1px;
}
/* BTM group covers: cong(10)+loss(10)+tariff(10)+alpha(22) = 52 */
.vba-group--btm { flex: 52; color: #7a4000; border-bottom: 1px dashed rgba(0,0,0,0.15); }
.vba-group--btm::before { background: #e8913a; }
/* FTM group covers: dev(36)+land(12) = 48 */
.vba-group--ftm { flex: 48; color: var(--purple); }
.vba-group--ftm::before { background: var(--purple); }

.value-bar-legend {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.value-bar-legend__group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.value-bar-legend__group-header {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.3rem 0.65rem;
    border-radius: 3px;
    margin-bottom: 0.1rem;
}
.vblg--btm {
    background: rgba(232, 145, 58, 0.1);
    color: #7a4000;
    border: 1px solid rgba(232, 145, 58, 0.25);
}
.vblg--base {
    background: rgba(82, 48, 139, 0.07);
    color: var(--purple);
    border: 1px solid rgba(82, 48, 139, 0.15);
}
.value-bar-legend__row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    border-radius: 4px;
    padding: 0.2rem 0.35rem;
    margin: -0.2rem -0.35rem;
    transition: background 0.12s ease;
}
.value-bar-legend__row:hover { background: rgba(82, 48, 139, 0.04); }
.value-bar-legend__row.vb-active { background: rgba(82, 48, 139, 0.07); }
.value-bar-legend__row.vb-active strong { color: var(--purple); }
.vb-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 3px;
}
.vb-dot--cong   { background: #e8913a; }
.vb-dot--loss   { background: #cf7a25; }
.vb-dot--tariff { background: #f0a653; }
.vb-dot--alpha  { background: #3a8c5a; }
.vb-dot--dev    { background: #52308B; }
.vb-dot--land   { background: #9ca3af; }
.value-bar-legend__row strong {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.1rem;
    line-height: 1.3;
}
.value-bar-legend__row p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0;
    line-height: 1.5;
}
@media (max-width: 580px) {
    .value-bar-chart { flex-direction: column; }
    .value-bar { width: 100%; min-height: 80px; flex-direction: row; border-radius: 6px; }
    .value-bar__seg { font-size: 0.58rem; }
    .value-bar__seg + .value-bar__seg { border-top: none; border-left: 1px solid rgba(255,255,255,0.18); }
    .value-bar__seg--ftm-line { border-top: none !important; border-left: 2px dashed rgba(255,255,255,0.75) !important; }
    .value-bar-annot { display: none; }
}

/* ===== Risk Comparison Accordion ===== */
.risk-accordion {
    margin: 1.5rem 0;
}
.risk-item {
    border: 1px solid rgba(82, 48, 139, 0.12);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.risk-item > summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    background: var(--off-white);
    color: var(--text-dark);
    font-size: 1rem;
}
.risk-item > summary::-webkit-details-marker { display: none; }
.risk-item[open] > summary {
    background: rgba(82, 48, 139, 0.05);
    border-bottom: 1px solid rgba(82, 48, 139, 0.1);
}
.risk-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.risk-compare__col {
    padding: 1.1rem 1.5rem 1rem;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-muted);
}
.risk-compare__col + .risk-compare__col {
    border-left: 1px solid rgba(82, 48, 139, 0.1);
}
.risk-compare__col p { margin-bottom: 0; }
.risk-compare__label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

/* ===== Scenario Cards ===== */
.scenario-cards {
    display: grid;
    gap: 0.75rem;
    margin: 1.5rem 0;
}
.scenario-card {
    border: 1px solid rgba(82, 48, 139, 0.1);
    border-radius: 8px;
    overflow: hidden;
}
.scenario-card__header {
    padding: 0.7rem 1.25rem;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.scenario-card__header::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.scenario-card--red .scenario-card__header { background: rgba(220, 38, 38, 0.07); color: #b91c1c; }
.scenario-card--red .scenario-card__header::before { background: #dc2626; }
.scenario-card--amber .scenario-card__header { background: rgba(217, 119, 6, 0.07); color: #92400e; }
.scenario-card--amber .scenario-card__header::before { background: #d97706; }
.scenario-card--green .scenario-card__header { background: rgba(22, 163, 74, 0.07); color: #166534; }
.scenario-card--green .scenario-card__header::before { background: #16a34a; }
.scenario-card__body {
    padding: 1rem 1.25rem;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-muted);
}
.scenario-card__body p { margin-bottom: 0; }

@media (max-width: 640px) {
    .risk-compare { grid-template-columns: 1fr; }
    .risk-compare__col + .risk-compare__col {
        border-left: none;
        border-top: 1px solid rgba(82, 48, 139, 0.1);
    }
}
