/* style.css
   Purpose: All visual styles for the MP Interests Leaderboard frontend
   Depends on: Inter font from Google Fonts (loaded in index.html)
   Used by: index.html, methodology.html */

/* ── Reset & base ──────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: #212529;
  line-height: 1.5;
  min-height: 100vh;
}


/* ── Layout ────────────────────────────────────────────────────────────────── */

.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
  box-sizing: border-box;
}

/* Prevent horizontal overflow from cards on narrow screens without breaking pill scroll */
main {
  overflow-x: hidden;
}


/* ── Banner ────────────────────────────────────────────────────────────────── */

.site-banner-img {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 12px;
}


/* ── Header ────────────────────────────────────────────────────────────────── */

.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
  padding: 20px 0;
  margin-bottom: 24px;
}

.site-header .page-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #212529;
  letter-spacing: -0.02em;
}

.site-strapline {
  font-size: 0.875rem;
  color: #6c757d;
}


/* ── Metric selector ───────────────────────────────────────────────────────── */

.selector-bar {
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 0;
  margin-bottom: 8px;
}

.selector-track {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.scroll-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid #dee2e6;
  border-radius: 50%;
  background: #ffffff;
  color: #495057;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  padding: 0;
}

.scroll-arrow:hover {
  background: #f8f9fa;
}

.scroll-arrow.hidden {
  opacity: 0;
  pointer-events: none;
}

.selector-scroll {
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.selector-scroll::-webkit-scrollbar {
  display: none;
}

.selector-pills {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #495057;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}

.pill:hover {
  background: #e9ecef;
  border-color: #ced4da;
}

.pill.active {
  background: #1a73e8;
  color: #ffffff;
  border-color: #1a73e8;
}


/* ── Meta bar (last updated) ───────────────────────────────────────────────── */

.meta-bar {
  padding: 8px 0 16px;
}

.meta-bar .page-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.last-updated {
  font-size: 0.8125rem;
  color: #6c757d;
}


/* ── Card grid ─────────────────────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding-bottom: 48px;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}



/* ── MP card ───────────────────────────────────────────────────────────────── */

.mp-card {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 4px solid #adb5bd;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.15s, transform 0.15s;
}

.mp-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

/* Party colour left borders */
.mp-card[data-party="Conservative"]       { border-left-color: #0087DC; }
.mp-card[data-party="Labour"]             { border-left-color: #E4003B; }
.mp-card[data-party="Liberal Democrat"]   { border-left-color: #FAA61A; }
.mp-card[data-party="Liberal Democrats"]  { border-left-color: #FAA61A; }
.mp-card[data-party="Reform UK"]          { border-left-color: #12B6CF; }
.mp-card[data-party="Green Party"]        { border-left-color: #02A95B; }
.mp-card[data-party="Scottish National Party"] { border-left-color: #FDF38E; }
.mp-card[data-party="SNP"]                { border-left-color: #FDF38E; }
.mp-card[data-party="Plaid Cymru"]        { border-left-color: #005B54; }
.mp-card[data-party="Democratic Unionist Party"] { border-left-color: #D46A4C; }
.mp-card[data-party="DUP"]                { border-left-color: #D46A4C; }

.card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-rank {
  font-size: 1.75rem;
  font-weight: 700;
  color: #dee2e6;
  min-width: 36px;
  text-align: center;
  line-height: 1;
}

.card-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  flex-shrink: 0;
  background: #e9ecef;
}

.card-photo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #adb5bd;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.card-identity {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 1rem;
  font-weight: 600;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 0.8125rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-bottom {
  border-top: 1px solid #f0f2f5;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-metric-value {
  font-size: 1.375rem;
  font-weight: 700;
  color: #1a73e8;
  line-height: 1.2;
}

.card-metric-label {
  font-size: 0.75rem;
  color: #6c757d;
}

.card-composite {
  font-size: 0.75rem;
  color: #adb5bd;
  margin-top: 4px;
}


/* ── Skeleton loading ──────────────────────────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f2f5 25%, #e9ecef 50%, #f0f2f5 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
}

.mp-card.skeleton-card {
  border-left-color: #e9ecef;
  pointer-events: none;
}

.skeleton-rank  { width: 36px; height: 32px; }
.skeleton-photo { width: 64px; height: 64px; border-radius: 50%; }
.skeleton-name  { width: 140px; height: 16px; margin-bottom: 6px; }
.skeleton-meta  { width: 100px; height: 13px; }
.skeleton-value { width: 80px; height: 22px; margin-top: 14px; }
.skeleton-label { width: 120px; height: 12px; margin-top: 6px; }


/* ── Error state ───────────────────────────────────────────────────────────── */

.error-card {
  grid-column: 1 / -1;
  background: #fff5f5;
  border-left-color: #E4003B;
  color: #495057;
  font-size: 0.9375rem;
  text-align: center;
  padding: 32px 16px;
}


/* ── Footer ────────────────────────────────────────────────────────────────── */

.site-footer {
  background: #ffffff;
  border-top: 1px solid #e9ecef;
  padding: 20px 0;
  margin-top: 8px;
}

.site-footer .page-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* EU AI content label (DOT-667) - icon links to the EU definition of the mark. */
.ai-label {
  text-decoration: none;
}

.ai-label img {
  width: 1.15rem;
  height: 1.15rem;
  display: inline-block;
  vertical-align: -0.22em;
}

.footer-text {
  font-size: 0.8125rem;
  color: #6c757d;
}

.footer-link {
  color: #1a73e8;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-kofi {
  font-size: 0.8125rem;
  color: #495057;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e9ecef;
}

.footer-kofi-link {
  color: #1a73e8;
  font-weight: 600;
  text-decoration: none;
}

.footer-kofi-link:hover {
  text-decoration: underline;
}


/* ── Party filter ──────────────────────────────────────────────────────────── */

.party-filter-bar {
  padding: 0 0 12px;
}

.party-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.party-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #495057;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.party-pill:hover {
  background: #e9ecef;
  border-color: #ced4da;
}

.party-pill.active {
  background: #1a73e8;
  color: #ffffff;
  border-color: #1a73e8;
}


/* ── Party breakdown bar ───────────────────────────────────────────────────── */

.breakdown-bar-section {
  padding: 0 0 16px;
}

.breakdown-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: #e9ecef;
  margin-bottom: 8px;
}

.breakdown-segment {
  position: absolute;
  top: 0;
  height: 100%;
}

.breakdown-segment:first-child {
  border-radius: 5px 0 0 5px;
}

.breakdown-segment:last-child {
  border-radius: 0 5px 5px 0;
}

.breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
}

.breakdown-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: #6c757d;
  flex: 0 0 50%;
}

@media (min-width: 640px) {
  .breakdown-legend-item {
    flex: 0 0 33.333%;
  }
}


.metric-description {
  margin-top: 12px;
  font-size: 0.9375rem;
  color: #495057;
  line-height: 1.6;
}


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


/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 639px) {
  .site-title {
    font-size: 1.25rem;
  }

  .card-rank {
    font-size: 1.375rem;
    min-width: 28px;
  }

  .mp-card {
    /* Ensure cards never exceed the viewport on any phone */
    max-width: 100%;
    min-width: 0;
  }

  .card-name {
    font-size: 0.9375rem;
  }

  .card-metric-value {
    font-size: 1.25rem;
  }
}


/* ── Methodology page ──────────────────────────────────────────────────────── */

.method-nav {
  background: #ffffff;
  border-bottom: 1px solid #e9ecef;
  padding: 10px 0;
  font-size: 0.8125rem;
}

.method-nav a {
  color: #1a73e8;
  text-decoration: none;
}

.method-nav a:hover {
  text-decoration: underline;
}

.method-body {
  padding: 40px 0 64px;
}

.method-section {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 32px;
  margin-bottom: 24px;
}

.method-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.method-section h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #212529;
  margin: 24px 0 10px;
}

.method-section p {
  font-size: 0.9375rem;
  color: #495057;
  line-height: 1.7;
  margin-bottom: 12px;
}

.method-section p:last-child {
  margin-bottom: 0;
}

.method-section ul,
.method-section ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.method-section li {
  font-size: 0.9375rem;
  color: #495057;
  line-height: 1.7;
  margin-bottom: 6px;
}

.callout {
  background: #f0f6ff;
  border-left: 4px solid #1a73e8;
  border-radius: 0 6px 6px 0;
  padding: 16px 20px;
  margin: 20px 0;
}

.callout p {
  font-size: 0.9375rem;
  color: #212529;
  line-height: 1.7;
  margin-bottom: 8px;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-amber {
  background: #fffbf0;
  border-left: 4px solid #f0a500;
}

.cite {
  font-size: 0.75rem;
  font-weight: 600;
  color: #1a73e8;
  vertical-align: super;
  line-height: 1;
}

.metric-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 8px;
}

.metric-table th {
  text-align: left;
  font-weight: 600;
  color: #212529;
  padding: 8px 12px;
  border-bottom: 2px solid #e9ecef;
  background: #f8f9fa;
}

.metric-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  color: #495057;
  line-height: 1.5;
  vertical-align: top;
}

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

.metric-id {
  font-weight: 600;
  color: #1a73e8;
  white-space: nowrap;
}

.reference-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.reference-list li {
  padding: 10px 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.875rem;
  color: #495057;
  line-height: 1.6;
}

.reference-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ref-num {
  font-weight: 600;
  color: #212529;
  margin-right: 6px;
}

.ref-doi {
  color: #1a73e8;
  text-decoration: none;
  word-break: break-all;
}

.ref-doi:hover {
  text-decoration: underline;
}

.formula {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  color: #212529;
  margin: 12px 0;
  display: block;
}

.anchor-target {
  scroll-margin-top: 24px;
}

@media (max-width: 639px) {
  .method-section {
    padding: 20px 16px;
    border-radius: 6px;
  }

  .metric-table {
    font-size: 0.8125rem;
  }

  .metric-table th,
  .metric-table td {
    padding: 8px 8px;
  }
}
