/* =========================================================
   Scotland Votes 2026 — Stylesheet
   ========================================================= */

/* --- Reset & Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --colour-bg:        #f8f9fa;
  --colour-surface:   #ffffff;
  --colour-border:    #dee2e6;
  --colour-text:      #212529;
  --colour-muted:     #6c757d;
  --colour-accent:    #005eb8;

  --status-committed: #d4edda;
  --status-committed-text: #155724;
  --status-opposed:   #f8d7da;
  --status-opposed-text: #721c24;
  --status-partial:   #fff3cd;
  --status-partial-text: #856404;
  --status-tbc:       #e9ecef;
  --status-tbc-text:  #495057;

  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --site-header-height: 72px; /* fallback — overwritten by JS on load/resize */
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--colour-bg);
  color: var(--colour-text);
  line-height: 1.6;
}

a { color: var(--colour-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout ---------------------------------------------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* --- Header ---------------------------------------------- */
.site-header {
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.saltire { font-size: 2rem; line-height: 1; }

.site-title {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
}
.site-title:hover { text-decoration: none; color: #c9d4ff; }

.site-subtitle {
  font-size: .8rem;
  color: #adb5bd;
  margin-top: .1rem;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}
.site-nav a {
  color: #c9d4ff;
  font-size: .9rem;
  font-weight: 500;
}
.site-nav a:hover { color: #fff; text-decoration: none; }

/* --- Hero ------------------------------------------------- */
.hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  color: #fff;
  padding: 3rem 0 2.5rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.2;
  max-width: 700px;
  margin: 0 auto .75rem;
}

.hero p {
  font-size: 1.05rem;
  color: #adb5bd;
  max-width: 560px;
  margin: 0 auto 1.5rem;
}

.election-countdown {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 2rem;
  padding: .4rem 1rem;
  font-size: .85rem;
  color: #e9ecef;
}

/* --- Section --------------------------------------------- */
.section {
  padding: 3rem 0;
}

.section + .section {
  border-top: 1px solid var(--colour-border);
}

.section-header {
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.section-header p {
  color: var(--colour-muted);
  margin-top: .35rem;
  font-size: .95rem;
}

/* --- Card ------------------------------------------------- */
.card {
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: clip; /* clip = same visual as hidden but does NOT create a scroll container,
                     which would silently break position:sticky on child elements */
}

/* --- Manifesto Tracker Table ----------------------------- */
.manifesto-table-wrap {
  overflow-x: auto;
}

.manifesto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.manifesto-table th {
  background: #f1f3f5;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--colour-muted);
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--colour-border);
  white-space: nowrap;
}

.manifesto-table td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--colour-border);
  vertical-align: middle;
}

.manifesto-table tr:last-child td { border-bottom: none; }
.manifesto-table tr:hover td { background: #f8f9fa; }

.party-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.party-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.party-name-full { font-weight: 600; }
.party-name-short { font-size: .8rem; color: var(--colour-muted); }

.status-pill {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 2rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.status-pill.released {
  background: var(--status-committed);
  color: var(--status-committed-text);
}

.status-pill.pending {
  background: var(--status-tbc);
  color: var(--status-tbc-text);
}

.manifesto-link {
  font-size: .85rem;
}

/* --- Party header pills in comparison table -------------- */
.party-header-cell {
  padding: .6rem .75rem !important;
  text-align: center;
  white-space: nowrap;
}

.party-header-pill {
  display: inline-block;
  padding: .3rem .75rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}

/* --- Policy Comparison Table ----------------------------- */
.filter-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: center;
}

.filter-bar label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--colour-muted);
  white-space: nowrap;
}

.filter-btn {
  padding: .35rem .85rem;
  border-radius: 2rem;
  border: 1px solid var(--colour-border);
  background: var(--colour-surface);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  color: var(--colour-text);
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--colour-accent);
  border-color: var(--colour-accent);
  color: #fff;
}

.policy-table-wrap {
  overflow-x: auto;
}

.policy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 800px;
}

.policy-table th {
  background: #f1f3f5;
  padding: .75rem .75rem;
  text-align: left;
  border-bottom: 2px solid var(--colour-border);
  border-right: 1px solid var(--colour-border);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--colour-muted);
  white-space: nowrap;
}

.policy-table th:last-child { border-right: none; }

.policy-table td {
  padding: .8rem .75rem;
  border-bottom: 1px solid var(--colour-border);
  border-right: 1px solid var(--colour-border);
  vertical-align: top;
}

.policy-table td:last-child { border-right: none; }

.policy-table tr:last-child td { border-bottom: none; }

.policy-area-cell {
  min-width: 160px;
  vertical-align: top;
}

.policy-area-name {
  font-weight: 600;
  white-space: nowrap;
}

.policy-area-icon {
  margin-right: .35rem;
}

.policy-share {
  display: flex;
  gap: .3rem;
  margin-top: .45rem;
}

.policy-share-link {
  font-size: .68rem;
  font-weight: 600;
  color: var(--colour-muted);
  text-decoration: none;
  padding: .1rem .3rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  line-height: 1.4;
  transition: color .15s, border-color .15s;
}

.policy-share-link:hover {
  color: var(--colour-text);
}

.policy-cell {
  min-width: 140px;
}

.policy-status {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 3px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .3rem;
}

.policy-status.committed {
  background: var(--status-committed);
  color: var(--status-committed-text);
}
.policy-status.opposed {
  background: var(--status-opposed);
  color: var(--status-opposed-text);
}
.policy-status.partial {
  background: var(--status-partial);
  color: var(--status-partial-text);
}
.policy-status.tbc {
  background: var(--status-tbc);
  color: var(--status-tbc-text);
}

.policy-summary {
  font-size: .82rem;
  color: var(--colour-text);
  line-height: 1.45;
  margin-top: .2rem;
}

/* --- Legend ---------------------------------------------- */
.legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: .82rem;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* --- No manifesto notice --------------------------------- */
.tbc-notice {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .85rem;
  color: #5d4037;
  margin-bottom: 1.25rem;
}

.tbc-notice strong { color: #3e2723; }

/* --- Footer ---------------------------------------------- */
.site-footer {
  background: #1a1a2e;
  color: #adb5bd;
  padding: 2rem 0;
  margin-top: 3rem;
  font-size: .85rem;
  text-align: center;
  line-height: 1.7;
}

.footer-links {
  margin-top: .75rem;
  display: flex;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

.footer-links a {
  color: #adb5bd;
  font-size: .82rem;
}

.footer-links a:hover { color: #fff; }

.footer-sep { color: #495057; }

.footer-date {
  margin-top: .75rem;
  color: #6c757d;
  font-size: .78rem;
}

.nav-github {
  display: flex;
  align-items: center;
  font-size: .82rem;
}

/* --- Distinct colours toggle -------------------------------- */
.colour-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  user-select: none;
  font-size: .85rem;
  font-weight: 500;
  color: var(--colour-text);
}

/* In the header nav the toggle sits on a dark background */
.nav-colour-toggle {
  color: #c9d4ff;
  font-size: .9rem;
}

.colour-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.colour-toggle-track {
  width: 40px;
  height: 22px;
  background: #adb5bd;
  border-radius: 11px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}

.colour-toggle-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.colour-toggle input:checked + .colour-toggle-track {
  background: var(--colour-accent);
}

.colour-toggle input:checked + .colour-toggle-track::after {
  transform: translateX(18px);
}

.nav-colour-toggle .colour-toggle-track {
  background: rgba(255,255,255,.25);
}

.nav-colour-toggle input:checked + .colour-toggle-track {
  background: #4f8ef7;
}

/* --- Party context bar (shown when table header scrolls out of view) --- */
.party-sticky-bar {
  position: fixed;
  top: var(--site-header-height);
  left: 0;
  right: 0;
  z-index: 90;
  background: #16213e;
  border-bottom: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 3px 10px rgba(0,0,0,.25);
  transform: translateY(-110%);
  transition: transform .2s ease;
  pointer-events: none;
}

.party-sticky-bar.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}

.party-sticky-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.party-sticky-bar-label {
  font-size: .72rem;
  color: #adb5bd;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-right: .25rem;
  white-space: nowrap;
}

/* --- IFS Analysis ---------------------------------------- */
.ifs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.ifs-card {
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ifs-card--pending {
  opacity: .75;
}

.ifs-card-header {
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.ifs-party-name {
  font-weight: 700;
  font-size: .95rem;
}

.ifs-assessed-badge,
.ifs-pending-badge {
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 2rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.ifs-assessed-badge {
  background: rgba(255,255,255,.25);
}

.ifs-pending-badge {
  background: rgba(0,0,0,.15);
}

.ifs-card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.ifs-verdict {
  font-size: .9rem;
  line-height: 1.55;
  color: var(--colour-text);
  font-style: italic;
}

.ifs-themes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--colour-text);
  padding-top: .6rem;
}

.ifs-themes li {
  padding: .6rem .75rem;
  border-left: 3px solid var(--colour-border);
  margin-bottom: .5rem;
  background: var(--colour-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.ifs-theme-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--colour-muted);
  margin-bottom: .3rem;
}

.ifs-theme-body {
  display: block;
  font-size: .85rem;
  line-height: 1.55;
  color: var(--colour-text);
}

.ifs-details {
  border-top: 1px solid var(--colour-border);
  padding-top: .6rem;
}

.ifs-details-toggle {
  font-size: .82rem;
  font-weight: 600;
  color: var(--colour-accent);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .35rem;
  user-select: none;
}

.ifs-details-toggle::-webkit-details-marker { display: none; }

.ifs-details-toggle::before {
  content: '▶';
  font-size: .6rem;
  transition: transform .15s ease;
  display: inline-block;
}

.ifs-details[open] > .ifs-details-toggle::before {
  transform: rotate(90deg);
}

.ifs-source-link {
  margin-top: auto;
  font-size: .85rem;
  font-weight: 600;
  color: var(--colour-accent);
}

.ifs-pending-text {
  font-size: .88rem;
  color: var(--colour-muted);
  line-height: 1.5;
}

/* --- Responsive ------------------------------------------ */
@media (max-width: 640px) {
  .site-nav { display: none; }
  .hero { padding: 2rem 0 1.75rem; }
  .ifs-grid { grid-template-columns: 1fr; }
}
