/* =============================================
   editorial-base.css — PollCheck Editorial Design System
   Shared tokens, typography, tables, and components.
   Each page imports this + its own scoped CSS file.

   Loading order:
     style.css          (nav, footer, legacy base)
     editorial-base.css (this file — tokens & components)
     page-specific.css  (scoped overrides with page prefix)
   ============================================= */

/* ---- 1. Design Tokens (CSS Custom Properties) ---- */
:root {
    /* Typography */
    --ed-font-serif: Georgia, "Times New Roman", serif;
    --ed-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --ed-font-sans-alt: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

    /* Text colors */
    --ed-color-primary: #1a1a1a;
    --ed-color-text: #111111;
    --ed-color-body: #333333;
    --ed-color-secondary: #555555;
    --ed-color-meta: #999999;
    --ed-color-muted: #AAAAAA;

    /* Surfaces & borders */
    --ed-color-surface: #FFFFFF;
    --ed-color-bg: #FAFAFA;
    --ed-color-border: #E0E0E0;
    --ed-color-border-light: #EEEEEE;
    --ed-color-border-grid: #F0F0F0;
    --ed-color-hover: #FAFAFA;

    /* Semantic colors */
    --ed-color-positive: #2e7d32;
    --ed-color-negative: #c62828;
    --ed-color-neutral: #CCCCCC;

    /* Party colors */
    --ed-party-con: #0087DC;
    --ed-party-lab: #E4003B;
    --ed-party-lab-alt: #d50000;
    --ed-party-ref: #12B6CF;
    --ed-party-ld: #FAA61A;
    --ed-party-ld-alt: #FDBB30;
    --ed-party-grn: #008066;
    --ed-party-grn-alt: #6AB023;
    --ed-party-snp: #FCD34D;
    --ed-party-snp-alt: #FFF95D;
    --ed-party-pc: #005B54;
    --ed-party-pc-alt: #3F8428;
    --ed-party-oth: #999999;

    /* Spacing */
    --ed-page-pad-top: 48px;
    --ed-page-pad-x: 24px;
    --ed-page-pad-bottom: 64px;
    --ed-section-gap: 32px;
}


/* ---- 2. Content Width Containers ---- */

.ed-wrap-960 {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--ed-page-pad-top) var(--ed-page-pad-x) var(--ed-page-pad-bottom);
}

.ed-wrap-760 {
    max-width: 760px;
    margin: 0 auto;
    padding: var(--ed-page-pad-top) var(--ed-page-pad-x) var(--ed-page-pad-bottom);
}

.ed-wrap-680 {
    max-width: 680px;
    margin: 0 auto;
    padding: var(--ed-page-pad-top) var(--ed-page-pad-x) var(--ed-page-pad-bottom);
}


/* ---- 3. Masthead ---- */

.ed-masthead {
    margin-bottom: var(--ed-section-gap);
    max-width: 700px;
}

.ed-kicker {
    font-family: var(--ed-font-sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ed-color-text);
    margin: 0 0 8px 0;
}

.ed-masthead-rule {
    border: none;
    border-top: 3px solid var(--ed-color-text);
    margin: 0 0 16px 0;
}

.ed-headline {
    font-family: var(--ed-font-serif);
    font-size: 32px;
    font-weight: 700;
    color: var(--ed-color-text);
    line-height: 1.15;
    margin: 0 0 6px 0;
}

.ed-subtitle {
    font-family: var(--ed-font-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--ed-color-secondary);
    margin: 0;
    line-height: 1.5;
}


/* ---- 4. Section Dividers & Labels ---- */

.ed-rule {
    border: none;
    border-top: 1px solid var(--ed-color-border);
    margin: 40px 0;
}

.ed-section-label {
    font-family: var(--ed-font-sans);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ed-color-meta);
    margin: 0 0 16px 0;
    padding: 0;
}

.ed-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 14px;
}

.ed-section-header .ed-section-label {
    margin-bottom: 0;
}

.ed-section-link {
    font-family: var(--ed-font-sans);
    font-size: 12px;
    color: var(--ed-color-meta);
    text-decoration: underline;
    text-decoration-color: #ddd;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.ed-section-link:hover {
    color: var(--ed-color-body);
    text-decoration-color: var(--ed-color-body);
}


/* ---- 5. Links ---- */

.ed-link {
    color: var(--ed-color-text);
    text-decoration: underline;
    text-decoration-color: #CCCCCC;
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s;
}

.ed-link:hover {
    text-decoration-color: var(--ed-color-text);
}


/* ---- 6. Buttons ---- */

.ed-btn {
    font-family: var(--ed-font-sans);
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #DDDDDD;
    background: var(--ed-color-surface);
    color: var(--ed-color-body);
    padding: 6px 12px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.1s;
    line-height: 1;
    white-space: nowrap;
}

.ed-btn:hover {
    border-color: #BBBBBB;
}

.ed-btn.is-active {
    background: var(--ed-color-text);
    color: var(--ed-color-surface);
    border-color: var(--ed-color-text);
}


/* ---- 7. Dropdown Select ---- */

.ed-select {
    font-family: var(--ed-font-sans);
    font-size: 13px;
    font-weight: 400;
    color: var(--ed-color-body);
    border: 1px solid #DDDDDD;
    background: var(--ed-color-surface);
    padding: 6px 28px 6px 10px;
    border-radius: 2px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 6px;
    line-height: 1.3;
}

.ed-select:focus {
    outline: 2px solid var(--ed-color-text);
    outline-offset: 2px;
}


/* ---- 8. Tables (NYT Style) ---- */

.ed-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ed-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--ed-font-sans);
    font-size: 14px;
}

.ed-table thead th {
    font-family: var(--ed-font-sans);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ed-color-meta);
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--ed-color-primary);
}

.ed-table thead th:not(:first-child) {
    text-align: right;
}

.ed-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ed-color-border-light);
    color: var(--ed-color-body);
    font-variant-numeric: tabular-nums;
}

.ed-table tbody td:not(:first-child) {
    text-align: right;
}

.ed-table tbody tr:last-child td {
    border-bottom: 2px solid var(--ed-color-primary);
}

.ed-table tbody tr:hover {
    background: var(--ed-color-hover);
}


/* ---- 9. Change Badges ---- */

.ed-change-up {
    color: var(--ed-color-positive);
    font-weight: 700;
}

.ed-change-down {
    color: var(--ed-color-negative);
    font-weight: 700;
}

.ed-change-flat {
    color: var(--ed-color-neutral);
}


/* ---- 10. Party Dot ---- */

.ed-party-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}


/* ---- 11. Chart Container ---- */

.ed-chart-container {
    position: relative;
    width: 100%;
    height: 400px;
}

.ed-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.ed-chart-container svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ed-chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}


/* ---- 12. Body Text (for editorial/long-form pages) ---- */

.ed-body-text {
    font-family: var(--ed-font-serif);
    font-size: 17px;
    line-height: 1.7;
    color: var(--ed-color-body);
}


/* ---- 13. Footer Attribution ---- */

.ed-footer-text {
    font-family: var(--ed-font-sans);
    font-size: 11px;
    color: var(--ed-color-muted);
    line-height: 1.6;
    margin: 0;
}


/* ---- 14. Note / Caption ---- */

.ed-note {
    font-family: var(--ed-font-serif);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ed-color-secondary);
    max-width: 700px;
    margin: 0;
}


/* ---- 15. Range Slider (interactive pages) ---- */

.ed-mini-range {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 3px;
    background: var(--ed-color-border);
    border-radius: 2px;
    outline: none;
    vertical-align: middle;
}

.ed-mini-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--party-color, #333);
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
    cursor: pointer;
}

.ed-mini-range::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--party-color, #333);
    border: 2px solid #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
    cursor: pointer;
}

.ed-mini-range::-webkit-slider-runnable-track {
    height: 3px;
    background: var(--ed-color-border);
    border-radius: 2px;
}

.ed-mini-range::-moz-range-track {
    height: 3px;
    background: var(--ed-color-border);
    border-radius: 2px;
}


/* ---- 16. Seat Bar ---- */

.ed-seat-bar {
    display: flex;
    height: 20px;
    background: #F5F5F5;
    overflow: hidden;
}

.ed-seat-bar .ed-segment {
    height: 100%;
    background: var(--party-color, #ccc);
    opacity: 0.75;
    transition: width 0.3s ease;
}


/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet: <= 768px */
@media (max-width: 768px) {
    :root {
        --ed-page-pad-top: 32px;
        --ed-page-pad-x: 16px;
        --ed-page-pad-bottom: 48px;
    }

    .ed-headline {
        font-size: 26px;
    }

    .ed-chart-container {
        height: 300px;
    }

    .ed-rule {
        margin: 32px 0;
    }

    .ed-chart-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .ed-table,
    .ed-table thead th,
    .ed-table tbody td {
        font-size: 13px;
    }
}

/* Mobile: <= 480px */
@media (max-width: 480px) {
    .ed-headline {
        font-size: 24px;
    }

    .ed-chart-container {
        height: 260px;
    }

    .ed-rule {
        margin: 24px 0;
    }
}

/* Touch targets */
@media (pointer: coarse) {
    .ed-btn {
        min-height: 44px;
        padding: 10px 14px;
    }

    .ed-select {
        min-height: 44px;
    }
}
