/* ==========================================================================
   Eleições — the preview and diff harness

   Chrome for looking at the templates. None of this ships: the graphic is the
   `.el-stage` inside, and everything here lives outside it.
   ========================================================================== */

:root {
  --ui-bg:     #14161a;
  --ui-panel:  #1c1f25;
  --ui-line:   #2c313a;
  --ui-text:   #e7e9ee;
  --ui-dim:    #9aa2b1;
  --ui-accent: #F0D233;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font: 13px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* --- toolbar --------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--ui-panel);
  border-bottom: 1px solid var(--ui-line);
}

.bar__group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar__label {
  color: var(--ui-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.bar select,
.bar input[type="number"] {
  background: #0f1115;
  color: var(--ui-text);
  border: 1px solid var(--ui-line);
  border-radius: 4px;
  padding: 5px 8px;
  font: inherit;
}

.bar input[type="range"] { width: 130px; accent-color: var(--ui-accent); }

.seg { display: flex; border: 1px solid var(--ui-line); border-radius: 4px; overflow: hidden; }

.seg button {
  background: #0f1115;
  color: var(--ui-dim);
  border: 0;
  border-right: 1px solid var(--ui-line);
  padding: 6px 11px;
  font: inherit;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ui-accent); color: #14161a; }

.bar__readout {
  margin-left: auto;
  color: var(--ui-dim);
  white-space: pre;
}
.bar__readout b { color: var(--ui-text); font-weight: 400; }

/* --- the stack ------------------------------------------------------------- */

.viewport {
  position: relative;
  overflow: auto;
  padding: 20px;
}

.stack {
  position: relative;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  /* Checkerboard so a hole in either layer is obvious. */
  background:
    repeating-conic-gradient(#22252b 0% 25%, #1a1d22 0% 50%) 0 0 / 24px 24px;
}

/* The boost only means anything against a difference, and applying it in the
   other modes just makes the render look wrong. */
.stack[data-mode="diff"] { filter: brightness(var(--boost, 1)); }

/* Both layers occupy the same 1920x1080 and never scale independently — the
   whole point is that they cancel. */
.stack > .layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
}

.layer--live .el-stage { transform: none; }
.layer--live .el-frame { width: 1920px; height: 1080px; }

.layer--ref {
  transform: translate(var(--dx, 0px), var(--dy, 0px));
  image-rendering: pixelated;
}
.layer--ref img { display: block; width: 1920px; height: 1080px; }

/* modes ------------------------------------------------------------------- */

.stack[data-mode="live"]  .layer--ref  { display: none; }
.stack[data-mode="ref"]   .layer--live { visibility: hidden; }

.stack[data-mode="onion"] .layer--ref  { opacity: var(--ref-opacity, 0.5); }

.stack[data-mode="diff"]  .layer--ref  { mix-blend-mode: difference; }

.stack[data-mode="swipe"] .layer--ref  {
  clip-path: inset(0 0 0 var(--swipe, 50%));
}

.stack[data-mode="swipe"]::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--swipe, 50%);
  width: 2px;
  background: var(--ui-accent);
  pointer-events: none;
}

/* crosshair --------------------------------------------------------------- */

.stack[data-cross="on"] .cross-v,
.stack[data-cross="on"] .cross-h { display: block; }

.cross-v, .cross-h {
  display: none;
  position: absolute;
  background: rgba(240, 210, 51, 0.65);
  pointer-events: none;
  z-index: 5;
}
.cross-v { top: 0; bottom: 0; width: 1px; }
.cross-h { left: 0; right: 0; height: 1px; }

/* --- side by side ---------------------------------------------------------- */

.pair { display: none; gap: 20px; padding: 20px; }
body[data-mode="side"] .pair { display: flex; }
body[data-mode="side"] .viewport { display: none; }

.pair figure { margin: 0; }
.pair figcaption {
  color: var(--ui-dim);
  padding: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}
.pair img { display: block; }

/* --- gallery (index.html) -------------------------------------------------- */

/* `minmax(0, 1fr)` and `min-width: 0` stop the 1920px stage inside from
   widening its own container — without them the fit measurement reads the
   stage it is trying to fit and settles at 100% forever. */
.gallery {
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
}

.card { min-width: 0; }
.card__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 0 8px;
}
.card__title { font-size: 14px; }
.card__note { color: var(--ui-dim); }
.bar__home {
  color: var(--ui-dim);
  text-decoration: none;
  margin-inline-end: 10px;
}
.bar__home:hover { color: var(--ui-text); }

.card__link { color: var(--ui-accent); text-decoration: none; margin-left: auto; }
.card__link:hover { text-decoration: underline; }

.note {
  padding: 10px 16px;
  color: var(--ui-dim);
  border-bottom: 1px solid var(--ui-line);
}
.note b { color: var(--ui-text); font-weight: 400; }

/* --- the package downloads -------------------------------------------------
   Shown only when the zips are published beside the page; see index.html.
   -------------------------------------------------------------------------- */

.dl { display: flex; flex-wrap: wrap; gap: 6px; }

.dl__item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--ui-line);
  border-radius: 4px;
  background: #0f1115;
  color: var(--ui-text);
  text-decoration: none;
  white-space: nowrap;
}

.dl__item:hover { border-color: var(--ui-accent); color: var(--ui-accent); }
.dl__item b { color: var(--ui-dim); font-weight: 400; }
.dl__item:hover b { color: inherit; }
