/* Hora de Votar, inside the jncoe.github.io shell (sidebar, mobile header, theme toggle).
   The site stylesheets provide the chrome and the surface/text tokens; everything here is
   scoped to .hdv so it never leaks into the shared layout.
   Data colors come from the urna keypad: CONFIRMA green for votes, CORRIGE orange for after closing. */
.hdv {
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --card: var(--bg-surface-alt, #fbfcfa);
  --grid: rgba(0, 0, 0, 0.1);
  --text-muted: #686c72;
  --accent: #1d8a4e;
  --accent-wash: rgba(29, 138, 78, 0.12);
  --late: #e0661f;
  --late-wash: rgba(224, 102, 31, 0.14);
  --screen: #1f2a22;
  --screen-text: #d8f0dc;
  --radius: var(--radius-lg, 12px);
  --gutter: var(--space-xl, 32px);

  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-primary);
  /* no padding-top: the site layout uses it to clear the fixed mobile header */
  padding-left: var(--gutter);
  padding-right: var(--gutter);
  padding-bottom: var(--space-2xl, 48px);
}
[data-theme="dark"] .hdv {
  --grid: rgba(255, 255, 255, 0.1);
  --text-muted: #9a9ca3;
  --accent: #34b06a;
  --accent-wash: rgba(52, 176, 106, 0.16);
  --late: #e87a3a;
  --late-wash: rgba(232, 122, 58, 0.18);
  --screen: #0b0f0c;
  --screen-text: #c9ebcf;
}
.hdv > * { max-width: 1040px; margin-left: auto; margin-right: auto; }

/* undo the site's generous defaults for headings, paragraphs and lists inside the page */
.hdv h1, .hdv h2, .hdv h3 { text-wrap: balance; margin: 0; }
.hdv p { margin: 0; line-height: 1.55; }
.hdv ul, .hdv ol { margin: 0; }
.hdv li { margin: 0; }
.hdv code { font-family: var(--font-mono); font-size: 0.85em; padding: 1px 5px; background: var(--grid); border-radius: 4px; }
.hdv a { color: var(--color-primary, #5393ce); text-decoration: underline; text-underline-offset: 2px; }
.hdv h3 { font-family: var(--font-body); font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--text-muted); font-size: 0.9rem; }

/* hero */
.hdv-hero { padding: var(--space-2xl, 48px) 0 var(--space-lg, 24px); }
.eyebrow { color: var(--text-secondary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.hdv-hero h1 {
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.01em;
  font-size: clamp(2.8rem, 8vw, 4.6rem); line-height: 0.95; margin: 0 0 12px;
  background: var(--gradient-main, none); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; width: fit-content;
}
.lede { color: var(--text-secondary); max-width: 62ch; font-size: 1.05rem; }
/* real log excerpts: kept byte for byte, so they scroll sideways inside their box */
.logline { font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.6; color: var(--text-secondary); background: var(--bg-body, var(--card)); border: 1px solid var(--grid); border-radius: 6px; padding: 8px 10px; margin: 0; overflow-x: auto; white-space: pre; tab-size: 4; }
.logline b { color: var(--accent); font-weight: 600; }

/* sections */
.hdv-section { padding-top: var(--space-xl, 32px); scroll-margin-top: calc(var(--dock-h, 0px) + 8px); }
.hdv-section > h2 {
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  font-size: 2.2rem; line-height: 1; letter-spacing: 0.01em; margin-bottom: 8px;
}
.hdv-section > .intro { margin-bottom: 16px; max-width: 70ch; }

.card, .player {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card, none);
  padding: 20px;
  margin: 0 0 16px;
}
.hdv figure { margin: 0 0 16px; }
.hdv figcaption { margin-bottom: 12px; }

/* the urna "display": always dark, in both themes */
.player { background: var(--screen); border-color: var(--screen); color: var(--screen-text); }
.player .muted { color: color-mix(in srgb, var(--screen-text) 62%, transparent); }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px 32px; }
.count { display: flex; flex-direction: column; min-width: 0; }
.count-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: color-mix(in srgb, var(--screen-text) 62%, transparent); }
.count-label b { color: var(--screen-text); font-family: var(--font-mono); font-weight: 500; letter-spacing: 0; }
.count-late .hero { color: var(--late); }
.hero { font-family: var(--font-display); font-size: clamp(2.6rem, 9vw, 4.6rem); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.05; }
.delta { margin-top: 14px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--screen-text) 15%, transparent); }
.late-flag { color: var(--late); font-weight: 600; }

/* the clock: an urna "display" stuck to the top of the screen (below the site's mobile header) */
.hdv > .dock {
  position: sticky; top: 0; z-index: var(--z-sticky, 200);
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "play clock track scope";
  align-items: center; gap: 6px 16px;
  margin-bottom: 8px; padding: 10px 18px 4px;
  background: var(--screen); color: var(--screen-text);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.dock .clock { grid-area: clock; display: flex; flex-direction: column; line-height: 1.1; padding-bottom: 6px; }
.dock #clock { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 500; }
.dock .clock small { font-size: 0.75rem; white-space: nowrap; color: color-mix(in srgb, var(--screen-text) 62%, transparent); font-variant-numeric: tabular-nums; }
.dock-track { grid-area: track; min-width: 0; }
.dock .scope { grid-area: scope; margin: 0 0 6px; }
#play {
  grid-area: play; margin-bottom: 6px;
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff;
  font-size: 1rem; cursor: pointer;
}
#play:hover { filter: brightness(1.1); }
#play:focus-visible, .dock input[type=range]:focus-visible { outline: 2px solid var(--screen-text); outline-offset: 2px; }
.dock input[type=range] { display: block; width: 100%; margin: 0; accent-color: var(--accent); height: 28px; }
.ticks { position: relative; height: 16px; margin: 0 8px; font-size: 0.7rem; color: color-mix(in srgb, var(--screen-text) 62%, transparent); }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

.scope { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: color-mix(in srgb, var(--screen-text) 12%, transparent); }
.scope button {
  border: 0; border-radius: 999px; padding: 6px 12px; white-space: nowrap; cursor: pointer;
  font: 600 0.85rem var(--font-body); background: transparent;
  color: color-mix(in srgb, var(--screen-text) 70%, transparent);
}
.scope button[aria-pressed="true"] { background: var(--screen-text); color: var(--screen); }
.scope button:focus-visible { outline: 2px solid var(--screen-text); outline-offset: 2px; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: var(--font-body); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--bg-surface-alt, #fff); color: var(--text-primary);
  border: 1px solid var(--grid); border-radius: 6px; padding: 6px 8px; font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12); white-space: nowrap; transform: translate(-50%, -110%);
}

.bars { display: grid; grid-template-columns: 2.4em 1fr auto; gap: 4px 10px; align-items: center; font-size: 0.85rem; }
.bars .track { height: 14px; position: relative; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 1px; transition: width 0.12s linear; }
.bars .val { font-variant-numeric: tabular-nums; color: var(--text-secondary); text-align: right; min-width: 7ch; }

/* the size of "after 17h": two shares side by side, then the 15-min periods */
.share { display: grid; gap: 22px; }
.share-head { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 8px; }
.share-num { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; line-height: 1; color: var(--late); font-variant-numeric: tabular-nums; }
.share-text { max-width: 52ch; }
.share-bar { height: 14px; border-radius: 4px; background: var(--accent-wash); overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--late); }
.share-take { color: var(--text-secondary); border-top: 1px solid var(--grid); padding-top: 14px; }
.periods td.bar-cell { white-space: nowrap; }
.periods .bar-cell > span:first-child { display: inline-block; min-width: 6.5ch; text-align: right; }
.periods .mini { display: inline-block; vertical-align: middle; width: 110px; height: 10px; margin-left: 10px; }
.periods .mini i { display: block; height: 100%; background: var(--late); border-radius: 0 3px 3px 0; }


/* "Depois das 17h" tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--grid); border-radius: var(--radius); box-shadow: var(--shadow-card, none); padding: 16px; }
.tile .label { color: var(--text-secondary); font-size: 0.85rem; }
.tile .value { font-family: var(--font-display); font-size: 2.3rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .note { color: var(--text-muted); font-size: 0.8rem; }
.tile-late .value { color: var(--late); }
.hist-bar { transition: opacity 0.15s; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 .card { margin: 0; }
.grid2 .col { display: grid; gap: 16px; align-content: start; }

/* tables */
.table-wrap { overflow-x: auto; }
.hdv table { border-collapse: collapse; width: 100%; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.hdv th, .hdv td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.hdv th { color: var(--text-secondary); font-weight: 600; }
.hdv td.num, .hdv th.num { text-align: right; }
.hdv td.wrap { white-space: normal; min-width: 14ch; }
.hdv tr.total td { font-weight: 700; border-bottom: 0; }
th .sort {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; color: inherit; border-radius: 4px;
}
th .sort:focus-visible { outline: 2px solid var(--color-primary, #5393ce); outline-offset: 2px; }
th .sort::after { content: "↕"; font-size: 0.8em; opacity: 0.4; }
th[aria-sort="ascending"] .sort::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .sort::after { content: "↓"; opacity: 1; }
th.num .sort { flex-direction: row-reverse; }

/* methodology steps */
.steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: 12px; margin-bottom: 16px; }
.steps li {
  counter-increment: step; position: relative;
  background: var(--card); border: 1px solid var(--grid); border-radius: var(--radius);
  box-shadow: var(--shadow-card, none); padding: 16px 20px 16px 64px;
}
.steps li::before {
  content: counter(step); position: absolute; left: 18px; top: 14px;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font: 700 1.1rem var(--font-display);
}
.steps p { color: var(--text-secondary); max-width: 75ch; }

/* FAQ */
.faq { display: grid; gap: 8px; }
.faq details { background: var(--card); border: 1px solid var(--grid); border-radius: var(--radius); box-shadow: var(--shadow-card, none); }
.faq summary {
  cursor: pointer; list-style: none; padding: 14px 44px 14px 18px; position: relative;
  font-weight: 600; font-size: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  font: 600 1.3rem var(--font-mono); color: var(--text-muted);
}
.faq details[open] summary::after { content: "−"; }
.faq summary:focus-visible { outline: 2px solid var(--color-primary, #5393ce); outline-offset: -2px; border-radius: var(--radius); }
.faq .answer { padding: 0 18px 16px; color: var(--text-secondary); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; max-width: 80ch; }
.faq details { scroll-margin-top: calc(var(--dock-h, 0px) + 8px); }
.faq .answer ul { padding-left: 20px; display: grid; gap: 6px; }
.faq .src { font-size: 0.8rem; color: var(--text-muted); }
.hdv table.compact { max-width: 520px; }

.hdv-footer { text-align: center; padding-top: var(--space-xl, 32px); }

@media (max-width: 1024px) {
  .hdv > .dock { top: var(--mobile-header-height, 64px); }
  .hdv-section, .faq details { scroll-margin-top: calc(var(--mobile-header-height, 64px) + var(--dock-h, 0px) + 8px); }
}
@media (max-width: 768px) {
  .hdv { --gutter: 16px; }
  .hdv-hero { padding-top: 24px; }
}
@media (max-width: 640px) {
  /* phones: play, time and toggle on one line, the slider full width below; edge to edge */
  .hdv > .dock {
    grid-template-columns: auto 1fr auto; grid-template-areas: "play clock scope" "track track track";
    gap: 4px 12px; margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter));
    padding: 8px var(--gutter) 2px; border-radius: 0;
  }
  .dock #play, .dock .clock, .dock .scope { margin-bottom: 0; padding-bottom: 0; }
  .dock #play { width: 38px; height: 38px; }
  .dock #clock { font-size: 1.35rem; }
  .scope button { padding: 6px 10px; font-size: 0.8rem; }
  .periods .mini { width: 56px; margin-left: 6px; }
}
@media (max-width: 560px) {
  .card, .player { padding: 16px; }
  .steps li { padding-left: 56px; }
  .steps li::before { left: 14px; }
}
@media (prefers-reduced-motion: reduce) { .bars .fill, .hist-bar { transition: none; } }
