/* ============================================
   nation-seat-calc.css - Scottish / Welsh seat calculators
   --------------------------------------------
   Page-specific layer for scottish-seat-calculator.html and
   welsh-seat-calculator.html. Everything structural comes from
   css/pc-components.css; this file only adds what those two pages need
   and nothing else on the site has yet. Tokens only, never raw hexes.

   Graduation rule: if a second page needs one of these, move it into
   pc-components.css and add a specimen to /design-system.html.
   ============================================ */

/* Page ground: cream in light mode, same as the swingometer and
   path-to-no10. Dark mode inherits the canonical slate ramp. */
.nsc-body {
    background: var(--pc-bg);
    color: var(--pc-text);
    margin: 0;
}

/* Wider than the 1080 editorial measure: this is a three-pane tool
   (controls, map, seat card), the same shape as the demographic
   swingometer, which uses 1400 for the same reason. */
.nsc-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 44px 32px 72px;
}
/* The masthead and prose stay at the editorial measure inside it. */
.nsc-wrap > .pc-masthead,
.nsc-wrap > .pc-standfirst,
.nsc-wrap > .nsc-method { max-width: 1080px; }

/* ---- Masthead meta ---- */
.nsc-masthead-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
/* pc-theme-toggle is absolutely positioned for a page corner; here it
   sits in the masthead action row, so put it back in normal flow. */
.nsc-theme-toggle {
    position: static;
    top: auto;
    right: auto;
}

/* Result strip runs full width above the workspace: the seat split is
   the answer, so it should not sit below seven sliders on a phone. */
.nsc-result-strip {
    margin: 30px 0 34px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--pc-border);
}

/* ---- Two-column workspace: controls left, seat table right ---- */
.nsc-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 32px;
    align-items: start;
}
.nsc-seats { min-width: 0; margin-top: 44px; }
.nsc-seats .pc-section-title,
.nsc-mapsec .pc-section-title { margin-bottom: 14px; }
.nsc-mapsec { min-width: 0; }

/* ---- Map ---- */
.nsc-map-search {
    position: relative;
    margin-bottom: 12px;
    max-width: 320px;
}
.nsc-map-search .pc-input { width: 100%; }
.nsc-map-search .sp-search-menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 260px;
    overflow-y: auto;
}
/* Card to the right of the map on desktop, at the swingometer's fixed
   320px so the map does not resize as the card switches between its hint
   and a full seat. Stacks under the map when there is no room. */
.nsc-map-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}
/* Capped so Scotland, which is about 1.5x as tall as it is wide, does not
   run to a thousand pixels when the column is generous. */
.nsc-map { min-width: 0; max-width: 560px; }
.nsc-map svg { display: block; width: 100%; height: auto; }
/* Semi-transparent ink, not a theme surface colour. A white stroke scores
   1.2 contrast against SNP yellow, so with the SNP taking 34-47 of the 57
   Scottish seats the map read as one block with no borders. Black at 40%
   sits at roughly 2.1-2.9 against every party fill and works unchanged in
   dark mode, because it darkens the fill rather than matching the page. */
.nsc-map .sp-map-const {
    stroke: rgba(0, 0, 0, 0.4);
    stroke-width: 0.6;
    cursor: pointer;
    transition: opacity 120ms;
}
.nsc-map .sp-map-const:hover { opacity: 0.75; }
.nsc-map .sp-map-const.is-selected {
    stroke: var(--pc-text);
    stroke-width: 2;
}

.nsc-map-card {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    padding: 14px 16px 18px;
    max-height: 780px;
    overflow-y: auto;
}
.sp-map-card-hint {
    font-family: var(--pc-sans);
    font-size: 13px;
    color: var(--pc-text-meta);
    margin: 0;
    padding: 14px 2px;
}

.nsc-panel {
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
    padding: 18px 20px;
}

.nsc-panel + .nsc-panel { margin-top: 20px; }

.nsc-panel-head {
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pc-text-meta);
    margin: 0 0 12px 0;
}

/* Controls column sticks while the results table scrolls past it. */
@media (min-width: 981px) {
    .nsc-controls { position: sticky; top: 16px; }
}

/* ---- Poll preset pills ---- */
.nsc-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.nsc-pills .pc-pill { flex: 0 1 auto; }

/* ---- Slider rows: the number box beside each slider ---- */
.nsc-num {
    width: 62px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    padding: 4px 6px;
}
/* Strip the spinners - the slider is the coarse control, this is the
   fine one, and the arrows crowd a 62px box. */
.nsc-num::-webkit-outer-spin-button,
.nsc-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.nsc-num { -moz-appearance: textfield; appearance: textfield; }

.nsc-pct {
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--pc-text-meta);
}

/* ---- Entered-total readout ---- */
.nsc-sum {
    display: block;
    margin-top: 12px;
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}
.nsc-sum.is-neg { color: var(--pc-negative); }

/* ---- Result header ---- */
.nsc-result-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.nsc-verdict {
    font-family: var(--pc-serif);
    font-size: 20px;
    font-weight: 700;
    color: var(--pc-text);
    margin: 0;
}
.nsc-verdict-note {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}
.nsc-basis {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
    margin: 14px 0 0 0;
}

/* Seat bar with no majority marker: within one nation there is no
   threshold to cross, so the bar is a pure share-of-seats read. */
.nsc-seatbar {
    height: 40px;
    display: flex;
    overflow: hidden;
    background: var(--pc-border-light);
    border-radius: 2px;
}
.nsc-seatbar .pc-seat-seg {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    /* Label colour is set inline per segment, picked by contrast against
       that party's fill (see labelColour in js/nation-seat-calc.js). Not a
       theme token: the fills are the same hexes in light and dark, so
       --pc-on-ink would flip and break contrast in one of them. */
    min-width: 0;
    overflow: hidden;
    background: var(--party-color, var(--pc-nc));
    transition: width 0.6s cubic-bezier(.4, 0, .2, 1);
}
@media (prefers-reduced-motion: reduce) {
    .nsc-seatbar .pc-seat-seg { transition: none; }
}


.nsc-totals { margin-top: 18px; }

/* ---- Constituency table ---- */
.nsc-table-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}
.nsc-table-controls .pc-input { min-width: 200px; flex: 1 1 200px; }

#nsc-table th[data-sort] { cursor: pointer; user-select: none; }
#nsc-table th[data-sort]:hover { background: var(--pc-hover-bg); }
#nsc-table th[data-sort].is-active { color: var(--pc-text); }
#nsc-table th[data-sort][data-dir="asc"]::after { content: " \2191"; }
#nsc-table th[data-sort][data-dir="desc"]::after { content: " \2193"; }

#nsc-table td .pc-swatch { margin-right: 6px; }
#nsc-table td:nth-child(2) { text-align: left; }
#nsc-table td:last-child { text-align: left; }
#nsc-table th:nth-child(2),
#nsc-table th:last-child { text-align: left; }

.nsc-empty {
    text-align: center !important;
    color: var(--pc-text-meta);
    font-style: italic;
    padding: 20px 0;
}

/* ---- Loading / method ---- */
.nsc-loading {
    font-family: var(--pc-sans);
    font-size: 14px;
    color: var(--pc-text-meta);
    padding: 40px 0;
    text-align: center;
}

.nsc-method p {
    font-family: var(--pc-serif);
    font-size: 15px;
    line-height: 1.65;
    color: var(--pc-text-secondary);
    max-width: 660px;
}
.nsc-method p + p { margin-top: 12px; }

/* ---- Touch ----
   The design system sizes its sliders up under max-width: 768px, which
   misses touch devices that are wider than that: an iPad Pro, or a phone
   held in landscape, got the 6px desktop track and a 14px thumb. Key off
   the pointer instead, so anything driven by a finger gets a target it can
   actually grab. Scoped to this page rather than changed in the shared
   component, which other pages rely on as-is. */
@media (pointer: coarse) {
    .nsc-body .pc-slider { height: 18px; }
    .nsc-body .pc-slider::-webkit-slider-thumb { width: 30px; height: 30px; }
    .nsc-body .pc-slider::-moz-range-thumb { width: 30px; height: 30px; }
    .nsc-body .nsc-num { height: 40px; width: 70px; font-size: 15px; }
    .nsc-body .pc-theme-toggle { width: 40px; height: 38px; }
    .nsc-body .pc-input,
    .nsc-body .pc-select { min-height: 40px; }
    /* Bigger hit area on map seats without changing how they look. */
    .nsc-body .nsc-map .sp-map-const { stroke-width: 0.9; }
}

/* ---- Responsive ---- */
/* Below this the card stacks under the map. Both keep a cap: given a full
   column the map would otherwise run past 1200px tall on Scotland. */
/* Below this the card stacks under the map. Both keep a cap: given a full
   column the map would otherwise run past 1200px tall on Scotland.
   justify-self, not margin:auto - auto margins make a grid item shrink to
   its content instead of filling, which collapsed the map to 300px. */
@media (max-width: 1180px) {
    .nsc-map-grid { grid-template-columns: 1fr; }
    .nsc-map { width: 100%; justify-self: center; }
    .nsc-map-card {
        max-height: none;
        max-width: 560px;
        width: 100%;
        justify-self: center;
        margin-top: 22px;
    }
}
@media (max-width: 980px) {
    .nsc-grid { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 600px) {
    .nsc-wrap { padding: 28px 16px 56px; }
    .pc-masthead { grid-template-columns: 1fr; grid-template-areas: "kicker" "headline" "meta"; }
    .pc-masthead-meta { align-items: flex-start; margin-top: 12px; }
    .nsc-table-controls .pc-input { min-width: 0; }
}
