/* harpy-poll — palette from the Darwin VS Code theme (same family as diario and ninho-track-player):
   black canvas, near-black panels, magenta as the cursor/accent, teal and cyan as secondary. */

:root {
  --bg: #000000;
  --panel: #0c0d0e;
  --panel-2: #141516;
  --panel-3: #1c1d1e;
  --line: #232425;
  --line-2: #3a3a3a;
  --text: #ffffff;
  --text-2: #cccccc;
  --muted: #777777;
  --magenta: #f90086;
  --teal: #08fbcf;
  --cyan: #54d4ff;
  --yellow: #fff900;
  --orange: #ff9c31;
  --danger: #ec5f67;
  --light-art: #f2f2f2;

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
::selection { background: rgba(8, 251, 207, .45); color: #fff; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(12, 13, 14, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font: 600 1rem var(--mono); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 12px var(--magenta); }

.chip {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); font: 500 .75rem var(--mono); color: var(--text-2);
}
.chip-open { color: var(--teal); border-color: rgba(8, 251, 207, .4); }
.chip-closed { color: var(--muted); }

/* ---------- page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
.page.has-votebar { padding-bottom: calc(110px + var(--safe-b)); }
.page-title { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: 20px; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); font-size: .9rem; }

.error-card { padding: 16px; border: 1px solid rgba(236, 95, 103, .4); border-radius: var(--radius); background: var(--panel); }
.error-card p { color: var(--danger); margin: 4px 0 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text);
  font: 500 .9rem var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-3); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { color: var(--text-2); }
.btn-choose[aria-pressed='true'] { background: var(--magenta); border-color: var(--magenta); color: #fff; font-weight: 600; }
/* "✓ seu voto" is disabled but must read as a state, not as faded. */
.btn-choose[aria-pressed='true']:disabled, .btn-primary.is-chosen:disabled { opacity: 1; }
.btn-primary { background: var(--magenta); border-color: var(--magenta); color: #fff; font-weight: 600; padding-inline: 20px; }
.btn-primary:hover:not(:disabled) { background: #ff2a9b; }
.btn-primary.is-chosen { background: transparent; color: var(--magenta); }
.btn-icon {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 1.1rem; cursor: pointer;
}
.btn-icon:hover { background: var(--panel-3); }

/* ---------- poll list ---------- */
.poll-list { display: grid; gap: 16px; }
.poll-card {
  display: grid; gap: 14px; padding: 16px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.poll-card:hover { text-decoration: none; border-color: var(--line-2); }
.poll-card h2 { font-size: 1.25rem; margin: 6px 0 4px; }
.poll-card p { margin: 0; }
.poll-meta { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.mini-strip { display: flex; gap: 8px; align-items: center; overflow: hidden; }
.mini-strip > .media { flex: none; width: 72px; border-radius: 8px; background: var(--panel-2); }
.mini-more { font: 500 .85rem var(--mono); color: var(--muted); padding-left: 4px; }

/* ---------- poll page ---------- */
.poll-head { display: grid; gap: 10px; margin-bottom: 14px; }
.poll-head h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); }
.poll-desc { margin: 0; color: var(--text-2); white-space: pre-line; max-width: 72ch; }
.source-link { font-size: .9rem; width: fit-content; }
.note {
  margin: 0 0 16px; padding: 8px 12px; max-width: 72ch;
  border-left: 2px solid var(--teal); background: var(--panel); border-radius: 0 8px 8px 0;
  color: var(--text-2); font-size: .85rem;
}
.results-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.card.is-selected { border-color: var(--magenta); box-shadow: 0 0 0 1px var(--magenta), 0 0 28px rgba(249, 0, 134, .22); }
.card-media {
  position: relative; display: block; width: 100%; padding: 14px; border: 0;
  background: var(--panel-2); cursor: zoom-in; color: inherit; font: inherit;
}
.card-media:hover { background: var(--panel-3); }
.badge-num {
  position: absolute; top: 10px; left: 10px; min-width: 30px; height: 30px; padding: 0 8px;
  display: grid; place-items: center; border-radius: 8px;
  background: #000; border: 1px solid var(--line-2); font: 600 .9rem var(--mono); color: var(--text);
}
.badge-num.static { position: static; flex: none; }
.card.is-selected .badge-num { background: var(--magenta); border-color: var(--magenta); }
.badge-count {
  position: absolute; top: 10px; right: 10px; padding: 2px 8px; border-radius: 8px;
  background: rgba(0, 0, 0, .75); font: 500 .75rem var(--mono); color: var(--text-2);
}
.card-body { display: grid; gap: 6px; padding: 12px 14px; flex: 1; align-content: start; }
.card-title { font-size: 1.05rem; font-weight: 600; }
.credits { font-size: .85rem; color: var(--muted); }
.card-desc {
  margin: 0; font-size: .875rem; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-actions { display: flex; gap: 8px; padding: 0 14px 14px; }
.card-actions .btn { flex: 1; }

.meter { position: relative; height: 28px; margin-top: 6px; border-radius: 6px; background: var(--panel-3); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: rgba(84, 212, 255, .28); transition: width .3s; }
.meter.is-leader .meter-fill { background: rgba(8, 251, 207, .35); }
.meter.is-mine .meter-fill { background: rgba(249, 0, 134, .55); }
/* Flex centring: a `font` shorthand would reset any line-height trick back to normal. */
.meter-label { position: relative; display: flex; align-items: center; height: 100%; padding: 0 10px; font: 500 .78rem/1 var(--mono); }

/* ---------- AI-use tag ("tarja") ---------- */
.ai-tag {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content;
  padding: 2px 8px; border-radius: 6px; border: 1px solid;
  font: 600 .72rem/1.5 var(--mono); letter-spacing: .01em; white-space: nowrap;
}
.ai-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ai-no { color: var(--teal); border-color: rgba(8, 251, 207, .45); background: rgba(8, 251, 207, .08); }
.ai-assisted { color: var(--yellow); border-color: rgba(255, 249, 0, .4); background: rgba(255, 249, 0, .07); }
.ai-yes { color: var(--orange); border-color: rgba(255, 156, 49, .5); background: rgba(255, 156, 49, .1); }
.ai-undeclared { color: var(--text-2); border-color: var(--line-2); background: rgba(255, 255, 255, .04); }
/* On cards the tag is a full-width stripe at the bottom of the media. */
.ai-ribbon {
  position: absolute; inset: auto 0 0 0; width: auto; justify-content: center;
  border-width: 1px 0 0; border-radius: 0; padding: 4px 8px; background-color: rgba(0, 0, 0, .85);
}
.card-media { padding-bottom: 40px; }
.ai-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 16px; }
.ai-legend > .muted { flex-basis: 100%; }
.ai-note { flex-basis: 100%; text-align: center; color: var(--muted); }

/* ---------- vote bar ---------- */
.votebar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: rgba(12, 13, 14, .94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.votebar-inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.votebar-text { flex: 1; min-width: 0; display: grid; }
.votebar-choice { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.votebar-flash { font-size: .8rem; color: var(--teal); }
.votebar-flash:empty { display: none; }

/* ---------- media ---------- */
.media { display: grid; place-items: center; width: 100%; }
.media-image { height: var(--box-h); }
.media-thumb { --box-h: 200px; }
.media-mini { --box-h: 72px; padding: 6px; }
.crop {
  position: relative; overflow: hidden;
  aspect-ratio: var(--r, 1);
  width: min(100%, calc(var(--box-h) * var(--r, 1)));
  border-radius: 6px;
  background: var(--panel-3);
}
.is-loaded .crop { background: transparent; }
.media-image:not(.is-loaded) .crop { animation: loading 1s ease-in-out infinite alternate; }
@keyframes loading { from { background: var(--panel-2); } to { background: var(--line-2); } }
@media (prefers-reduced-motion: reduce) { .media-image:not(.is-loaded) .crop { animation: none; } }
.media-image[data-bg='light'] .crop { background: var(--light-art); }
.crop img { position: absolute; display: block; max-width: none; height: auto; user-select: none; opacity: 0; transition: opacity .2s; }
/* The frame only knows its aspect ratio after load; until then the crop would look wrong. */
.is-loaded .crop img { opacity: 1; }

.media-text p { margin: 0; white-space: pre-line; }
.media-text.media-thumb { height: 200px; align-items: start; justify-items: start; text-align: left; padding: 22px 6px 0; color: var(--text-2); }
.media-text.media-thumb p { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.media-text.media-mini { height: 72px; font-size: .55rem; overflow: hidden; color: var(--muted); }
.media-text.media-full { max-width: 70ch; font-size: clamp(1.05rem, 2.5vw, 1.35rem); padding: 16px; overflow: auto; max-height: 100%; }

.media-broken {
  display: grid; gap: 4px; place-items: center; text-align: center; padding: 16px;
  width: 100%; height: 100%; min-height: 120px; border: 1px dashed var(--line-2); border-radius: 8px;
  color: var(--muted); font-size: .85rem;
}
.media-broken strong { color: var(--danger); }

/* ---------- viewer ---------- */
.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #000; color: var(--text);
}
/* minmax(0, 1fr) column: otherwise the option strip's min-content widens the whole dialog on phones. */
.viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
.viewer::backdrop { background: #000; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.viewer-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.viewer-heading { display: grid; min-width: 0; }
.viewer-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-main { position: relative; display: grid; min-height: 0; padding: 12px 64px; touch-action: pan-y; }
.viewer-stage { container-type: size; display: grid; place-items: center; min-height: 0; min-width: 0; }
.media-full { --box-h: 100cqh; }
.media-full .crop { border-radius: 4px; }
.nav {
  position: absolute; top: 50%; translate: 0 -50%; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2);
  background: rgba(20, 21, 22, .85); color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.nav:hover { border-color: var(--text); }
.nav-prev { left: 10px; }
.nav-next { right: 10px; }
.viewer-caption { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; padding: 8px 16px; font-size: .85rem; color: var(--text-2); }
.viewer-bottom {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--panel);
}
.viewer-strip { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: thin; }
.strip-btn {
  flex: none; width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2); font: 600 .9rem var(--mono);
}
.strip-btn[aria-current='true'] { border-color: var(--text); color: var(--text); background: var(--panel-3); }
.strip-btn.is-chosen { background: var(--magenta); border-color: var(--magenta); color: #fff; }

@media (max-width: 640px) {
  .viewer-main { padding: 8px; }
  .nav { top: auto; bottom: 14px; translate: none; width: 40px; height: 40px; }
  .viewer-bottom { flex-wrap: wrap; }
  .viewer-bottom .btn-primary { width: 100%; }
  .media-thumb { --box-h: 180px; }
}

.order-note { margin: 28px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; max-width: 72ch; }
