/*
  The presenter drawer: the right-side overlay that opens on a constituency in
  both views. It started on the studio stage and is now the public map's popup
  too, so its rules live here and both pages link this file — one widget, one
  set of measurements, no drift between the broadcast and the public screen.

  The panel is deliberately dark in both themes: it sits over a map and is read
  at broadcast distance. `theme-light.css` adjusts its text and surfaces so it
  stays legible on the bright public page.
*/
.presenter-drawer {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 440px;
  max-width: calc(100% - 28px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: rgba(10, 16, 29, 0.95);
  border: 1px solid #273b5a;
  border-right: 3px solid var(--red, #dc172b);
  border-radius: 12px;
  box-shadow: -10px 14px 45px rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  transform: translateX(115%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  visibility: hidden;
}

.presenter-drawer.open {
  transform: translateX(0);
  visibility: visible;
}

.drawer-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #1c2b42;
  background: #0e172a;
}

.drawer-code {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--sky, #38bdf8);
  font: 800 10px "JetBrains Mono", monospace;
  letter-spacing: .08em;
}

.drawer-title {
  margin: 6px 0 2px;
  color: #ffffff;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
}

.drawer-subtitle {
  margin: 0;
  color: var(--muted, #94a3b8);
  font-size: 11px;
}

.drawer-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #2f415e;
  border-radius: 6px;
  background: #152238;
  color: #b0c4de;
  font: 700 10px "JetBrains Mono", monospace;
  letter-spacing: .04em;
  transition: .15s ease;
  cursor: pointer;
}

.drawer-close:hover {
  border-color: var(--red, #dc172b);
  background: var(--red, #dc172b);
  color: #fff;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-body > section {
  margin: 0;
}

.drawer-body .section-title {
  margin: 0 0 8px;
  color: var(--sky, #38bdf8);
  font: 800 9.5px "JetBrains Mono", monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.drawer-body .kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.drawer-body .kpi {
  padding: 10px 12px;
  border: 1px solid #1e2e46;
  border-radius: 6px;
  background: #0c1424;
}

.drawer-body .kpi-label {
  color: #7d90a9;
  font: 700 8px "JetBrains Mono", monospace;
  text-transform: uppercase;
}

.drawer-body .kpi-value {
  margin-top: 4px;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.drawer-body .kpi-sub {
  margin-top: 2px;
  color: #62748e;
  font-size: 8.5px;
}

.drawer-body .candidate-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.drawer-body .candidate {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 110px;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid #1b293e;
  border-radius: 7px;
  background: #111a2c;
}

.drawer-body .candidate.winner {
  border-color: #10b981;
  background: linear-gradient(90deg, rgba(16, 185, 129, .14), #111a2c 70%);
}

.drawer-body .candidate .rank {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #1a273b;
  color: #94a3b8;
  font: 800 11px "JetBrains Mono", monospace;
}

.drawer-body .candidate.winner .rank {
  background: #064e3b;
  color: #34d399;
}

.drawer-body .candidate-name {
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  /* A broadcast name must be readable in full; two lines is the limit that
     still fits beside the portrait and the vote column. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.drawer-body .party-badge {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  font: 800 8.5px "JetBrains Mono", monospace;
}

.drawer-body .votes {
  text-align: right;
}

.drawer-body .vote-count {
  color: #fff;
  font: 800 13px "JetBrains Mono", monospace;
}

.drawer-body .vote-share {
  color: var(--sky, #38bdf8);
  font: 600 9.5px "JetBrains Mono", monospace;
}

.drawer-body .progress {
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: #1e293b;
}

.drawer-body .progress-fill {
  height: 100%;
  background: var(--sky, #38bdf8);
}

.drawer-body .winner .progress-fill {
  background: #10b981;
}

.drawer-body .candidate-empty {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.5;
}

/*
  On the public map the stage is only as tall as the map panel, so anchoring
  top and bottom to it left the panel a ~230px scroll box that opened with the
  candidate list already scrolled out of view — nothing like the broadcast
  panel. On this page the drawer is therefore pinned to the viewport instead of
  the stage: the same full-height card the studio shows, with candidates first,
  then counting status and demographics, all readable without scrolling.
*/
.presenter-drawer--map {
  position: fixed;
  top: 14px;
  bottom: 14px;
}

@media (max-width: 960px) {
  .presenter-drawer {
    width: 380px;
  }
}

@media (max-width: 600px) {
  .presenter-drawer {
    width: 100%;
    max-width: 100%;
    top: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
  }

  /* A phone gets the whole screen, so the fixed height must not win. */
  .presenter-drawer--map {
    bottom: 0;
    height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .presenter-drawer {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   Candidate portrait and biodata.

   The studio drawer and the public seat popup print the same record: a round
   portrait from the nomination register, the party badge with the candidate's
   age and occupation, and a two-line biodata block. A candidate with no photo
   keeps a monogram circle in the same footprint, so the list never reflows
   between seats that have portraits and seats that do not.
   -------------------------------------------------------------------------- */

.drawer-body .candidate-body { min-width: 0; }

.drawer-body .candidate-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* A portrait, not an avatar: the register's photo is 3:4, so a circular crop
   would cut the face off. One fixed box keeps every candidate row aligned. */
.drawer-body .candidate-photo {
  width: 52px;
  height: 68px;
  flex: none;
  border-radius: 6px;
  object-fit: cover;
  object-position: top center;
  background: #0b1220;
  border: 2px solid rgba(148, 163, 184, .35);
}

.drawer-body .candidate.winner .candidate-photo { border-color: #10b981; }

.drawer-body .candidate-no-photo {
  display: grid;
  place-items: center;
  font: 800 13px "JetBrains Mono", monospace;
  color: #cbd5e1;
  letter-spacing: .04em;
  border-style: dashed;
}

.drawer-body .candidate-id { min-width: 0; }

.drawer-body .candidate-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.drawer-body .candidate-age {
  font-size: 9px;
  color: #94a3b8;
  letter-spacing: .02em;
}

.drawer-body .candidate-bio {
  margin: 7px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: #94a3b8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
