/* VotePoll picture cards — one design for Picture Poll ballots (main app) and Contest / Awards nominees (contest
   service). This file is copied byte for byte into both apps (public/css/picture-cards.css and
   contest/public/static/picture-cards.css; tests/picture-cards-shared.cjs fails when they differ), so the services
   share the look without any runtime link. It uses its own --pc-* tokens and depends on neither site's variables.
   Voting interactions stay each app's own: selection (radio/checkbox) on polls, a Vote button per card on contests.

   Markup: .pc-grid[.pc-cols-2|3|4] > .pc-card > .pc-figure (+ .pc-zoom) and .pc-body > .pc-name, optional
   .pc-result (.pc-result-top: .pc-rank .pc-votes .pc-share, then .pc-bar > i). Without a .pc-cols-* class each app
   keeps its own automatic columns (the layout existing polls and contests always had). */
.pc-grid {
  --pc-navy: #0b2557;
  --pc-navy-2: #0e3270;
  --pc-blue: #0b5cc4;
  --pc-blue-light: #4da3ff;
  --pc-ink: #101828;
  --pc-ink-soft: #5b6475;
  --pc-line: #e3e8f0;
  --pc-track: #e3e9f2;
  --pc-photo-bg: #eef2f7;
  --pc-radius: 14px;
  --pc-gap: 14px;
  --pc-min: 140px; /* narrowest card a column preference may produce; fewer columns below that */
  --pc-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 10px 28px -16px rgba(16, 24, 40, 0.35);
  display: grid;
  gap: var(--pc-gap);
}
/* A column count is a preference, not a command: at most N columns, fewer whenever a card would get narrower than
   --pc-min (tablets, phones), never horizontal scrolling. The 0.1px keeps N tracks fitting despite rounding. */
.pc-grid.pc-cols-2 { --pc-n: 2; }
.pc-grid.pc-cols-3 { --pc-n: 3; }
.pc-grid.pc-cols-4 { --pc-n: 4; }
.pc-grid.pc-cols-2, .pc-grid.pc-cols-3, .pc-grid.pc-cols-4 {
  grid-template-columns: repeat(auto-fill, minmax(max(min(100%, var(--pc-min)), calc((100% - (var(--pc-n) - 1) * var(--pc-gap)) / var(--pc-n) - 0.1px)), 1fr));
}

.pc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  background: #fff;
  border: 1px solid var(--pc-line);
  border-radius: var(--pc-radius);
  overflow: hidden;
  box-shadow: var(--pc-shadow);
  color: var(--pc-ink);
}
/* Portrait-friendly 4:5 frame, the same for every card in a grid. Photos fill it (cropped, never stretched);
   landscape pictures (.pc-fit, set when they load) are shown whole on a neutral backing instead. Very wide cards
   (2 columns on a large screen) stop at 560px tall rather than growing without limit. */
.pc-figure {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 560px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--pc-photo-bg);
}
.pc-figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pc-figure img.pc-fit { object-fit: contain; }
/* "View larger image" control: top-right of the picture, 36px (easy to hit, small enough not to swallow taps). */
.pc-zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--pc-line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--pc-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  cursor: zoom-in;
}
.pc-zoom:hover { color: var(--pc-blue); border-color: var(--pc-blue); }
.pc-zoom:focus-visible { outline: 3px solid var(--pc-blue-light); outline-offset: 2px; }
.pc-zoom svg { width: 18px; height: 18px; }

.pc-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
  padding: 12px 14px 14px;
}
/* Names: up to three lines, and always the height of two, so one- and two-line names line up across the grid. */
.pc-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  min-height: 2.6em;
  color: var(--pc-ink);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Results on a card: vote-based rank and share in blue, optional vote count, horizontal bar. Pushed to the bottom
   of the card (above a contest's Vote button) so results line up across a row. */
.pc-result {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pc-result-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.pc-rank { flex: none; font-weight: 800; font-size: 1.02rem; color: var(--pc-blue); }
.pc-share { flex: none; margin-left: auto; font-weight: 800; font-size: 1.02rem; color: var(--pc-blue); }
.pc-votes { min-width: 0; color: var(--pc-ink-soft); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-bar { display: block; height: 8px; border-radius: 999px; background: var(--pc-track); overflow: hidden; }
.pc-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pc-navy-2), var(--pc-blue)); transition: width 0.4s; }
.pc-result.is-first .pc-bar i { background: linear-gradient(90deg, var(--pc-blue), var(--pc-blue-light)); }
.pc-result.is-empty { flex-direction: row; align-items: baseline; gap: 8px; }
.pc-result.is-empty .pc-rank { color: #8a93a3; }
.pc-result.is-empty .pc-votes { font-size: 0.84rem; }

/* Visitor "Columns" selector (beside Sort by on contests, above the pictures on polls). */
.pc-layout { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 650; white-space: nowrap; }
.pc-layout select {
  font: inherit;
  font-size: 16px; /* ≥ 16px: no zoom on focus in iOS Safari */
  font-weight: 600;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 10px;
  width: auto;
  border: 1px solid #cdd5e1;
  background-color: #fff;
  color: var(--pc-navy);
  cursor: pointer;
}
.pc-layout select:focus-visible { outline: 3px solid var(--pc-blue-light); outline-offset: 2px; }

@media (max-width: 560px) {
  .pc-grid { --pc-gap: 10px; }
  .pc-body { padding: 10px 10px 12px; }
  .pc-name { font-size: 0.95rem; }
  .pc-rank, .pc-share { font-size: 0.95rem; }
  .pc-result-top { flex-wrap: wrap; row-gap: 2px; }
  .pc-result-top .pc-votes { order: 3; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .pc-bar i { transition: none; }
}
