/* Colinha do Juliano Lopes 20789 — estrutura comum às três versões.
   O tema (theme.css) redefine tokens e desenha o topo. */
:root {
  /* paleta do kit "LOGO + ELEMENTOS JL 2026" */
  --marinho: #005d8a;
  --marinho-escuro: #00314a;
  --azul: #0097d1;
  --amarelo: #ffcf00;
  --limao: #aae800;
  --laranja: #ff6b00;

  --surface: #ffffff;
  --surface-alt: #eef4f7;
  --line: #cfe3ee;
  --line-strong: #7d98a8;
  --ink: #0b2a3d;
  --ink-muted: #4d6675;
  --erro: #b42318;

  /* papéis — cada versão ajusta */
  --page: #ffffff;
  --on-page: var(--ink);
  --page-muted: var(--ink-muted);
  --bar: var(--marinho);
  --on-bar: #ffffff;
  --primary: var(--amarelo);
  --on-primary: var(--marinho-escuro);
  --primary-edge: var(--marinho-escuro);
  --secondary: var(--marinho);
  --on-secondary: #ffffff;
  --ballot-edge: var(--marinho);
  --ballot-shadow: var(--azul);
  --ballot-head: var(--marinho);
  --on-ballot-head: #ffffff;
  --cargo: var(--azul);
  --fix-row: #fff8d6;
  --fix-box: var(--amarelo);
  --on-fix-box: var(--marinho);
  --fix-edge: var(--marinho);
  --photo-edge: var(--azul);
  --foot: var(--marinho-escuro);
  --on-foot: #ffffff;

  --shadow-float: 0 12px 32px -4px #00314a40;
  --focus-ring: 0 0 0 2px #ffffff, 0 0 0 5px var(--marinho-escuro);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  --font-display: "Anton", Impact, "Arial Narrow", sans-serif;
  --font-cond: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--foot); }
body {
  margin: 0; min-width: 320px;
  font: 400 16px/24px var(--font-sans);
  color: var(--on-page); background: var(--page);
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus-ring); }
.wrap { width: min(100% - 32px, 1120px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- barra do topo ---------- */
.topbar { background: var(--bar); color: var(--on-bar); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.topbar-brand { display: flex; align-items: center; gap: 10px; font: 700 16px/20px var(--font-cond); letter-spacing: .04em; text-transform: uppercase; }
.chip-num {
  font: 400 22px/1 var(--font-display); letter-spacing: .01em;
  background: var(--amarelo); color: var(--marinho);
  padding: 6px 10px 5px; border-radius: var(--radius-sm);
}
.topbar a { color: var(--on-bar); font: 700 15px/1 var(--font-cond); letter-spacing: .04em; text-transform: uppercase; text-decoration: none; border: 2px solid currentColor; border-radius: var(--radius-full); padding: 8px 14px; opacity: .9; }
.topbar a:hover { opacity: 1; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 19px/20px var(--font-cond); letter-spacing: .03em; text-transform: uppercase;
  min-height: 52px; padding: 0 24px;
  border-radius: var(--radius-full); border: 2px solid transparent; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary-edge); box-shadow: 4px 4px 0 var(--primary-edge); }
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--primary-edge); }
.btn-primary:active { transform: translate(4px, 4px); box-shadow: none; }
.btn-secondary { background: var(--secondary); color: var(--on-secondary); }
.btn-secondary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn:disabled { opacity: .45; cursor: wait; transform: none; }
.btn-full { width: 100%; }
.arrow { font-size: 20px; }

/* ---------- montagem ---------- */
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }

.ballot {
  background: var(--surface); color: var(--ink); border: 3px solid var(--ballot-edge); border-radius: var(--radius-lg);
  box-shadow: 7px 7px 0 var(--ballot-shadow); overflow: hidden;
}
.ballot-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; background: var(--ballot-head); color: var(--on-ballot-head); }
.ballot-title { font: 400 26px/30px var(--font-display); letter-spacing: .01em; text-transform: uppercase; }
.ballot-year { font: 700 15px/1 var(--font-cond); letter-spacing: .12em; }

.row {
  position: relative;
  display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; column-gap: 16px; row-gap: 8px;
  align-items: center; padding: 14px 20px; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row.fixed { background: var(--fix-row); }
.row-photo {
  --cols: 1; --rows: 1; --tx: 0; --ty: 0;
  grid-row: 1 / span 2; width: 72px; height: 72px; border-radius: var(--radius-md); overflow: hidden;
  background: var(--surface-alt) center / cover no-repeat; border: 2px solid var(--line);
  display: grid; place-items: center; color: var(--line-strong);
}
.row-photo.sprite {
  background-size: calc(var(--cols) * 100%) calc(var(--rows) * 100%);
  background-position: calc(var(--tx) / max(var(--cols) - 1, 1) * 100%) calc(var(--ty) / max(var(--rows) - 1, 1) * 100%);
}
.row-photo.has-photo { border-color: var(--photo-edge); }
.row-photo.has-photo svg { display: none; }
.row-info { min-width: 0; }
.row-cargo { display: block; font: 700 15px/18px var(--font-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--cargo); }
.row-name { display: block; min-height: 26px; font: 700 22px/26px var(--font-cond); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name.placeholder { color: var(--ink-muted); font: 500 18px/26px var(--font-cond); }
.row-meta { display: block; min-height: 18px; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.row-meta.warn { color: var(--erro); font-weight: 700; }
.row-meta.lock { color: var(--marinho); font-weight: 700; }
.digits { display: flex; gap: 6px; }
.digit {
  width: 44px; height: 56px; padding: 0; text-align: center;
  font: 400 34px/1 var(--font-display); color: var(--ink);
  background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--radius-sm);
  caret-color: var(--azul); -moz-appearance: textfield;
}
.digit:focus { outline: 2px solid transparent; border-color: var(--marinho); box-shadow: var(--focus-ring); }
.row[data-invalid] .digit { border-color: var(--erro); }
.row.fixed .digit { background: var(--fix-box); color: var(--on-fix-box); border: 3px solid var(--fix-edge); }
.form-message { margin: 16px 0; padding: 10px 14px; border-radius: var(--radius-md); background: #ffffff; color: #b42318; font-weight: 700; border: 2px solid #b42318; }
.form-message:empty { display: none; }
#generate { margin-top: 20px; }
.form-message:not(:empty) + #generate { margin-top: 0; }

.aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.note { background: #ffffff; color: var(--ink); border: 3px solid var(--ballot-edge); border-radius: var(--radius-lg); padding: 16px; display: flex; gap: 12px; }
.note svg { flex: none; color: var(--azul); margin-top: 2px; }
.note p { margin: 0; }
.note strong { display: block; font: 700 21px/24px var(--font-cond); text-transform: uppercase; letter-spacing: .02em; color: var(--marinho); margin-bottom: 4px; }
.notice { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 13px; line-height: 18px; color: var(--page-muted); font-weight: 500; }
.notice svg { flex: none; margin-top: 1px; }
#data-source { min-height: 18px; }

/* ---------- rodapé ---------- */
footer { background: var(--foot); color: var(--on-foot); padding-block: 32px; font-size: 13px; line-height: 18px; }
footer p { margin: 0 0 8px; }
footer .legal { font: 700 14px/18px var(--font-cond); letter-spacing: .06em; }
footer .small { opacity: .85; }
footer a { color: var(--on-foot); }

/* ---------- janelas ---------- */
dialog {
  width: min(100% - 24px, 460px); max-height: calc(100dvh - 24px); padding: 20px; border: 3px solid var(--marinho);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-float);
}
dialog::backdrop { background: #00314acc; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font: 400 30px/34px var(--font-display); text-transform: uppercase; color: var(--marinho); }
.modal-close { width: 44px; height: 44px; flex: none; border-radius: var(--radius-full); border: 2px solid var(--line-strong); background: transparent; font-size: 24px; line-height: 1; }
.result-stage { display: grid; place-items: center; background: var(--surface-alt); border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px; }
.result-stage img { max-height: 52dvh; width: auto; border-radius: 6px; box-shadow: 0 4px 16px #0003; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-actions .btn-primary { grid-column: 1 / -1; }
.result-secondary { display: flex; gap: 8px; margin-top: 8px; }
.result-secondary .btn { flex: 1; min-height: 40px; font-size: 16px; padding: 0 12px; }
.status { min-height: 20px; margin: 8px 0 0; font-size: 13px; color: var(--ink-muted); text-align: center; }
#manual-copy input { width: 100%; margin-top: 6px; padding: 10px; border: 2px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); }
.models { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.model {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 6px 12px;
  border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--surface);
}
.model[aria-pressed="true"] { border-color: var(--marinho); box-shadow: 4px 4px 0 var(--marinho); }
.model-swatch { width: 100%; aspect-ratio: 5 / 9; border-radius: 6px; border: 1px solid var(--line-strong); display: grid; place-items: center; }
.model-swatch i { width: 70%; height: 60%; background: #fff; border-radius: 4px; border: 1px solid var(--marinho); }
.model b { font: 700 17px/1 var(--font-cond); text-transform: uppercase; }
.model small { font-size: 12px; color: var(--ink-muted); line-height: 14px; text-align: center; }

#print-art { display: none; }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .builder-grid { grid-template-columns: 1fr; }
  .aside { position: static; }
}
@media (max-width: 720px) {
  .row { grid-template-columns: 64px minmax(0, 1fr); padding: 12px 16px; column-gap: 12px; }
  .row-photo { width: 64px; height: 64px; }
  .row .digits { grid-column: 2; gap: 6px; }
  .digit { width: 40px; height: 52px; font-size: 30px; }
  .row-name { font-size: 20px; line-height: 24px; }
  .topbar-brand span:last-child { font-size: 14px; }
}
@media (max-width: 360px) {
  .row .digits { gap: 4px; }
  .digit { width: 34px; height: 46px; font-size: 26px; }
  .topbar a { display: none; }
}

@media print {
  @page { size: 5cm 9cm; margin: 0; }
  body > *:not(#print-art) { display: none !important; }
  html, body { background: #fff; }
  #print-art { display: block; }
  #print-art img { width: 5cm; height: 9cm; }
}

/* foto do Juliano já no primeiro desenho, antes do script */
.row[data-office="e"] .row-photo { background-image: url("img/juliano-168.webp"); border-color: var(--photo-edge); }
.row[data-office="e"] .row-photo svg { display: none; }
