/* Results page: "Votes by Contestants" board (public/results.php).
   Mobile first. Colours are scoped to the board so the rest of the site's
   palette (style.css) is untouched. */

.results-page {
  --rb-dark: #0B4D2C;
  --rb-green: #3DB94A;
  --rb-gold: #C9A227;
  --rb-ink: #1E2A22;
  --rb-line: #E3E8E4;
  --rb-title-font: 'Montserrat', 'Segoe UI', Roboto, Arial, sans-serif;
  --rb-script-font: 'Caveat', 'Segoe Print', cursive;
  padding-top: 20px;
  padding-bottom: 12px;
}
/* The printed chart is 1280px wide; let the board reach that on big screens. */
.container.results-page { max-width: 1312px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Tools row (not part of the exported image) */
.rb-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.rb-refresh-note { margin: 0; font-size: 0.85rem; color: #5b6660; }
.rb-download { font-weight: 700; }
.rb-download[disabled] { opacity: 0.6; cursor: progress; }

/* Board */
.rb {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  color: var(--rb-ink);
  font-family: var(--rb-title-font);
}

/* Header block */
.rb-head {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 6px;
  padding: 16px 14px 12px;
  text-align: center;
}
.rb-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.rb-logo img { width: 64px; height: 64px; object-fit: contain; }
.rb-logo-tag {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rb-dark);
}
.rb-titles { min-width: 0; }
.rb-title {
  margin: 0;
  font-size: clamp(1.2rem, 5.6vw, 2.55rem);
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--rb-dark);
  letter-spacing: 0.01em;
}
.rb-pill {
  display: inline-block;
  margin: 8px 0 0;
  padding: 6px 18px;
  border-radius: 10px;
  background: var(--rb-green);
  color: #fff;
  font-size: clamp(1rem, 4.6vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.rb-asat {
  margin: 6px 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--rb-ink);
}
.rb-total {
  margin: 4px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4d5a52;
}
.rb-total strong { color: var(--rb-dark); font-weight: 800; }

/* Handwritten taglines */
.rb-tagline {
  margin: 0;
  font-family: var(--rb-script-font);
  font-weight: 700;
  color: var(--rb-dark);
  line-height: 1.05;
}
.rb-swoosh {
  display: block;
  width: 70%;
  height: 10px;
  margin: 2px 0 0 auto;
  color: var(--rb-gold);
}
.rb-tagline-top { display: none; }
.rb-tagline-bottom {
  font-size: 1.05rem;
  text-align: center;
  padding: 12px 16px 4px;
}
.rb-tagline-bottom .rb-swoosh { width: 140px; margin: 2px auto 0; }

/* Table area */
.rb-body { position: relative; }
.rb-watermark { display: none; }

.rb-cols,
.rb-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  position: relative;
  z-index: 1;
}
.rb-cols {
  background: var(--rb-dark);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rb-cols span { padding: 9px 10px; }
.rb-cols .rb-col-rank { padding-left: 2px; padding-right: 2px; }
.rb-col-rank { text-align: center; border-right: 1px solid rgba(255, 255, 255, 0.25); }
/* On mobile, "Votes" sits on the same line as the name heading, right aligned. */
.rb-col-name { display: flex; }
.rb-col-votes { display: none; }
.rb-cols::after {
  content: 'Votes';
  position: absolute;
  right: 12px;
  top: 9px;
}

.rb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rb-row {
  grid-template-areas:
    "rank name"
    "rank track";
  min-height: 44px;
  border-bottom: 1px solid var(--rb-line);
}
.rb-row:hover { background: rgba(61, 185, 74, 0.05); }
.rb-rank {
  grid-area: rank;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: -1px;
  background: var(--rb-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}
.rb-name {
  grid-area: name;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 8px;
  padding: 8px 12px 0;
  align-content: center;
  color: var(--rb-ink);
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
/* The whole row is the tap target for the contestant link (>= 44px tall). */
.rb-name::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.rb-name:hover,
.rb-name:focus-visible { color: var(--rb-dark); text-decoration: underline; }
.rb-name:focus-visible { outline: none; }
.rb-name:focus-visible::after { outline: 3px solid var(--rb-gold); outline-offset: -3px; }
.rb-no {
  font-size: 0.72rem;
  font-weight: 600;
  color: #7c877f;
  white-space: nowrap;
}

.rb-track {
  grid-area: track;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 12px 10px;
}
.rb-bar {
  flex: none;
  height: 14px;
  min-width: 4px;
  width: calc((100% - 4.5rem) * var(--share, 0));
  background: var(--rb-green);
  border-radius: 2px;
  animation: rb-grow 1s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: width 0.6s ease;
}
.rb-votes {
  flex: none;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--rb-ink);
}
@keyframes rb-grow {
  from { width: 0; min-width: 0; }
}
.rb-row.is-updated .rb-votes { color: var(--rb-green); transition: color 0.3s; }

.rb-empty { padding: 24px 16px; text-align: center; }

/* Footer band */
.rb-foot { position: relative; }
.rb-wave { display: block; width: 100%; height: 26px; }
.rb-band {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 16px 14px;
  background: var(--rb-dark);
  color: #fff;
  text-align: center;
}
.rb-motto {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.rb-motto span { margin: 0 0.35em; opacity: 0.8; }
.rb-social {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}
.rb-social-links {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}
.rb-social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: #fff;
  border-radius: 50%;
}
.rb-social-links a:hover,
.rb-social-links a:focus-visible { background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.rb-social-sep { display: none; opacity: 0.7; }


/* Tablet and up: one line per contestant, as in the printed chart */
@media (min-width: 481px) {
  .rb-head {
    grid-template-columns: 130px minmax(0, 1fr) 130px;
    align-items: center;
    padding: 18px 20px 14px;
  }
  .rb-logo img { width: 84px; height: 84px; }
  .rb-title { font-size: clamp(1.35rem, 3.6vw, 2rem); }
  .rb-pill { font-size: clamp(1rem, 2.8vw, 1.6rem); padding: 5px 22px; }
  .rb-tagline-top {
    display: block;
    white-space: nowrap;
    font-size: 1.05rem;
    text-align: center;
    transform: rotate(-4deg);
  }

  .rb-cols,
  .rb-row {
    grid-template-columns: 64px minmax(0, 34%) minmax(0, 1fr);
  }
  .rb-row { grid-template-areas: "rank name track"; }
  .rb-cols::after { content: none; }
  .rb-col-votes { display: block; text-align: right; padding-right: 20px; }
  .rb-name { padding: 6px 14px; align-content: center; }
  .rb-track { padding: 6px 14px 6px 0; }
  .rb-bar { height: 18px; }

  .rb-watermark {
    display: block;
    position: absolute;
    right: 1%;
    bottom: 64px;
    height: 70%;
    max-height: 520px;
    width: auto;
    color: var(--rb-green);
    opacity: 0.08;
    pointer-events: none;
    z-index: 0;
  }

  .rb-tagline-bottom {
    font-size: 1.25rem;
    text-align: right;
    padding: 10px 28px 0;
    transform: rotate(-4deg);
  }
  .rb-tagline-bottom .rb-swoosh { width: 150px; margin: 2px 0 0 auto; }

  .rb-wave { height: 36px; }
  .rb-band {
    flex-direction: row;
    justify-content: space-between;
    padding: 4px 24px 10px;
    text-align: left;
  }
  .rb-social { justify-content: flex-end; }
  .rb-social-sep { display: inline; }
  .rb-motto { letter-spacing: 0.22em; }
}

/* Desktop */
@media (min-width: 900px) {
  .rb-head { grid-template-columns: 190px minmax(0, 1fr) 190px; padding: 22px 28px 16px; }
  .rb-title { font-size: clamp(1.6rem, 2.7vw, 2.4rem); }
  .rb-logo img { width: 112px; height: 112px; }
  .rb-logo-tag { font-size: 0.6rem; }
  .rb-tagline-top { font-size: 1.5rem; white-space: nowrap; }
  .rb-pill { padding: 6px 42px; }
  .rb-asat { font-size: 1.05rem; }
  .rb-total { font-size: 0.9rem; }

  .rb-body { padding: 0 28px; }
  .rb-cols,
  .rb-row { grid-template-columns: 86px minmax(0, 300px) minmax(0, 1fr); }
  .rb-cols { font-size: 0.9rem; }
  .rb-cols span { padding: 10px 14px; }
  .rb-col-name { padding-left: 24px !important; }
  .rb-name { padding-left: 24px; font-size: 1.1rem; }
  .rb-rank { font-size: 1.1rem; }
  .rb-bar { height: 22px; }
  .rb-votes { font-size: 1.1rem; }
  .rb-watermark { right: 3%; }

  /* Sits in the white space right of the lowest rows (their bars are the shortest). */
  .rb-body { padding-bottom: 14px; }
  .rb-tagline-bottom {
    position: absolute;
    right: 40px;
    bottom: 0;
    z-index: 2;
    padding: 0;
    font-size: 1.5rem;
    pointer-events: none;
  }
  .rb-motto { font-size: 0.9rem; letter-spacing: 0.24em; }
  .rb-band { padding: 2px 32px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .rb-bar { animation: none; transition: none; }
  .rb-row.is-updated .rb-votes { transition: none; }
}

/* "Download as Image": the clone html2canvas renders gets this class so the
   export matches the printed chart (1280px wide, no rounded card, no motion). */
.rb.is-exporting {
  width: 1280px;
  border-radius: 0;
  box-shadow: none;
}
.rb.is-exporting .rb-bar { animation: none; transition: none; }
.rb.is-exporting .rb-head { padding-top: 14px; padding-bottom: 10px; }
.rb.is-exporting .rb-logo img { width: 96px; height: 96px; }
.rb.is-exporting .rb-row { min-height: 0; }
.rb.is-exporting .rb-name,
.rb.is-exporting .rb-track { padding-top: 4px; padding-bottom: 4px; }
.rb.is-exporting .rb-body { padding-bottom: 8px; }
.rb.is-exporting .rb-social-links a { width: 34px; height: 34px; }

/* html2canvas 1.4.1 measures font baselines with a temporary <div><img></div>
   appended to <body>. style.css's global `img { display: block }` breaks that
   measurement and every exported line of text renders a few px too low.
   Nothing on this page is a direct body > div > img, so this only touches
   html2canvas's measuring element. */
body > div > img { display: inline; }

/* "Meet the Contestants" gallery, below the board. Outside #results-board,
   so neither the image export nor the auto-refresh ever touches it. */
.cg { margin-top: 36px; }
.cg-title {
  margin: 0;
  font-family: var(--rb-title-font);
  font-size: clamp(1.35rem, 5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  text-align: center;
  color: var(--rb-dark);
}
.cg-title::after {
  content: '';
  display: block;
  width: 90px;
  height: 3px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: var(--rb-gold);
}
.cg-sub {
  margin: 8px 0 18px;
  text-align: center;
  font-size: 0.95rem;
  color: #4d5a52;
}

.cg-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cg-grid > li { display: flex; min-width: 0; }

.cg-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 8px 8px 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(11, 77, 44, 0.10);
  color: var(--rb-ink);
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.cg-card:hover { text-decoration: none; }
.cg-card:focus-visible { outline: 3px solid var(--rb-gold); outline-offset: 2px; }

.cg-photo {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 9px;
  background: #EEF3EF;
}
.cg-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* never crop the top of the head */
}
.cg-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--rb-green);
  color: #fff;
  font-family: var(--rb-title-font);
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.cg-name {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 2px;
  font-family: var(--rb-title-font);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: var(--rb-dark);
  overflow-wrap: anywhere;
}
.cg-vote {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* tap target */
  border-radius: 8px;
  background: var(--rb-green);
  color: #fff;
  font-family: var(--rb-title-font);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.18s ease;
}

@media (min-width: 600px) {
  .cg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .cg-card { padding: 10px 10px 12px; }
  .cg-name { font-size: 1rem; }
}
@media (min-width: 1024px) {
  .cg { margin-top: 44px; }
  .cg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
}
@media (min-width: 1200px) {
  .cg-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Lift on hover only where there is a real pointer (not on touch taps). */
@media (hover: hover) {
  .cg-card:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(11, 77, 44, 0.18); }
  .cg-card:hover .cg-vote { background: var(--rb-dark); }
}
@media (prefers-reduced-motion: reduce) {
  .cg-card, .cg-vote { transition: none; }
  .cg-card:hover { transform: none; }
}
