/* ============================================
   css/senedd-polls.css - Senedd polls page
   Scoped under body.senedd-polls, prefix: sdp-
   Built on the design system (css/pc-tokens.css + css/pc-components.css):
   only the classes the page's JS builds, and the token-fed chart skin,
   live here. No raw hexes except the black/white text set on party fills.
   Sister sheet: css/holyrood-polls.css (hp-), which this mirrors.
   ============================================ */

/* ---- Page ground + style.css bleed ---- */
body.senedd-polls {
    background: var(--pc-surface);
    font-family: var(--pc-sans);
    color: var(--pc-text-body);
}
body.senedd-polls .pc-wrap h1,
body.senedd-polls .pc-wrap h2,
body.senedd-polls .pc-wrap h3 {
    letter-spacing: normal;
    text-align: left;
}
body.senedd-polls .pc-wrap table { margin: 0; box-shadow: none; border-radius: 0; background: none; }
body.senedd-polls .pc-wrap th,
body.senedd-polls .pc-wrap td { background: none; }

.sdp-masthead { margin-bottom: 20px; }
.sdp-masthead .pc-intro { margin-top: 14px; }
.sdp-masthead .pc-cta-row { flex-wrap: wrap; row-gap: 4px; }

/* ---- Hero ---- */
.sdp-hero { margin-top: 8px; }
.sdp-hero-label { margin-bottom: 10px; }
.sdp-hero .pc-hero-party { min-width: 72px; }
.sdp-hero-footnote { margin-top: 2px; }
@media (max-width: 480px) {
    /* 7 parties: 3 across keeps the strip to three rows on a phone */
    .sdp-hero .pc-hero-strip { grid-template-columns: repeat(3, 1fr); }
    .sdp-hero .pc-hero-party { padding: 8px 10px; }
}

/* ---- Latest poll card ---- */
.sdp-latest { margin-top: 28px; }
.sdp-latest .pc-poll-card-meta { flex-wrap: wrap; row-gap: 2px; }
.sdp-latest .pc-bar-name { width: 84px; }
.sdp-latest .pc-bar-chg { width: 46px; flex-basis: 46px; }

/* ---- Trend chart (token skin for the shared PollLineChart, which
        draws with gbp- class names) ---- */
.sdp-chart-controls .pc-seg { flex-wrap: nowrap; }
body.senedd-polls .gbp-chart-container {
    position: relative;
    width: 100%;
    height: 620px;
}
body.senedd-polls .gbp-chart-container svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}
body.senedd-polls .gbp-chart-container .axis text { font-family: var(--pc-sans); font-size: 11px; fill: var(--pc-text-meta); }
body.senedd-polls .gbp-chart-container .grid-line { stroke: var(--pc-border-grid); stroke-width: 0.5; }
body.senedd-polls .gbp-chart-container .crosshair { stroke: var(--pc-border); }
body.senedd-polls .gbp-chart-container .event-marker { stroke: var(--pc-text-meta); }
body.senedd-polls .gbp-chart-container .event-badge { fill: var(--pc-text); }
body.senedd-polls .gbp-chart-container .event-badge-num { fill: var(--pc-on-ink); }
body.senedd-polls .gbp-chart-container .chart-band { fill: var(--pc-text); }
body.senedd-polls .gbp-chart-container .chart-band-label,
body.senedd-polls .gbp-chart-container .marker-caption { fill: var(--pc-text-secondary); }
body.senedd-polls .gbp-chart-container .result-marker { stroke: var(--pc-surface); }
body.senedd-polls .gbp-event-legend { color: var(--pc-text-body); }
body.senedd-polls .gbp-event-legend-num { background: var(--pc-text); color: var(--pc-on-ink); }
body.senedd-polls .gbp-tooltip {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 3px;
    font-family: var(--pc-sans);
}
body.senedd-polls .gbp-tooltip-date { color: var(--pc-text-body); }
body.senedd-polls .gbp-tooltip-party { color: var(--pc-text-secondary); font-size: 11px; }
body.senedd-polls .gbp-tooltip-val { color: var(--pc-text); font-size: 11px; }
@media (max-width: 768px) {
    .sdp-chart-controls { flex-direction: column; align-items: stretch; }
    .sdp-chart-controls .pc-seg { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sdp-chart-controls .pc-seg .pc-btn { flex: 1 0 auto; padding: 9px 12px; }
    body.senedd-polls .gbp-chart-container { height: 520px; }
}
@media (max-width: 480px) {
    body.senedd-polls .gbp-chart-container { height: 460px; }
}

/* SEO summary prose (injected between SEO-SUMMARY markers) */
body.senedd-polls .seo-polling-summary {
    font-family: var(--pc-serif);
    font-size: 17px;
    line-height: 1.7;
    color: var(--pc-text-body);
    max-width: 680px;
    margin: 24px 0 0;
    padding: 0;
    background: none;
    border: none;
    text-align: left;
}
body.senedd-polls .seo-polling-summary strong { color: var(--pc-text); }

/* ---- Party swatch (tables) ---- */
.sdp-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--party-color, var(--pc-nc));
    flex: none;
}
.sdp-party {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--pc-text);
    white-space: nowrap;
}
.sdp-short { display: none; }

/* ---- Result vs polls since ---- */
.sdp-compare-table .sdp-chg { font-weight: 700; }
.sdp-compare-table .sdp-chg.is-pos { color: var(--pc-positive); }
.sdp-compare-table .sdp-chg.is-neg { color: var(--pc-negative); }
.sdp-compare-table .sdp-chg.is-nc { color: var(--pc-text-meta); }
.sdp-compare-table td.sdp-bar-cell { width: 34%; padding-left: 12px; }
.sdp-compare-table .pc-diverge > span.is-pos,
.sdp-compare-table .pc-diverge > span.is-neg { background: var(--party-color, var(--pc-nc)); opacity: 0.85; }

/* ---- 2026 result ---- */
.sdp-seatbar { margin-bottom: 20px; }
.sdp-seatbar .pc-seat-seg { color: #111111; } /* fixed: sits on a party fill in both themes */
.sdp-seatbar .pc-seat-seg.is-dark { color: #FFFFFF; }
.sdp-result-table td.sdp-total { font-weight: 700; color: var(--pc-text); }
.sdp-result-table tbody tr:last-child td { border-bottom: 2px solid var(--pc-text); }
.sdp-result-note { margin-top: 12px; }

/* ---- All polls table ---- */
.sdp-table-controls { margin-bottom: 8px; }
.sdp-polls-table { min-width: 560px; }
.sdp-polls-table thead th.pc-party-col { color: var(--pc-text-meta); }
.sdp-polls-table .sdp-col-poll {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--pc-surface);
    text-align: left;
    min-width: 128px;
    box-shadow: inset -1px 0 0 var(--pc-border-light);
}
.sdp-polls-table thead th.sdp-col-poll { z-index: 2; }
.sdp-polls-table tbody tr:hover .sdp-col-poll,
.sdp-polls-table tbody tr.is-expanded .sdp-col-poll { background: var(--pc-hover-bg); }
.sdp-poll-pollster { display: block; color: var(--pc-text); font-weight: 600; white-space: nowrap; }
.sdp-poll-date { display: block; font-size: 11px; color: var(--pc-text-meta); white-space: nowrap; }
.sdp-polls-table td.sdp-lead { font-weight: 700; color: var(--pc-text); }
.sdp-polls-table td.sdp-n { font-size: 12px; color: var(--pc-text-meta); }
.sdp-polls-table tbody tr.poll-row { cursor: pointer; }
.sdp-polls-table tbody tr.is-expanded { background: var(--pc-hover-bg); }
.sdp-polls-table tbody tr.is-expanded td { border-bottom-color: transparent; }
/* The election result sits in the table as a row of its own */
.sdp-polls-table tbody tr.sdp-result-row td {
    border-top: 2px solid var(--pc-text);
    border-bottom: 2px solid var(--pc-text);
    font-weight: 700;
    color: var(--pc-text);
    background: var(--pc-tint);
}
.sdp-polls-table tbody tr.sdp-result-row .sdp-col-poll { background: var(--pc-tint); }
.sdp-polls-table tbody tr.sdp-result-row:hover { background: var(--pc-tint); }
.sdp-detail-row td { padding: 0 8px 14px; text-align: left !important; }
.sdp-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px 24px;
    max-width: 560px;
    position: sticky;
    left: 8px;
}
.sdp-detail-meta {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 12px;
    color: var(--pc-text-secondary);
    margin-bottom: 6px;
}
.sdp-detail-meta strong { color: var(--pc-text); font-weight: 600; }
.sdp-detail-row-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 3px 0;
    border-bottom: 1px solid var(--pc-border-light);
}
.sdp-detail-row-item .sdp-detail-name { flex: 1; color: var(--pc-text-secondary); }
.sdp-detail-row-item .sdp-detail-val { font-weight: 700; color: var(--pc-text); }
.sdp-detail-row-item .sdp-detail-chg { width: 40px; text-align: right; font-size: 12px; }
.sdp-detail-chg.is-pos { color: var(--pc-positive); }
.sdp-detail-chg.is-neg { color: var(--pc-negative); }
.sdp-detail-chg.is-nc { color: var(--pc-text-meta); }
.sdp-more { margin-top: 12px; }

/* ---- Explore list ---- */
.sdp-explore { margin: 0; padding: 0; list-style: none; }
.sdp-explore li { padding: 8px 0; border-bottom: 1px solid var(--pc-border-light); font-size: 14px; }

/* ---- Phone ---- */
@media (max-width: 600px) {
    .sdp-long { display: none; }
    .sdp-short { display: inline; }
    .sdp-hide-narrow { display: none; }
    .sdp-result-table th,
    .sdp-result-table td { padding-left: 5px; padding-right: 5px; }
    .sdp-compare-table th,
    .sdp-compare-table td { padding: 9px 6px; }
    .sdp-compare-table td.sdp-bar-cell { width: 28%; padding-left: 6px; }
    .sdp-polls-table { font-size: 12px; min-width: 0; }
    .sdp-polls-table thead th,
    .sdp-polls-table tbody td { padding-left: 6px; padding-right: 6px; }
    .sdp-polls-table .sdp-col-poll { min-width: 112px; max-width: 128px; }
    .sdp-poll-pollster { white-space: normal; line-height: 1.25; }
    .sdp-detail { grid-template-columns: 1fr; max-width: calc(100vw - 48px); }
    .sdp-table-controls { flex-direction: column; align-items: stretch; }
    .sdp-table-controls .pc-select { width: 100%; }
}
@media (pointer: coarse) {
    .sdp-polls-table tbody tr.poll-row td { padding-top: 10px; padding-bottom: 10px; }
}
