/* AIVI data story (custom-data-story.hbs). Self-contained: nothing here touches
   other templates. Palette = AIVI design brief (50 Foot sample booklet):
   navy #1D1E48, teal #00D4C2, deep teal #006B8B, blue #3A71C1, slate #353746,
   text #404040, grays #646464 / #D1D3D4 / #E0E0E0, gradient #0A6C94 -> #00BCB5.
   Teal #00D4C2 is only used on navy (8.5:1) or as a non-text accent; on white
   the text accent is deep teal #006B8B (6.2:1). Type: Manrope (stand-in for Roobert). */

@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope/manrope-variable-latin.woff2") format("woff2");
}

.ds {
    --ds-navy: #1D1E48;
    --ds-teal: #00D4C2;
    --ds-deep: #006B8B;
    --ds-blue: #3A71C1;
    --ds-slate: #353746;
    --ds-text: #404040;
    --ds-muted: #646464;
    --ds-rule: #E0E0E0;
    --ds-rule-2: #D1D3D4;
    --ds-tint: rgba(29, 30, 72, 0.05);
    --ds-on-navy: rgba(255, 255, 255, 0.80);
    --ds-on-navy-2: rgba(255, 255, 255, 0.66);
    --ds-font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ds-radius: 18px;
    --ds-radius-s: 14px;
    --ds-shadow: 0 1px 2px rgba(29, 30, 72, 0.05), 0 8px 24px -12px rgba(29, 30, 72, 0.16);
    --ds-pad: 48px;
    --ds-max: 1180px;
    font-family: var(--ds-font);
    color: var(--ds-text);
    -webkit-font-smoothing: antialiased;
}

.data-story-template .site-content { padding-top: 0; padding-bottom: 0; }
.data-story-template .site-main { padding-bottom: 0; }

.ds-sr {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap; border: 0;
}
.ds [hidden] { display: none !important; }

/* ---------- Hero ---------- */
.ds-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(720px 340px at 8% -10%, rgba(0, 212, 194, 0.16), transparent 62%),
        radial-gradient(560px 300px at 100% 110%, rgba(58, 113, 193, 0.20), transparent 60%),
        var(--ds-navy);
    color: var(--ds-on-navy);
    color-scheme: dark;
}
.ds-hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 40px;
    align-items: center;
    max-width: var(--ds-max);
    margin: 0 auto;
    padding: 48px var(--ds-pad) 52px;
}
.ds-has-where .ds-hero-inner { grid-template-columns: minmax(0, 1fr) 380px; gap: 56px; }

.ds-kicker {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
    margin: 0 0 18px;
    color: var(--ds-teal);
    font-size: 12.5px; font-weight: 700; line-height: 1.4;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.ds-kicker-sep { color: var(--ds-on-navy-2); }
.ds-kicker-item { display: contents; }
.ds-kicker-item:first-child > .ds-kicker-sep { display: none; }
.ds-kicker-type {
    margin-left: 4px;
    padding: 3px 9px 2px;
    border: 1px solid rgba(0, 212, 194, 0.5);
    border-radius: 999px;
    letter-spacing: 0.1em;
}

.ds-title {
    margin: 0;
    max-width: 26ch;
    color: #fff;
    font-family: var(--ds-font);
    font-size: clamp(28px, 2.75vw, 40px);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.015em;
    text-wrap: balance;
}
.ds-dek { margin: 16px 0 0; max-width: 60ch; font-size: 18px; line-height: 1.55; color: var(--ds-on-navy); }

.ds-byline {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
    margin-top: 28px;
    font-size: 14.5px; line-height: 1.4;
}
.ds-avatar {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
    box-shadow: 0 0 0 2px var(--ds-navy), 0 0 0 3px rgba(0, 212, 194, 0.6);
}
.ds-avatar-blank { display: inline-block; background: linear-gradient(135deg, #00BCB5, #0A6C94); }
.ds-author { color: #fff; font-weight: 700; text-decoration: none; }
.ds-author:hover { text-decoration: underline; }
.ds-meta { display: inline-flex; gap: 8px; color: var(--ds-on-navy); }
.ds-grade-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px 4px;
    border-radius: 999px;
    background: rgba(0, 212, 194, 0.14);
    box-shadow: inset 0 0 0 1px rgba(0, 212, 194, 0.55);
    color: var(--ds-teal);
    font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Where this happened */
.ds-where {
    padding: 18px 20px 16px;
    border-radius: var(--ds-radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 24px 48px -24px rgba(0, 0, 0, 0.5);
}
.ds-where-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ds-where-title {
    margin: 0; color: var(--ds-on-navy);
    font-family: var(--ds-font); font-size: 11.5px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.ds-where-link {
    color: var(--ds-teal); font-size: 11.5px; font-weight: 800;
    letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none;
}
.ds-where-link:hover, .ds-where-link:focus-visible { text-decoration: underline; }
.ds-arrow { margin-left: 4px; }
.ds-where-map { margin: 8px -4px 4px; }
.ds-plate { display: block; width: 100%; height: auto; max-height: 290px; overflow: visible; }
.ds-plate-state {
    fill: rgba(0, 212, 194, 0.12);
    stroke: var(--ds-teal); stroke-width: 1px; vector-effect: non-scaling-stroke;
    stroke-linejoin: round;
}
.ds-plate text {
    font-family: var(--ds-font); font-size: 9.5px; font-weight: 700; fill: #fff;
    paint-order: stroke; stroke: var(--ds-navy); stroke-width: 3px; stroke-linejoin: round;
}
.ds-plate-dot { fill: var(--ds-teal); }
.ds-plate-halo { fill: rgba(0, 212, 194, 0.22); stroke: rgba(0, 212, 194, 0.6); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.ds-plate-dc rect { fill: var(--ds-navy); stroke: #fff; stroke-width: 1.4px; vector-effect: non-scaling-stroke; }
.ds-plate-dc text { font-weight: 600; fill: var(--ds-on-navy); }
.ds-where-legend {
    display: flex; flex-wrap: wrap; gap: 6px 16px;
    margin: 6px 0 0; padding: 0; list-style: none;
    font-size: 12px; color: var(--ds-on-navy);
}
.ds-where-legend li { display: inline-flex; align-items: center; gap: 7px; }
.ds-key { display: inline-block; width: 10px; height: 10px; flex: none; }
.ds-key-case { border-radius: 50%; background: var(--ds-teal); box-shadow: 0 0 0 3px rgba(0, 212, 194, 0.25); }
.ds-key-dc { border-radius: 2px; border: 1.5px solid #fff; }
.ds-where-note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--ds-on-navy-2); }

/* pins pop in once */
@media (prefers-reduced-motion: no-preference) {
    .ds-plate-pin { animation: ds-pop 0.5s cubic-bezier(.2, .8, .3, 1.3) both; animation-delay: calc(0.25s + var(--i, 0) * 0.12s); transform-box: fill-box; }
    .ds-plate-halo { animation: ds-halo 2.4s ease-out 1s 2; transform-box: fill-box; transform-origin: center; }
}
@keyframes ds-pop { from { opacity: 0; } to { opacity: 1; } }
@keyframes ds-halo { 0% { transform: scale(1); } 50% { transform: scale(1.6); opacity: .4; } 100% { transform: scale(1); } }

/* ---------- Page ---------- */
.ds-page { max-width: var(--ds-max); margin: 0 auto; padding: 40px var(--ds-pad) 8px; }
.ds-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; align-items: start; }
.ds-has-rail .ds-main { grid-template-columns: minmax(0, 1fr) 336px; }
.ds:not(.ds-has-rail) .ds-col { max-width: 760px; margin: 0 auto; }

/* Stat tiles */
.ds-stats-wrap { margin-bottom: 36px; }
.ds-stats {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
    margin: 0; padding: 0; list-style: none;
}
.ds-stat {
    position: relative;
    display: flex; flex-direction: column;
    margin: 0; padding: 18px 18px 16px;
    background: #fff;
    border-radius: var(--ds-radius-s);
    box-shadow: inset 0 0 0 1px var(--ds-rule), var(--ds-shadow);
}
.ds-stat::before {
    content: ""; position: absolute; left: 18px; top: 0; width: 28px; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--ds-teal);
}
.ds-stat p { margin: 0; }
.ds-stat-value {
    color: var(--ds-blue);
    font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ds-stat-label { margin-top: 10px !important; color: var(--ds-navy); font-size: 14px; font-weight: 700; line-height: 1.3; }
.ds-stat-detail { margin-top: 4px !important; color: var(--ds-text); font-size: 13px; line-height: 1.4; }
.ds-stat-source {
    margin-top: auto !important; padding-top: 12px;
    color: var(--ds-muted); font-size: 11.5px; line-height: 1.35;
}
.ds-stats-note { margin: 12px 0 0; color: var(--ds-muted); font-size: 12.5px; font-style: italic; line-height: 1.5; }

.ds-example {
    display: inline-block; margin-left: 8px; padding: 2px 7px 1px;
    border-radius: 4px; background: #FFF; color: #8A2B5E; box-shadow: inset 0 0 0 1px #B63E84;
    font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; vertical-align: middle;
}

/* Body */
.ds-body.gh-content { font-family: var(--ds-font); font-size: 18px; line-height: 1.7; color: var(--ds-text); max-width: 68ch; }
.ds-body.gh-content > * { margin-top: 0; margin-bottom: 0; }
.ds-body.gh-content > * + * { margin-top: 24px; }
.ds-body.gh-content > p:first-of-type::first-line { color: var(--ds-navy); font-weight: 600; }
.ds-body a { color: var(--ds-deep); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ds-body a:hover { color: var(--ds-navy); }
.ds-body .kg-html-card:has(.ds-data[data-ds-data]) { margin: 0; }
.ds-ready .ds-body > .ds-data:first-child + * ,
.ds-ready .ds-body > .kg-card:first-child + * { margin-top: 0; }
.ds-data { margin: 0; }
.ds-ready .ds-data { display: none; }
.ds-fallback { padding: 16px 20px; border-radius: var(--ds-radius-s); background: var(--ds-tint); font-size: 16px; }
.ds-fallback ul { margin: 8px 0; padding-left: 20px; }

/* Chart */
.ds-body .ds-chart {
    margin: 36px 0 !important;
    padding: 24px 28px 20px;
    background: #fff;
    border-radius: var(--ds-radius);
    box-shadow: inset 0 0 0 1px var(--ds-rule), var(--ds-shadow);
    max-width: none;
}
.ds-chart-title { margin: 0; color: var(--ds-navy); font-size: 16px; font-weight: 800; line-height: 1.3; text-align: left; }
.ds-bars-sub { margin: 4px 0 18px; color: var(--ds-muted); font-size: 13px; line-height: 1.4; }
.ds-bar-row {
    display: grid; grid-template-columns: 210px minmax(0, 1fr) 96px; gap: 18px; align-items: center;
    padding: 11px 0;
    border-top: 1px solid #EEEEEE;
}
.ds-bar-row:first-of-type { border-top: 0; }
.ds-bar-label { display: flex; flex-direction: column; line-height: 1.3; }
.ds-bar-name { color: var(--ds-navy); font-size: 14px; font-weight: 700; }
.ds-bar-place { color: var(--ds-muted); font-size: 12.5px; }
.ds-bar-track {
    position: relative; height: 14px; border-radius: 7px;
    background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), #E0E0E0 calc(25% - 1px) 25%), #F3F4F6;
}
.ds-bar-fill {
    position: absolute; top: 0; bottom: 0; width: var(--w);
    border-radius: 7px; background: var(--ds-deep);
    transform-origin: left center;
}
.ds-up .ds-bar-fill { background: var(--ds-blue); }
.ds-bar-lead {
    position: absolute; left: 0; top: 5px; height: 4px;
    background: repeating-linear-gradient(90deg, rgba(0, 107, 139, .45) 0 4px, transparent 4px 8px);
}
.ds-bar-value { color: var(--ds-navy); font-size: 15px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ds-bars-legend { display: flex; gap: 18px; margin-top: 14px; color: var(--ds-muted); font-size: 12.5px; }
.ds-bars-legend span { display: inline-flex; align-items: center; gap: 7px; }
.ds-key-down { border-radius: 3px; background: var(--ds-deep); }
.ds-key-up { border-radius: 3px; background: var(--ds-blue); }
.ds-chart-note { margin: 10px 0 0 !important; color: var(--ds-muted); font-size: 12.5px !important; font-style: italic; line-height: 1.5; }

/* the real table (no-JS, email, and screen readers once JS runs) */
.ds-chart-table { margin: 14px 0 0; font-size: 15px; }
.ds-chart-table th, .ds-chart-table td { padding: 8px 10px; border-bottom: 1px solid var(--ds-rule); text-align: left; vertical-align: top; }
.ds-chart-table thead th { color: var(--ds-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.ds-chart-table tbody th { color: var(--ds-navy); font-weight: 700; }
.ds-chart-table tbody th span { color: var(--ds-muted); font-weight: 400; }
.ds-chart-table td { font-weight: 800; color: var(--ds-navy); white-space: nowrap; text-align: right; }
.ds-chart:not(.ds-chart-ready) .ds-chart-table caption { position: static !important; width: auto; height: auto; clip: auto; clip-path: none; white-space: normal; margin: 0 0 6px; text-align: left; color: var(--ds-muted); font-size: 13px; }

@media (prefers-reduced-motion: no-preference) {
    .ds-chart-ready .ds-bar-fill { transform: scaleX(0); transition: transform 0.9s cubic-bezier(.2, .7, .2, 1); transition-delay: calc(var(--i, 0) * 0.14s); }
    .ds-chart-ready.ds-drawn .ds-bar-fill { transform: scaleX(1); }
}

/* ---------- Rail ---------- */
.ds-rail { display: flex; flex-direction: column; gap: 16px; }
.ds-box {
    padding: 20px 22px;
    background: #fff;
    border-radius: var(--ds-radius-s);
    box-shadow: inset 0 0 0 1px var(--ds-rule), var(--ds-shadow);
    font-size: 14.5px; line-height: 1.55; color: var(--ds-text);
}
.ds-box p { margin: 0; }
.ds-box p + p { margin-top: 8px; }
.ds-box-title {
    margin: 0 0 10px; color: var(--ds-deep);
    font-family: var(--ds-font); font-size: 12px; font-weight: 800; line-height: 1.3;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.ds-box-meta { color: var(--ds-muted); font-size: 12.5px; }

.ds-says {
    background:
        radial-gradient(260px 160px at 100% 0%, rgba(0, 212, 194, 0.16), transparent 70%),
        var(--ds-navy);
    box-shadow: 0 16px 40px -18px rgba(29, 30, 72, 0.6);
    color: var(--ds-on-navy);
    padding: 22px 24px 22px;
}
.ds-says .ds-box-title { color: var(--ds-teal); }
.ds-score { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 12px !important; }
.ds-score-n { color: #fff; font-size: 56px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.ds-score-max { color: var(--ds-on-navy-2); font-size: 20px; font-weight: 700; }
.ds-seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 16px; }
.ds-seg i { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); }
.ds-seg i.on { background: var(--ds-teal); }
.ds-says-text { color: var(--ds-on-navy); font-size: 14.5px; }
.ds-says-flag {
    display: inline-flex; align-items: center; gap: 8px;
    margin-top: 14px !important; padding-top: 12px; width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--ds-on-navy); font-size: 12.5px; font-weight: 700;
}
.ds-says-flag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--ds-teal); }

.ds-sources { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.ds-sources li { position: relative; padding-left: 26px; counter-increment: s; }
.ds-sources li + li { margin-top: 12px; }
.ds-sources li::before {
    content: counter(s); position: absolute; left: 0; top: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--ds-tint); color: var(--ds-navy);
    font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}
.ds-source-title { display: block; color: var(--ds-navy); font-weight: 700; line-height: 1.4; text-decoration: none; }
.ds-source-title:hover, .ds-source-title:focus-visible { color: var(--ds-deep); text-decoration: underline; }
.ds-source-meta { display: block; margin-top: 2px; color: var(--ds-muted); font-size: 12.5px; }

.ds-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ds-chip {
    display: inline-block; padding: 6px 12px 5px;
    border-radius: 999px; background: var(--ds-tint);
    color: var(--ds-navy); font-size: 13px; font-weight: 700; line-height: 1.3; text-decoration: none;
}
.ds-chip-link { background: var(--ds-navy); color: #fff; }
.ds-chip-link::after { content: " \203A"; color: var(--ds-teal); }
.ds-chip-link:hover, .ds-chip-link:focus-visible { background: var(--ds-deep); }
.ds-chip-muted { background: transparent; box-shadow: inset 0 0 0 1px var(--ds-rule-2); color: var(--ds-muted); font-weight: 600; }
.ds-chip-note { font-weight: 500; }
.ds-usecase-title { display: block; margin-bottom: 4px; color: var(--ds-navy); font-size: 15.5px; font-weight: 800; text-decoration: none; }
a.ds-usecase-title:hover, a.ds-usecase-title:focus-visible { color: var(--ds-deep); text-decoration: underline; }

/* ---------- Subscribe ---------- */
.ds-subscribe { max-width: var(--ds-max); margin: 0 auto; padding: 40px var(--ds-pad) 56px; }
.ds-subscribe-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 26px 32px;
    border-radius: 20px;
    background: linear-gradient(100deg, #0A6C94 0%, #006B8B 45%, #00BCB5 100%);
    box-shadow: 0 20px 44px -24px rgba(10, 108, 148, 0.7);
}
.ds-subscribe-text { margin: 0; color: #fff; font-size: 20px; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; }
.ds-subscribe-btn {
    flex: none; padding: 12px 24px; border-radius: 999px;
    background: #fff; color: var(--ds-navy);
    font-size: 15px; font-weight: 800; text-decoration: none;
    box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.4);
}
.ds-subscribe-btn:hover, .ds-subscribe-btn:focus-visible { background: var(--ds-navy); color: #fff; }

.ds a:focus-visible { outline: 2px solid var(--ds-teal); outline-offset: 2px; border-radius: 4px; }
.ds-body a:focus-visible { outline-color: var(--ds-deep); }

/* ---------- Responsive ---------- */
@media (max-width: 1199px) {
    .ds { --ds-pad: 36px; }
    .ds-has-where .ds-hero-inner { grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; }
    .ds-has-rail .ds-main { grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; }
    .ds-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
    .ds-has-where .ds-hero-inner, .ds-has-rail .ds-main { grid-template-columns: minmax(0, 1fr); }
    .ds-where { max-width: 520px; }
}
@media (max-width: 599px) {
    .ds { --ds-pad: 20px; }
    .ds-hero-inner { padding-top: 32px; padding-bottom: 32px; gap: 28px !important; }
    .ds-kicker { font-size: 11.5px; margin-bottom: 14px; }
    .ds-title { font-size: 26px; line-height: 1.18; }
    .ds-plate { max-height: 210px; }
    .ds-where { padding: 16px 16px 14px; }
    .ds-byline { margin-top: 20px; font-size: 14px; }
    .ds-page { padding-top: 24px; }
    .ds-stats { gap: 10px; }
    .ds-stat { padding: 16px 14px 14px; }
    .ds-stat::before { left: 14px; }
    .ds-stat-value { font-size: 25px; }
    .ds-stat-label { font-size: 13.5px; }
    .ds-body.gh-content { font-size: 17px; }
    .ds-body .ds-chart { padding: 20px 18px 16px; margin-left: 0 !important; margin-right: 0 !important; }
    .ds-bar-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
    .ds-bar-label { grid-column: 1; }
    .ds-bar-value { grid-column: 2; grid-row: 1; }
    .ds-bar-track { grid-column: 1 / -1; }
    .ds-subscribe { padding-top: 28px; padding-bottom: 36px; }
    .ds-subscribe-inner { flex-direction: column; align-items: flex-start; padding: 22px 22px; }
    .ds-subscribe-text { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .ds *, .ds *::before, .ds *::after { animation: none !important; transition: none !important; }
}

@media print {
    .ds-hero { background: #fff; color: #000; }
    .ds-title { color: #000; }
    .ds-subscribe { display: none; }
}

/* table fallback: undo Dawn's scrolling-table treatment and uppercase heads */
.ds-body .ds-chart .ds-chart-table { display: table; width: 100%; max-width: 100%; background: none; overflow: visible; border-collapse: collapse; }
.ds-body .ds-chart .ds-chart-table tbody th { text-transform: none; letter-spacing: 0; font-size: 14.5px; }
.ds-body .ds-chart .ds-chart-table thead th { font-weight: 700; }
