/* =============================================
   polls-politico.css - shared politico reskin layer
   for the secondary poll pages (scottish-polls,
   welsh-polls, holyrood-polls, senedd-polls,
   holyrood-seat-projections, the seat calculators).

   Modelled on the July 2026 gb-polls.css politico
   treatment. Self-contained: does NOT import or
   depend on gb-polls.css.

   How to use on a page:
     1. Link this file AFTER the page's existing CSS
        (style.css, editorial-base.css, polls-editorial.css,
        page-specific.css).
     2. Add class "pp-politico" to <body> (keep the
        page's existing body class).
     3. Add the pp- masthead classes alongside the
        page's own masthead classes.
     4. Add class "pp-range" to the time-range /
        quick-compare .btn-group that should get the
        accent highlight.
     5. Add the dark-mode pre-paint IIFE and (optional)
        the pp-theme-toggle button.

   Prefix: pp-. Scoped under body.pp-politico so it is
   inert on any page that does not opt in.
   ============================================= */

/* ---- Tokens (light) ---- */
body.pp-politico {
    --pp-bg: #FAFAFA;
    --pp-surface: #FFFFFF;
    --pp-text: #111111;
    --pp-text-body: #333333;
    --pp-text-secondary: #555555;
    --pp-text-meta: #999999;
    --pp-text-muted: #AAAAAA;
    --pp-border: #E0E0E0;
    --pp-border-light: #EEEEEE;
    --pp-hover-bg: #FAFAFA;
    --pp-positive: #2A9D2A;
    --pp-negative: #C0392B;
    /* Accent - used only to highlight the active time-range button (Politico-style) */
    --pp-accent: #C2410C;
    --pp-serif: Georgia, "Times New Roman", serif;
    --pp-sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

    /* Re-point the editorial-base tokens so every existing
       component on the page inherits the politico face without
       touching editorial-base.css or polls-editorial.css. */
    --ed-font-sans: var(--pp-sans);

    background: var(--pp-surface);
    font-family: var(--pp-sans);
    color: var(--pp-text-body);
}

/* ---- Tokens (dark) - toggled via body.dark-mode, shared
       localStorage key 'swingometer_theme' sitewide ---- */
body.pp-politico.dark-mode {
    --pp-bg: #0f172a;
    --pp-surface: #1e293b;
    --pp-text: #f8fafc;
    --pp-text-body: #e2e8f0;
    --pp-text-secondary: #cbd5e1;
    --pp-text-meta: #94a3b8;
    --pp-text-muted: #64748b;
    --pp-border: #334155;
    --pp-border-light: #3a4a60;
    --pp-hover-bg: #273548;
    --pp-positive: #4ade80;
    --pp-negative: #f87171;
    --pp-accent: #EA580C;

    /* Re-point editorial tokens so token-driven components go dark */
    --ed-color-primary: #f8fafc;
    --ed-color-text: #f8fafc;
    --ed-color-body: #e2e8f0;
    --ed-color-secondary: #cbd5e1;
    --ed-color-meta: #94a3b8;
    --ed-color-muted: #64748b;
    --ed-color-surface: #1e293b;
    --ed-color-bg: #0f172a;
    --ed-color-border: #334155;
    --ed-color-border-light: #3a4a60;
    --ed-color-border-grid: #2a3548;
    --ed-color-hover: #273548;
    --ed-color-positive: #4ade80;
    --ed-color-negative: #f87171;
    --ed-color-neutral: #475569;
}

/* ============================================
   MASTHEAD (kicker / 3px rule / serif headline /
   "Updated <date>" subtitle / serif intro)
   ============================================ */
.pp-masthead {
    margin-bottom: 32px;
    max-width: 700px;
}
.pp-kicker {
    font-family: var(--pp-sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pp-text);
    margin: 0 0 8px 0;
}
.pp-masthead-rule {
    border: none;
    border-top: 3px solid var(--pp-text);
    margin: 0 0 16px 0;
}
.pp-masthead-headline {
    font-family: var(--pp-serif);
    font-size: 32px;
    font-weight: 700;
    color: var(--pp-text);
    line-height: 1.15;
    margin: 0 0 6px 0;
}
.pp-masthead-subtitle {
    font-family: var(--pp-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--pp-text-secondary);
    margin: 0;
    line-height: 1.5;
}
.pp-intro {
    font-family: var(--pp-serif);
    font-size: 17px;
    line-height: 1.7;
    color: var(--pp-text-body);
    max-width: 680px;
    margin: 16px 0 0;
    text-align: left;
}

/* ============================================
   SEO SUMMARY - plain serif prose, no tinted box.
   !important defeats the inline styles that
   inject_seo_summary.py bakes into the block.
   ============================================ */
body.pp-politico .seo-polling-summary {
    font-family: var(--pp-serif) !important;
    font-size: 17px !important;
    line-height: 1.7 !important;
    color: var(--pp-text-body) !important;
    margin: 24px 0 16px 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    max-width: 680px;
    text-align: left;
}

/* ============================================
   TIME-RANGE / QUICK-COMPARE BUTTONS
   Only the group marked .pp-range gets the accent
   highlight; smoothing and other controls keep the
   dark invert (Politico-style).
   ============================================ */
body.pp-politico .pp-range .pill-btn {
    font-size: 13px;
    font-weight: 600;
    height: 32px;
    padding: 0 14px;
    border-radius: 3px;
}
body.pp-politico .pp-range .pill-btn.is-active {
    background: var(--pp-accent);
    color: #FFFFFF;
    border-color: var(--pp-accent);
}
body.pp-politico .pp-range .pill-btn.is-active:hover {
    border-color: var(--pp-accent);
}

/* ============================================
   LEGACY CARD CONTAINERS (style.css) - flatten the
   rounded white cards and navy section-header
   underline bars; let them follow the theme tokens.
   ============================================ */
body.pp-politico .chart-container {
    background: var(--pp-surface);
    border-color: var(--pp-border);
    border-radius: 0;
    box-shadow: none;
}
body.pp-politico .data-container {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}
body.pp-politico .data-header {
    background: transparent;
    border-bottom: none;
    padding: 12px 0 0;
}
body.pp-politico .data-header h2::after,
body.pp-politico .data-header h3::after {
    display: none;
}

/* ============================================
   POLL / SEAT CARDS - flatten the legacy pastel
   gradient cards (style.css) into flat surface
   cards with a 4px party accent on the left.
   ============================================ */
body.pp-politico .poll-card {
    background: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-radius: 0;
    padding: 12px 14px;
    text-align: left;
    box-shadow: none;
}
body.pp-politico .poll-card:hover {
    box-shadow: none;
    transform: none;
}
body.pp-politico .poll-card h4 {
    font-family: var(--pp-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pp-text-secondary);
    margin: 0 0 4px 0;
}
body.pp-politico .poll-card .poll-value {
    font-family: var(--pp-sans);
    font-size: 26px;
    font-weight: 700;
    color: var(--pp-text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
body.pp-politico .poll-card .poll-change {
    font-family: var(--pp-sans);
    font-size: 11px;
    color: var(--pp-text-meta);
    margin-top: 4px;
}
/* Party accents (left border) - overrides the pastel gradients */
body.pp-politico .poll-card.labour { border-left: 4px solid var(--ed-party-lab, #E4003B); }
body.pp-politico .poll-card.conservative { border-left: 4px solid var(--ed-party-con, #0087DC); }
body.pp-politico .poll-card.reform { border-left: 4px solid var(--ed-party-ref, #12B6CF); }
body.pp-politico .poll-card.libdem { border-left: 4px solid var(--ed-party-ld-alt, #FDBB30); }
body.pp-politico .poll-card.greens,
body.pp-politico .poll-card.green { border-left: 4px solid var(--ed-party-grn, #008066); }
body.pp-politico .poll-card.snp { border-left: 4px solid var(--ed-party-snp, #FCD34D); }
body.pp-politico .poll-card.pc { border-left: 4px solid var(--ed-party-pc-alt, #3F8428); }
body.pp-politico .poll-card.alba { border-left: 4px solid #00AEEF; }
body.pp-politico .poll-card.others { border-left: 4px solid var(--ed-party-oth, #999999); }

/* Recent-poll cards - square the legacy rounded corners */
body.pp-politico .recent-poll-card {
    border-radius: 0;
    box-shadow: none;
}

/* Mobile poll/seat cards - same flattening (style.css gives
   these rounded corners, shadows, centred text and pastel
   party gradients inside its mobile media query) */
body.pp-politico .latest-poll-card-mobile {
    background: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-left-width: 3px;
    border-radius: 0;
    box-shadow: none;
    align-items: flex-start;
    text-align: left;
}
body.pp-politico .latest-poll-card-mobile:hover {
    box-shadow: none;
    transform: none;
}
body.pp-politico .latest-poll-card-mobile h4 {
    font-family: var(--pp-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pp-text-secondary);
}
body.pp-politico .latest-poll-card-mobile .poll-value {
    color: var(--pp-text);
    font-variant-numeric: tabular-nums;
}
body.pp-politico .latest-poll-card-mobile .poll-change {
    color: var(--pp-text-meta);
}
body.pp-politico .latest-poll-card-mobile.labour { border-left-color: var(--ed-party-lab, #E4003B); }
body.pp-politico .latest-poll-card-mobile.conservative { border-left-color: var(--ed-party-con, #0087DC); }
body.pp-politico .latest-poll-card-mobile.reform { border-left-color: var(--ed-party-ref, #12B6CF); }
body.pp-politico .latest-poll-card-mobile.libdem { border-left-color: var(--ed-party-ld-alt, #FDBB30); }
body.pp-politico .latest-poll-card-mobile.greens,
body.pp-politico .latest-poll-card-mobile.green { border-left-color: var(--ed-party-grn, #008066); }
body.pp-politico .latest-poll-card-mobile.snp { border-left-color: var(--ed-party-snp, #FCD34D); }
body.pp-politico .latest-poll-card-mobile.pc { border-left-color: var(--ed-party-pc-alt, #3F8428); }
body.pp-politico .latest-poll-card-mobile.alba { border-left-color: #00AEEF; }
body.pp-politico .latest-poll-card-mobile.others { border-left-color: var(--ed-party-oth, #999999); }

/* ============================================
   TREND SNAPSHOT LABEL (replaces the inline
   color:#111 so it adapts in dark mode)
   ============================================ */
.pp-snapshot-label {
    font-family: var(--pp-sans);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pp-text);
}

/* ============================================
   THEME TOGGLE - top-right of the page content
   (absolute within <main>, which is positioned)
   ============================================ */
body.pp-politico main {
    position: relative;
}
.pp-theme-toggle {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    background: var(--pp-surface);
    color: var(--pp-text-secondary);
    border: 1px solid var(--pp-border);
    border-radius: 0;
    cursor: pointer;
    padding: 0;
    transition: color 120ms, border-color 120ms, background 120ms;
}
.pp-theme-toggle:hover {
    color: var(--pp-text);
    border-color: var(--pp-text);
}
.pp-theme-toggle:focus-visible {
    outline: 2px solid var(--pp-text);
    outline-offset: 2px;
}
.pp-theme-icon { display: none; }
body.pp-politico:not(.dark-mode) .pp-theme-icon-moon { display: block; }
body.pp-politico.dark-mode .pp-theme-icon-sun { display: block; }

/* ============================================
   DARK-MODE FIXES for components with hardcoded
   light values in polls-editorial.css / style.css
   ============================================ */

/* Buttons and inputs carry hardcoded #DDDDDD borders */
body.pp-politico.dark-mode .pill-btn,
body.pp-politico.dark-mode .icon-btn,
body.pp-politico.dark-mode .btn,
body.pp-politico.dark-mode .btn-secondary,
body.pp-politico.dark-mode .date-input,
body.pp-politico.dark-mode .compare-inline .date-input,
body.pp-politico.dark-mode .mobile-smooth-group {
    border-color: #334155;
}
body.pp-politico.dark-mode .mobile-smooth-group .pill-btn {
    border-right-color: #334155;
}
body.pp-politico.dark-mode .pill-btn:hover,
body.pp-politico.dark-mode .icon-btn:hover,
body.pp-politico.dark-mode .btn:hover,
body.pp-politico.dark-mode .btn-secondary:hover {
    border-color: #64748b;
}
body.pp-politico.dark-mode .date-input {
    background: var(--pp-surface);
    color: var(--pp-text-body);
}

/* Charts stay on white cards in dark mode - the canvases
   draw their axis and value labels in fixed dark colours */
body.pp-politico.dark-mode .chart-shell {
    background: #FFFFFF;
}
body.pp-politico.dark-mode .tab-content .chart-container {
    background: #FFFFFF;
}
body.pp-politico.dark-mode .tab-content .chart-container canvas {
    background: #FFFFFF;
}
body.pp-politico.dark-mode .tab-content .chart-container h3 {
    color: #111111;
}

/* Recent-poll summary pills keep their translucent party tints
   (style.css), which sit dark over a dark card - flip the text light */
body.pp-politico.dark-mode .recent-poll-pill {
    color: var(--pp-text-body);
}
body.pp-politico.dark-mode .recent-poll-pill.neutral {
    background: #273548;
    color: var(--pp-text-meta);
}

/* Compare/event overlays float over the white chart card,
   so keep their text dark regardless of theme */
body.pp-politico.dark-mode .compare-overlay {
    background: rgba(255, 255, 255, 0.96);
    border-color: #CBD5E1;
}
body.pp-politico.dark-mode .compare-overlay,
body.pp-politico.dark-mode .compare-overlay-body {
    color: #333333;
}
body.pp-politico.dark-mode .compare-overlay-head strong {
    color: #111111;
}

/* Link underlines */
body.pp-politico.dark-mode main a {
    text-decoration-color: #475569;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .pp-masthead-headline { font-size: 26px; }
}
@media (max-width: 600px) {
    .pp-theme-toggle { width: 28px; height: 28px; }
}
@media (max-width: 480px) {
    .pp-masthead-headline { font-size: 24px; }
}
