/* Specific to the comparator. Color tokens, typography, the header, the
   footer and the column width come from ../assets/site.css, loaded before
   this file: whatever must stay identical across tools is not redeclared
   here. */
:root {
  --red: #d1495b;
  --red-bg: #fbe4e6;
  --green: #2f8f5b;
  --green-bg: #e2f3e8;
  --danger-bg: #fbe4e6;
  --danger-ink: #8a2a37;
}
@media (prefers-color-scheme: dark) {
  :root {
    --red: #e58a94;
    --red-bg: #3e2429;
    --green: #7fcf9f;
    --green-bg: #1f3a2b;
    --danger-bg: #3e2429;
    --danger-ink: #f2b6bd;
  }
}

.dropzones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 28px 0 18px;
}
@media (max-width: 560px) { .dropzones { grid-template-columns: 1fr; } }

.dropzone {
  background: var(--paper-raised);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  position: relative;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .role {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 10px;
}
.dropzone .icon { font-size: 22px; margin-bottom: 6px; opacity: 0.6; }
.dropzone .fname {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--ink);
  word-break: break-word;
  margin-top: 4px;
}
.dropzone .hint { font-size: 12.5px; color: var(--ink-soft); }
.dropzone input { display: none; }
.dropzone.filled { border-style: solid; border-color: var(--accent); }

.actions { display: flex; align-items: center; gap: 12px; margin: 22px 0 4px; flex-wrap: wrap; }
.actions .spacer { flex: 1; }
button {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
#compareBtn { background: var(--accent); color: #fff; }
#compareBtn:hover:not(:disabled) { opacity: 0.9; }
#downloadBtn { background: var(--ink); color: var(--paper); }
#downloadBtn:hover:not(:disabled) { opacity: 0.85; }

#status {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  color: var(--ink-soft);
  min-height: 18px;
}

.progress-track {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 0;
  display: none;
}
.progress-track.on { display: block; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }

details.advanced {
  margin: 18px 0 6px;
  font-size: 13.5px;
}
details.advanced summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--ink-soft); }
.field input[type="number"] {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
.field .unit { font-size: 11px; color: var(--ink-soft); }
/* The checkbox sits on the same baseline grid as the number fields: label on
   top would leave it floating alone in its cell. */
.field.check { justify-content: flex-end; gap: 6px; }
.field.check label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}
.field.check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Margin preview: page 1 of one of the two PDFs, with the two ignored strips
   drawn over it. The strips and the two percentage fields above are two views
   of the same numbers — dragging writes back into the fields, typing in the
   fields moves the strips.
   The band colors are not themed: whatever the page theme, the rendered PDF
   underneath is white paper, so the tint that reads well on it is the same in
   light and dark. */
.preview {
  display: none;
  grid-column: 1 / -1;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  --band: rgba(209, 73, 91, 0.16);
  --band-line: #d1495b;
  --band-ink: #8a2a37;
}
.preview.on { display: block; }
.preview-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.preview-bar .preview-label { flex: 1; font-size: 12px; color: var(--ink-soft); }
.preview button, .out-preview button {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 400;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink-soft);
}
.preview button:disabled, .out-preview button:disabled { opacity: 0.4; }
.side-switch { display: inline-flex; gap: 4px; }
.side-switch button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
}
.pager button { padding: 2px 8px; }

.stage { position: relative; width: 100%; max-width: 300px; margin: 14px auto 0; line-height: 0; }
.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.band { position: absolute; left: 0; right: 0; background: var(--band); pointer-events: none; }
.band-top { top: 0; }
.band-bottom { bottom: 0; }
.band span {
  position: absolute;
  right: 5px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--band-ink);
}
.band-top span { bottom: 1px; }
.band-bottom span { top: 1px; }

/* The grip is wider than the page and taller than its visible line: the hit
   area stays comfortable on a touch screen without a thick rule on the page. */
.grip {
  position: absolute;
  left: -8px;
  right: -8px;
  height: 16px;
  margin-top: -8px;
  cursor: ns-resize;
  touch-action: none;
}
.grip-bottom { margin-top: 0; margin-bottom: -8px; }
.grip::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 7px;
  height: 2px;
  background: var(--band-line);
}
.grip::after {
  content: "";
  position: absolute;
  left: 50%;
  margin-left: -13px;
  top: 4px;
  width: 26px;
  height: 8px;
  border-radius: 4px;
  background: var(--band-line);
}
.grip:hover::after, .grip.dragging::after, .grip:focus-visible::after { background: var(--accent); }
.grip:focus-visible { outline: none; }
.grip:focus-visible::before { background: var(--accent); }

.preview-hint { font-size: 11.5px; line-height: 1.5; color: var(--ink-soft); margin: 12px 0 0; }
/* What the automatic detection found. Empty means it has nothing to say --
   no PDF loaded yet, or the margins are being set by hand. */
.auto-note { font-size: 11.5px; line-height: 1.5; color: var(--ink); margin: 12px 0 0; }
.auto-note:empty { display: none; }

.legend {
  display: flex;
  gap: 18px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 18px;
  flex-wrap: wrap;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.red { background: var(--red-bg); border: 1px solid var(--red); }
.swatch.green { background: var(--green-bg); border: 1px solid var(--green); }

#result {
  display: none;
  margin-top: 26px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
#result.on { display: block; }
#result h2 { font-size: 15px; margin: 0 0 4px; }
#result .stat-row { display: flex; gap: 22px; margin: 14px 0 18px; flex-wrap: wrap; }
#result .stat { font-family: "IBM Plex Mono", monospace; }
#result .stat b { display: block; font-size: 20px; color: var(--ink); }
#result .stat span { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }

/* The generated PDF, shown before it is downloaded. The colour key switch sits
   right under it: the key is the one thing about the output worth changing
   once it exists, and from here the change can be seen rather than imagined.
   Pages are two source pages wide, so this one runs the full column. */
.out-preview { margin: 0 0 20px; }
.out-preview .preview-bar { margin-bottom: 10px; }
.out-stage { line-height: 0; transition: opacity 0.15s ease; }
.out-stage.busy { opacity: 0.4; }
.out-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.out-option { margin-top: 12px; }
.out-option label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}
.out-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.out-option input[type="checkbox"]:disabled { cursor: wait; }
.out-option .unit { display: block; font-size: 11px; line-height: 1.5; color: var(--ink-soft); margin: 4px 0 0 23px; }

.error-box {
  display: none;
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-top: 14px;
}
.error-box.on { display: block; }
