/*
 * The voting page's look. Not the dashboard's greyscale on purpose: that palette exists so
 * the rerun's state reads across a room, and this page is read by a viewer deciding what to
 * watch. It carries the brand instead — the logo's green and the hard 45° black extrusion —
 * and only on the things you can press and the thing that won.
 */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --paper: #f3f5f2;
  --surface: #ffffff;
  --sunk: #e8ece7;
  --ink: #111512;
  --muted: #5d665f;
  --line: #d3d9d2;
  --brand: #36b55a;
  --brand-strong: #23853f;
  --on-brand: #07170c;
  --extrude: #0b0d0c;
  --twitch: #9146ff;
  --urgent: #e5484d;
  --cat-chat: #a3aba4;
  --bar: #2b322d;
  --r: 6px;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans KR", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d100e;
    --surface: #161a17;
    --sunk: #1f2420;
    --ink: #eef2ee;
    --muted: #98a29a;
    --line: #2a312c;
    --brand: #3fc565;
    --brand-strong: #5fd880;
    --on-brand: #04130a;
    --extrude: #000000;
    --twitch: #a970ff;
    --cat-chat: #5b645d;
    --bar: #c9d2ca;
    color-scheme: dark;
  }
}

.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- header ---------- */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-row { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.logo { height: 30px; width: auto; display: block; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--extrude); border-radius: var(--r); padding: 8px 14px;
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--ink);
  background: var(--surface); box-shadow: 3px 3px 0 var(--extrude); cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s; text-decoration: none;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--extrude); }
.btn[disabled] { opacity: 0.5; cursor: default; box-shadow: none; transform: none; }
.btn-twitch { background: var(--twitch); color: #fff; }
.btn-brand { background: var(--brand); color: var(--on-brand); }
.btn-voted { background: var(--brand); color: var(--on-brand); }
.btn-quiet { box-shadow: none; border-color: var(--line); background: transparent; }
.btn-quiet:active { transform: none; }

.user { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; min-width: 0; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover; background: var(--sunk); }
.sign-out { font: inherit; font-weight: 500; color: var(--muted); background: none; border: 0; padding: 4px; font-size: 13px; text-decoration: underline; cursor: pointer; }

/* ---------- on air ---------- */
.on-air { padding-block: 18px 6px; }
.on-air-row { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.on-air-thumb { width: 112px; aspect-ratio: 16 / 9; border-radius: 4px; object-fit: cover; display: block; background: var(--sunk); }
.eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--urgent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--urgent) 25%, transparent); }
.on-air-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.on-air-meta { font-size: 13px; color: var(--muted); }
.progress { height: 4px; background: var(--sunk); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--muted); }
.on-air-end { text-align: right; font-size: 13px; color: var(--muted); }
.on-air-end b { display: block; font-size: 18px; color: var(--ink); font-weight: 600; }

/* ---------- vote bar ---------- */
.vote-bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); padding-block: 14px 12px; border-bottom: 1px solid var(--line); }
.vote-bar-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.vote-head { flex: 1 1 320px; min-width: 0; }
.vote-head h1 { margin: 0; font-size: clamp(20px, 2.6vw, 28px); line-height: 1.15; text-wrap: balance; letter-spacing: -0.01em; font-weight: 700; }
.vote-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.clock { display: flex; align-items: center; gap: 14px; }
.clock-label { font-size: 14px; font-weight: 600; }
.clock-time { font-weight: 700; font-size: 40px; line-height: 1; letter-spacing: -0.01em; text-align: right; }
.drain { height: 6px; background: var(--sunk); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.drain > span { display: block; height: 100%; background: var(--brand); transition: width 1s linear; }
.urgent .clock-time { color: var(--urgent); }
.urgent .drain > span { background: var(--urgent); }

/* ---------- ballot ---------- */
.main { padding-block: 22px 64px; }
.notice { margin: 0 0 18px; padding: 10px 14px; border-radius: var(--r); background: var(--sunk); font-size: 14px; }
.hint { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.ballot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; align-items: stretch; }
@media (max-width: 980px) {
  .ballot { grid-template-columns: minmax(0, 1fr); max-width: 620px; margin: 0 auto; }
}

.card {
  background: var(--surface); border: 2px solid var(--line); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s, opacity 0.3s, filter 0.3s;
}
.mine { border-color: var(--extrude); box-shadow: 6px 6px 0 var(--brand); transform: translate(-2px, -2px); }
.won { border-color: var(--extrude); box-shadow: 6px 6px 0 var(--brand); }
.lost { opacity: 0.55; filter: saturate(0.3); }

.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--sunk); max-width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.num {
  position: absolute; left: 10px; top: 10px; width: 42px; height: 42px; display: grid; place-items: center;
  font-weight: 700; font-size: 24px; background: var(--surface); color: var(--ink);
  border: 2px solid var(--extrude); border-radius: 4px; box-shadow: 3px 3px 0 var(--extrude);
}
.mine .num, .won .num { background: var(--brand); color: var(--on-brand); }
.duration {
  position: absolute; right: 8px; bottom: 8px; font-size: 12px; font-weight: 600; padding: 2px 7px;
  border-radius: 4px; background: rgb(0 0 0 / 0.78); color: #fff; line-height: 1.5;
}
.stamp {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-4deg);
  font-weight: 800; font-size: 26px; letter-spacing: 0.04em; padding: 6px 16px; background: var(--brand);
  color: var(--on-brand); border: 3px solid var(--extrude); box-shadow: 5px 5px 0 var(--extrude); white-space: nowrap;
}

.body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.title { margin: 0; font-size: 17px; line-height: 1.35; font-weight: 600; text-wrap: balance; overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.sect { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat { display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: 6px; background: var(--sunk); font-size: 13px; line-height: 1.25; min-width: 0; }
.cat img { width: 24px; height: 32px; border-radius: 3px; display: block; flex: none; object-fit: cover; }
.cat-no-art { width: 24px; height: 32px; border-radius: 3px; flex: none; background: var(--cat-chat); }
.cat b { font-weight: 600; }
.cat small { color: var(--muted); font-size: 11px; display: block; }

.foot { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.meter { height: 10px; border-radius: 5px; background: var(--sunk); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--bar); opacity: 0.55; transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
.lead .meter > span, .won .meter > span { background: var(--brand); opacity: 1; }
.tally { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.tally b { font-size: 22px; color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.lead-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand-strong); }
.actions { display: flex; }
.actions .btn { flex: 1; padding-block: 11px; font-size: 15px; }

/* ---------- no vote ---------- */
.idle { background: var(--surface); border: 2px dashed var(--line); border-radius: 10px; padding: 28px 24px; max-width: 760px; margin: 0 auto; }
.idle h2 { margin: 0 0 6px; font-size: 22px; text-wrap: balance; }
.idle p { margin: 0; color: var(--muted); max-width: 60ch; }

/* ---------- sign-in dialog ---------- */
.dialog {
  border: 2px solid var(--extrude); border-radius: 10px; background: var(--surface); color: var(--ink);
  box-shadow: 8px 8px 0 var(--extrude); font-family: "IBM Plex Sans KR", "Segoe UI", system-ui, sans-serif;
}
.dialog-body { display: flex; flex-direction: column; gap: 16px; }
.dialog-body h2 { margin: 0; font-size: 20px; line-height: 1.25; text-wrap: balance; }
.dialog-body p { margin: 0; color: var(--muted); }
.perm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 480px) { .perm { grid-template-columns: minmax(0, 1fr); } }
.perm div { background: var(--sunk); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.perm h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.perm ul { margin: 0; padding-left: 18px; line-height: 1.6; }
.perm-yes h3 { color: var(--brand-strong); }
.perm-no h3 { color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 640px) {
  .on-air-row { grid-template-columns: 84px minmax(0, 1fr); }
  .on-air-thumb { width: 84px; }
  .on-air-end { grid-column: 1 / -1; text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .on-air-end b { display: inline; font-size: 15px; }
  .clock-time { font-size: 32px; }
  .vote-head p { display: none; }
  .logo { height: 22px; }
  .long-label { display: none; }
}
@media (min-width: 641px) { .short-label { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- native pieces the Next version borrowed from the dashboard ---------- */
dialog.dialog { padding: 22px; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
dialog.dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.lang { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.lang button { font: inherit; font-size: 12px; font-weight: 600; padding: 4px 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--sunk); color: var(--ink); }

/* A phone has room for the logo, the toggle and one more thing: the avatar and sign-out
   stay, the name goes. */
.lang { flex: none; }
.sign-out { white-space: nowrap; }
@media (max-width: 640px) {
  .top-row { gap: 10px; }
  .user-name { display: none; }
}
