/* Ballot page styles.  Tier colors come from config.toml via --tier-bg / --tier-bg-dark. */

:root {
  --fg: #1d2025;
  --muted: #5b6370;
  --bg: #f7f7f5;
  --card: #ffffff;
  --line: #c9ccd2;
  --chip: #ffffff;
  --chip-line: #9aa1ab;
  --accent: #1f5fbf;
  --accent-fg: #ffffff;
  --drop: #1f5fbf;
  --coi: #b26b00;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e8eb;
    --muted: #a3aab5;
    --bg: #16181c;
    --card: #1f2227;
    --line: #444a54;
    --chip: #2b2f36;
    --chip-line: #6b7380;
    --accent: #5c9cff;
    --accent-fg: #0b1220;
    --drop: #7fb2ff;
    --coi: #ffb547;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.page { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
h1 { font-size: 1.4rem; margin: 0 0 .2rem; }
.voter { margin: 0 0 1rem; color: var(--muted); }

.banner {
  background: #fbe3e1; color: #6b1a14; border-radius: 8px; padding: .6rem .8rem; margin-bottom: 1rem;
}
@media (prefers-color-scheme: dark) { .banner { background: #4a1f1c; color: #ffd9d4; } }

.instructions {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .8rem; margin-bottom: 1rem;
}
.instructions summary { cursor: pointer; font-weight: 600; }
.prose { font-size: .95rem; }
.prose h1, .prose h2 { font-size: 1.05rem; }

.hint { font-size: .9rem; color: var(--muted); }
.star-demo { color: var(--coi); }
/* Show mouse- or touch-specific hints. */
.touch-only { display: none; }
@media (hover: none) { .touch-only { display: inline; } .mouse-only { display: none; } }

/* ---------- candidates ("chips") ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .15rem;
  background: var(--chip); border: 1px solid var(--chip-line); border-radius: 999px;
  padding: .2rem .7rem .2rem .25rem; min-height: 2.1rem;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; max-width: 100%;
}
.chip .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .coi {
  border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1;
  width: 1.9rem; height: 1.9rem; border-radius: 50%; cursor: pointer; padding: 0;
}
.chip .coi[aria-pressed="true"] { color: var(--coi); }
.chip.is-coi { border-color: var(--coi); border-style: dashed; }
.chip.is-coi .label { text-decoration: line-through; }
.chip.dragging { opacity: .3; }
.chip.ghost {
  position: fixed; z-index: 1000; pointer-events: none; margin: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); transform: rotate(-2deg); opacity: .95;
}
body.locked .chip { cursor: default; }

/* ---------- unranked pool ---------- */
.pool {
  border: 1px dashed var(--line); border-radius: 10px; padding: .4rem;
  margin-bottom: .8rem; background: var(--card); min-height: 3.2rem;
}
.pool-label { font-size: .8rem; color: var(--muted); font-weight: 600; margin: 0 0 .3rem .2rem; }
.pool.drop-target { outline: 3px solid var(--drop); outline-offset: -2px; }

/* ---------- the board: one big box split into colored tiers ---------- */
.board { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative; }
.tier {
  display: grid; grid-template-columns: 6.2rem 1fr;
  background: var(--tier-bg);
}
@media (prefers-color-scheme: dark) { .tier { background: var(--tier-bg-dark); } }
.tier-label {
  font-size: .78rem; font-weight: 700; line-height: 1.2; padding: .45rem .4rem .45rem .55rem;
  border-right: 1px solid rgba(0,0,0,.08); hyphens: auto;
}
.board.single .tier { grid-template-columns: 1fr; }
.board.single .tier-label { display: none; }
.rows { padding: 2px 4px; min-width: 0; }
.drop-notice {
  display: flex; align-items: center; justify-content: center; min-height: 8rem;
  font-size: 1.4rem; font-weight: 600; opacity: 0.45; text-align: center;
  pointer-events: none; user-select: none;
}
.tier.empty .rows { min-height: 2.8rem; }  /* room to drop into an empty tier */

.row {
  display: flex; align-items: flex-start; gap: .35rem;
  padding: 3px 2px; border-radius: 8px; border: 1px solid transparent;
}
.row + .row { border-top-color: rgba(0,0,0,.08); }
.row.tie { border-color: rgba(0,0,0,.18); background: rgba(255,255,255,.35); }
@media (prefers-color-scheme: dark) {
  .row + .row { border-top-color: rgba(255,255,255,.08); }
  .row.tie { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.05); }
}
.rank { font-size: .75rem; color: var(--muted); width: 1.6rem; text-align: right; padding-top: .55rem; flex: none; }
.row-chips { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; flex: 1; }
/* Candidates in a tier are all tied (rank_within_tiers = false): no tie box, and
   wrapped lines are indented (a hanging indent) so no chip looks higher ranked. */
.board.tied .row-chips { display: block; padding-left: 1.2rem; text-indent: -1.2rem; }
.board.tied .chip { text-indent: 0; vertical-align: top; margin: 0 .3rem .3rem 0; }
.row.drop-join { outline: 3px solid var(--drop); outline-offset: -2px; }

.drop-line {
  position: absolute; height: 4px; border-radius: 2px; background: var(--drop);
  pointer-events: none; z-index: 10;
}

/* ---------- submit bar & dialogs ---------- */
.submit-bar {
  position: sticky; bottom: 0; display: flex; gap: .8rem; align-items: center; justify-content: flex-end;
  padding: .7rem 0; background: var(--bg); margin-top: .8rem;
}
#status { font-size: .9rem; color: var(--muted); flex: 1; }
#status.error { color: #c0392b; }
button {
  font: inherit; border-radius: 8px; padding: .5rem 1.1rem; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
/* Save (a draft) is the same color as Submit, but less prominent. */
button.primary.light { background: transparent; color: var(--accent); font-weight: 400; }
button:disabled { opacity: .5; cursor: default; }
dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--fg);
  max-width: min(32rem, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { font-size: 1.1rem; margin-top: 0; }
.dialog-buttons { display: flex; gap: .6rem; justify-content: flex-end; }
a { color: var(--accent); }

/* Candidate "info" may contain newlines (e.g., title, then authors). */
#info-text { white-space: pre-line; }

/* Hover tooltip (see `tip` in ballot.js). */
.tip {
  position: fixed; z-index: 1100; pointer-events: none; max-width: min(22rem, calc(100vw - 12px));
  background: var(--fg); color: var(--bg); border-radius: 6px; padding: .35rem .55rem;
  font-size: .85rem; line-height: 1.35; white-space: pre-line; box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.tip.tip-coi { background: var(--coi); }  /* matches the star */
.banner a { color: inherit; font-weight: 600; }
