/* ==========================================================================
   Fact & Figure — editorial stylesheet
   Type: Fraunces (display serif) + Inter (text sans)
   ========================================================================== */

:root {
    --paper: #faf8f4;
    --paper-alt: #f2eee6;
    --ink: #1b2733;
    --ink-soft: #4a5764;
    --rule: #e0d9cc;
    --accent: #b4532a;        /* burnt sienna — myth / warning */
    --verdict: #1e6e5c;       /* deep green — verdict */
    --navy: #1f4e79;          /* primary data color */
    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Global -------------------------------------------------------------- */

html {
    scroll-behavior: smooth;
    scroll-padding-top: 72px;
}

body {
    font-family: var(--sans);
    color: var(--ink);
    background-color: var(--paper);
    line-height: 1.7;
    font-size: 1.0625rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--serif);
    font-weight: 600;
    color: var(--ink);
    line-height: 1.2;
}

a {
    color: var(--navy);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--accent);
}

/* Accessibility ---------------------------------------------------------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 2000;
    background: var(--ink);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 0 0 6px 0;
    font-weight: 600;
}

.skip-link:focus {
    left: 0;
    color: #fff;
}

/* Ampersand flourish */
.amp {
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    color: var(--accent);
}

/* Navigation ----------------------------------------------------------- */

.site-nav {
    background-color: rgba(250, 248, 244, 0.94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--rule);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.site-nav .navbar-brand {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--ink);
}

.site-nav .nav-link {
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
}

.site-nav .nav-link:hover,
.site-nav .nav-link:focus {
    color: var(--accent);
}

.site-nav .nav-link.active {
    color: var(--ink);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--accent);
}

.site-nav .navbar-toggler {
    border-color: var(--rule);
}

.site-nav .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(27, 39, 51, 0.8)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.site-nav .nav-cta {
    border: 1px solid var(--rule);
    border-radius: 999px;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    margin-left: 0.5rem;
    color: var(--ink);
}

.site-nav .nav-cta:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Reading progress bar (scaleX driven by js/main.js) */
.progress-bar-reading {
    position: absolute;
    left: 0;
    bottom: -1px;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, var(--navy), var(--accent));
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 0.08s linear;
}

/* Hero ------------------------------------------------------------------ */

.hero {
    position: relative;
    overflow: hidden;
    padding: 7rem 0 5.5rem;
    text-align: center;
    background:
        radial-gradient(ellipse at 50% -20%, rgba(31, 78, 121, 0.08), transparent 60%),
        var(--paper);
    border-bottom: 1px solid var(--rule);
}

/* Decorative line-chart motif behind the hero copy */
.hero-motif {
    position: absolute;
    inset: 0;
    opacity: 0.16;
    pointer-events: none;
}

.hero-motif svg {
    width: 100%;
    height: 100%;
}

.motif-path {
    stroke-dasharray: 2400;
    stroke-dashoffset: 2400;
    animation: drawLine 3s ease-out forwards;
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

.hero .container {
    position: relative;
}

.hero-inner {
    max-width: 46rem;
    margin: 0 auto;
}

.hero h1 {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
}

.tagline {
    font-family: var(--serif);
    font-style: italic;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    color: var(--ink-soft);
    margin-bottom: 0;
}

.rule {
    width: 4rem;
    margin: 2rem auto;
    border: 0;
    border-top: 2px solid var(--accent);
    opacity: 1;
}

.hero-standfirst {
    font-size: 1.125rem;
    color: var(--ink-soft);
    margin-bottom: 0;
}

.hero-meta {
    margin-top: 2rem;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.hero-meta strong {
    color: var(--ink);
    font-weight: 700;
}

.hero-meta .dot {
    margin: 0 0.6rem;
    color: var(--accent);
}

.scroll-cue {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
}

.scroll-cue:hover {
    color: var(--accent);
}

.scroll-cue svg {
    animation: cueBob 2s ease-in-out infinite;
}

@keyframes cueBob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(4px); }
}

/* Intro / myth index --------------------------------------------------------- */

.intro-section {
    padding: 5.5rem 0 4.5rem;
}

.intro-head {
    font-size: clamp(1.6rem, 3.5vw, 2.35rem);
    max-width: 46rem;
    margin-bottom: 1.25rem;
}

.myth-index {
    list-style: none;
    counter-reset: none;
    padding-left: 0;
    margin: 2.5rem 0 2rem;
    border-top: 1px solid var(--rule);
    max-width: 46rem;
}

.myth-index li {
    border-bottom: 1px solid var(--rule);
}

.myth-index a {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    padding: 1.25rem 0.5rem;
    text-decoration: none;
    color: var(--ink);
    transition: background-color 0.2s ease;
}

.myth-index a:hover {
    background-color: rgba(31, 78, 121, 0.05);
}

.myth-index-no {
    font-family: var(--serif);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 2.25rem;
}

.myth-index-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.myth-index-claim {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.2rem;
    line-height: 1.35;
}

.myth-index-topic {
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.myth-index-arrow {
    color: var(--ink-soft);
    transition: transform 0.2s ease, color 0.2s ease;
}

.myth-index a:hover .myth-index-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

.how-to-read {
    max-width: 44rem;
    color: var(--ink-soft);
    font-size: 0.98rem;
    border-left: 3px solid var(--rule);
    padding-left: 1rem;
    margin-bottom: 0;
}

/* Kicker / section labels ------------------------------------------------ */

.kicker {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}

/* Sections ---------------------------------------------------------------- */

.myth-section {
    padding: 5.5rem 0;
}

.myth-section.alt {
    background-color: var(--paper-alt);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

.section-inner {
    max-width: 62rem;
    margin: 0 auto;
}

.myth-section h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 1.25rem;
}

.section-lead {
    font-size: 1.15rem;
    color: var(--ink-soft);
    max-width: 44rem;
    margin-bottom: 2.5rem;
}

.section-lead a {
    color: var(--navy);
}

/* Pull quotes: myth vs verdict --------------------------------------------- */

.myth-quote {
    font-family: var(--serif);
    font-size: clamp(1.75rem, 4.5vw, 2.75rem);
    font-weight: 600;
    font-style: italic;
    line-height: 1.25;
    color: var(--ink);
    border-left: 4px solid var(--accent);
    padding: 0.5rem 0 0.5rem 1.5rem;
    margin: 0 0 1.75rem;
    max-width: 46rem;
}

.verdict-quote {
    font-family: var(--serif);
    font-size: 1.35rem;
    line-height: 1.5;
    color: var(--ink);
    background-color: rgba(30, 110, 92, 0.06);
    border-left: 4px solid var(--verdict);
    border-radius: 0 6px 6px 0;
    padding: 1.5rem 1.75rem;
    margin: 3rem 0 0;
}

.verdict-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--verdict);
    margin-bottom: 0.6rem;
}

/* Visualization containers -------------------------------------------------- */

.viz-container {
    background-color: #fff;
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(27, 39, 51, 0.05), 0 8px 24px rgba(27, 39, 51, 0.05);
    padding: 1.75rem;
    margin-bottom: 1rem;
    min-height: 400px;
    overflow-x: auto;
}

/* Charts scale to their container instead of overflowing */
.viz-container svg {
    max-width: 100%;
    height: auto;
}

.viz-figure {
    margin: 0 0 1rem;
}

.viz-figure figcaption {
    font-size: 0.85rem;
    color: var(--ink-soft);
    padding: 0.6rem 0.25rem 0;
    border-top: 1px solid var(--rule);
    margin-top: 0.25rem;
}

.js-plotly-plot .modebar {
    display: none !important;
}

/* Insights ------------------------------------------------------------------- */

.insights-block {
    margin-top: 2.5rem;
}

.insights-block h3 {
    font-size: 1.15rem;
    text-transform: none;
    margin-bottom: 1rem;
}

.insights-list {
    list-style-type: none;
    padding-left: 0;
    max-width: 44rem;
}

.insights-list li {
    position: relative;
    padding-left: 1.6rem;
    margin-bottom: 0.75rem;
    color: var(--ink-soft);
}

.insights-list li::before {
    content: "\2192";
    color: var(--accent);
    position: absolute;
    left: 0;
    font-weight: 700;
}

/* Restyle Bootstrap components generated by the viz scripts ------------------- */

.card {
    border: 1px solid var(--rule);
    border-radius: 8px;
    background-color: #fff;
}

.card-title {
    font-family: var(--serif);
    font-weight: 600;
}

.alert-info {
    background-color: var(--paper-alt);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--navy);
    border-radius: 6px;
}

.btn-primary {
    background-color: var(--navy);
    border-color: var(--navy);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: #163a5c;
    border-color: #163a5c;
}

.btn-outline-primary {
    color: var(--navy);
    border-color: var(--navy);
}

.btn-outline-primary:hover {
    background-color: var(--navy);
    border-color: var(--navy);
}

.btn-group .btn {
    transition: all 0.2s;
}

.form-select:focus,
.form-range:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 0.2rem rgba(31, 78, 121, 0.15);
}

.form-range::-webkit-slider-thumb {
    background: var(--navy);
}

.form-range::-moz-range-thumb {
    background: var(--navy);
}

.table th {
    font-family: var(--sans);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.bg-light {
    background-color: var(--paper-alt) !important;
}

.text-primary {
    color: var(--navy) !important;
}

.spinner-border.text-primary {
    color: var(--navy) !important;
}

/* Year slider for word cloud ---------------------------------------------------- */

.year-slider-container {
    width: 100%;
    padding: 10px 20px;
    margin-top: 15px;
}

.year-slider {
    width: 100%;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 12px;
    color: var(--ink-soft);
}

/* Viz 2 sub-containers ------------------------------------------------------------ */

.viz2-chart-container {
    min-height: 500px;
    position: relative;
}

.ratio-chart-container {
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 10px;
    background-color: #fff;
}

.legend-container {
    padding: 10px 12px;
    background-color: var(--paper);
    border-radius: 6px;
    border: 1px solid var(--rule);
}

.legend-title {
    font-weight: 600;
    font-size: 14px;
}

.legend-item {
    font-size: 13px;
}

.color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 5px;
    border-radius: 2px;
}

/* SVG element transitions */
path.area {
    transition: opacity 0.3s;
}

.total-point {
    transition: r 0.2s;
}

.axis-label {
    font-size: 12px;
    fill: var(--ink-soft);
}

/* Tooltips ------------------------------------------------------------------------- */

.temp-tooltip {
    transition: opacity 0.2s;
}

.tooltip-inner {
    max-width: 300px;
    padding: 10px 15px;
    background-color: rgba(27, 39, 51, 0.92);
    font-size: 14px;
}

/* Conclusion CTAs -------------------------------------------------------------------- */

.cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2rem;
}

.btn-ghost {
    display: inline-block;
    padding: 0.65rem 1.4rem;
    border: 1.5px solid var(--ink);
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    background-color: var(--ink);
    color: var(--paper);
}

/* Footer ----------------------------------------------------------------------------- */

.site-footer {
    background-color: var(--ink);
    color: #cbd3da;
    padding: 3.5rem 0;
    margin-top: 0;
    font-size: 0.95rem;
}

.footer-brand {
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.75rem;
}

.footer-heading {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8fa0af;
    margin-bottom: 0.9rem;
}

.footer-note {
    color: #9fadba;
    margin-bottom: 0.75rem;
}

.site-footer a {
    color: #dfe6ec;
    text-decoration-color: rgba(223, 230, 236, 0.4);
}

.site-footer a:hover {
    color: #fff;
}

.footer-sources {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.footer-sources li {
    padding-left: 1.3rem;
    position: relative;
    margin-bottom: 0.6rem;
    color: #9fadba;
}

.footer-sources li::before {
    content: "\2192";
    color: var(--accent);
    position: absolute;
    left: 0;
}

.footer-fine {
    font-size: 0.82rem;
    color: #7a8b99;
    margin: 1.25rem 0 0;
}

/* Animations ------------------------------------------------------------------------ */

.fade-in {
    opacity: 0;
    animation: fadeIn ease 1s forwards;
}

@keyframes fadeIn {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

/* Scroll-reveal: elements only start hidden once JS confirms it can reveal them
   (body.reveal-ready is added by js/main.js), so content is never lost without JS. */
body.reveal-ready .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

body.reveal-ready .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    .fade-in {
        animation: none;
        opacity: 1;
    }
    body.reveal-ready .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .motif-path {
        animation: none;
        stroke-dashoffset: 0;
    }
    .scroll-cue svg {
        animation: none;
    }
}

/* Chart cohesion: tame the Bootstrap layouts injected by viz2 & viz3 ------------------- */
/* Those scripts build card-based layouts INSIDE .viz-container, and viz3 even nests a
   second .viz-container for its sub-charts. Flatten the nesting so charts don't read as
   boxes-within-boxes, and make injected D3 axes/tooltips match the Plotly theme. */

.viz-container .card {
    border: 1px solid var(--rule);
    border-radius: 10px;
    background-color: var(--paper);
    box-shadow: none;
    margin-bottom: 1.25rem;
}

.viz-container .card-body { padding: 1.25rem; }

.viz-container .card-title,
.viz-container h5 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.12rem;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.viz-container h6 { font-family: var(--serif); font-weight: 600; }

/* Nested plotly/d3 sub-charts sit flat on their card — strip the inner frame */
.viz-container .card .viz-container,
.viz-container .card .ratio-chart-container {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    min-height: 0;
    overflow: visible;
}

.conclusion-container {
    background-color: var(--paper-alt) !important;
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 1.5rem !important;
}

.conclusion-container h4 {
    font-family: var(--serif);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.alert-info h5 {
    font-family: var(--sans);
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.table-bordered, .table-bordered th, .table-bordered td { border-color: var(--rule); }
.table-light, .table-light > th, .table-light > td { background-color: var(--paper-alt) !important; }
.text-muted { color: #8a94a0 !important; }

/* Make injected D3 axes read like the Plotly theme */
.viz-container .tick line { stroke: var(--rule); }
.viz-container .domain { stroke: #c9c0b1; }
.viz-container .tick text { fill: var(--ink-soft); font-family: var(--sans); }

/* Dark, unified D3 tooltips (Plotly hover labels are themed in js/main.js) */
.tooltip,
.savings-tooltip,
.temp-tooltip {
    font-family: var(--sans) !important;
    font-size: 13px !important;
    background-color: rgba(27, 39, 51, 0.95) !important;
    color: #f6f2ea !important;
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 24px rgba(27, 39, 51, 0.28) !important;
}
.tooltip strong,
.savings-tooltip strong,
.temp-tooltip strong { color: #fff; }

/* Responsive adjustments --------------------------------------------------------------- */

@media (max-width: 768px) {
    .hero {
        padding: 4.5rem 0 3.5rem;
    }

    .myth-section {
        padding: 3.5rem 0;
    }

    .viz-container {
        padding: 1rem;
        min-height: 300px;
    }

    .myth-quote {
        padding-left: 1rem;
    }

    .verdict-quote {
        font-size: 1.15rem;
        padding: 1.15rem 1.25rem;
    }

    /* Let the viz2 view-selector buttons wrap instead of overflowing */
    .btn-group.w-100 {
        flex-wrap: wrap;
    }

    .btn-group.w-100 .btn {
        flex: 1 1 48%;
        border-radius: 4px !important;
        margin: 2px;
        font-size: 0.85rem;
    }
}
