/* BleedCheck: a proofing table. Cool grey work surface, ink-navy header,
   process-ink status colors (teal pass, amber warn, magenta fail). */

:root {
  --ink: #14213d;
  --ink-2: #22355e;
  --surface: #e8ebef;
  --surface-2: #dde1e7;
  --paper: #f8f9fb;
  --line: #c3c9d2;
  --text: #182033;
  --muted: #475266;
  --focus: #2563eb;

  --pass: #00695c;
  --pass-bg: #d4efea;
  --pass-line: #0fa3a3;
  --warn: #8a4b00;
  --warn-bg: #fdeccb;
  --warn-line: #f0a500;
  --fail: #b0004f;
  --fail-bg: #fbdcea;
  --fail-line: #e0006f;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--sans);
  color: var(--text);
  background: var(--surface);
}
h1, h2, h3 { line-height: 1.2; }
a { color: var(--ink-2); text-underline-offset: 2px; }
a:hover { color: var(--fail); }
.mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* ---------- masthead ---------- */
.masthead { background: var(--ink); color: #eef1f6; }
.masthead-inner {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 8px 24px; padding-top: 18px; padding-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; }
.brand:hover { color: #fff; }
.brand:focus-visible { outline-color: #ffc94d; }
.tagline { margin: 0; color: #c9d1e0; }
.promise { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; color: #fff; white-space: nowrap; }
.promise-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pass-line); box-shadow: 0 0 0 3px rgba(15, 163, 163, 0.3); }

main.wrap { padding-top: 28px; padding-bottom: 40px; }
.noscript { padding: 12px 16px; background: var(--fail-bg); color: var(--fail); border-radius: var(--radius); }

.section-label { font-size: 0.95rem; font-weight: 700; text-transform: none; color: var(--ink); margin: 0 0 10px; }

/* ---------- target picker ---------- */
.target { margin-bottom: 20px; }
.target-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; }
.shops { border: 0; margin: 0; padding: 0; min-width: 0; flex: 1 1 520px; }
.shop-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.shop-option {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--paper); cursor: pointer;
}
.shop-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.shop-option:hover { border-color: var(--ink-2); }
.shop-option:has(input:checked) { border-color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--ink); }
.shop-option:has(input:checked) .shop-name::before { content: "● "; color: var(--pass-line); }
.shop-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.shop-name { font-weight: 650; }
.shop-size { color: var(--muted); }

.size-field { display: flex; flex-direction: column; justify-content: center; gap: 4px; flex: 0 1 220px; font-size: 0.9rem; color: var(--muted); }
select {
  font: inherit; font-size: 1rem; color: var(--text);
  padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--paper);
}

.spec-line {
  display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 14px 0 6px;
  padding: 10px 14px; background: var(--paper); border-left: 4px solid var(--ink); border-radius: 0 var(--radius) var(--radius) 0;
}
.spec-item { display: inline-flex; gap: 8px; align-items: baseline; }
.spec-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.shop-note { margin: 0; color: var(--muted); max-width: 80ch; }

/* ---------- drop zone ---------- */
.dropzone {
  position: relative; text-align: center; padding: 44px 24px;
  border: 2px dashed var(--ink-2); border-radius: 12px; background: var(--paper);
  margin-bottom: 24px; transition: background-color 0.15s, border-color 0.15s;
}
.dropzone-over { background: #fff; border-color: var(--pass-line); border-style: solid; }
.drop-title { margin: 0 0 6px; font-size: 1.4rem; color: var(--ink); }
.drop-hint { margin: 0 0 18px; color: var(--muted); }
.drop-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.dropzone-compact { padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; text-align: left; }
.dropzone-compact .drop-title { font-size: 1.05rem; margin: 0; }
.dropzone-compact .drop-hint { display: none; }
.dropzone-compact .inline-error { flex-basis: 100%; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 0.98rem; color: var(--ink);
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius);
  border: 2px solid var(--ink); background: #fff; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--ink-2); }
.btn.quiet { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn.quiet:hover { background: var(--surface-2); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }

.inline-error { color: var(--fail); font-weight: 600; margin: 12px 0 0; }

/* ---------- deck bar ---------- */
.deckbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface); padding: 12px 0 10px; margin-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}
.deckbar-main { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.summary { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.summary-ok { color: var(--pass); }
.deckbar-actions { display: flex; gap: 8px; align-items: center; }
.deckbar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 10px; }
.zip-status { margin: 8px 0 0; color: var(--muted); min-height: 0; }
.zip-status:empty { display: none; }
.zip-status.inline-error { color: var(--fail); }

.segmented { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: #fff; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 14px; font-weight: 600; font-size: 0.92rem; }
.segmented label + label span { border-left: 2px solid var(--ink); }
.segmented input:checked + span { background: var(--ink); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -5px; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.95rem; min-height: 36px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }

/* ---------- grid + tiles ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px;
}
.tile {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 10px 12px 14px; background: var(--paper);
  border: 1px solid var(--line); border-top: 5px solid var(--line); border-radius: var(--radius);
}
.tile-pass { border-top-color: var(--pass-line); }
.tile-warn { border-top-color: var(--warn-line); }
.tile-fail { border-top-color: var(--fail-line); }
.tile-canvas { display: block; width: 100%; height: auto; }
.tile-placeholder {
  aspect-ratio: 300 / 397; display: grid; place-items: center; margin: 8px;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface) 10px 20px);
  color: var(--muted); border-radius: 4px; font-weight: 600;
}
.tile-name { margin: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { margin: 0; color: var(--muted); }
.tile-reason { font-size: 0.93rem; color: var(--text); }
.tile-reason p, p.tile-reason { margin: 0 0 4px; }
.tile-actions { margin-top: auto; padding-top: 6px; }

.chip {
  align-self: flex-start; justify-self: start; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 0.88rem; border: 1px solid;
}
.chip-pass { color: var(--pass); background: var(--pass-bg); border-color: var(--pass-line); }
.chip-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.chip-fail { color: var(--fail); background: var(--fail-bg); border-color: var(--fail-line); }

.unreadable {
  margin-bottom: 16px; padding: 10px 14px; background: var(--fail-bg);
  border-left: 4px solid var(--fail-line); border-radius: 0 var(--radius) var(--radius) 0;
}
.unreadable-title { margin: 0 0 4px; font-size: 0.98rem; color: var(--fail); }
.unreadable-list { list-style: none; margin: 0; padding: 0; }
.unreadable-row { display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; }
.unreadable-row + .unreadable-row { border-top: 1px solid rgba(176, 0, 79, 0.2); }
.unreadable-row p { margin: 0; font-size: 0.93rem; min-width: 0; overflow-wrap: anywhere; }
.unreadable-row .btn { flex: none; color: var(--fail); }

.grid-empty { padding: 24px; text-align: center; color: var(--pass); font-weight: 600; background: var(--paper); border-radius: var(--radius); }

/* ---------- legend + pdf pack ---------- */
.legend { margin-top: 32px; }
.legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 28px; color: var(--muted); }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.legend-list b { color: var(--text); }
.swatch { width: 22px; height: 16px; border-radius: 2px; flex: none; }
.swatch-bleed { background: rgba(20, 33, 61, 0.55); }
.swatch-trim { border: 2px solid var(--ink); background: #fff; }
.swatch-safe { border: 2px dashed var(--fail-line); background: rgba(224, 0, 111, 0.16); }

.pdf-pack {
  margin-top: 28px; padding: 18px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.pdf-pack h2 { font-size: 1.05rem; margin: 0 0 4px; color: var(--ink); }
.pdf-pack p { margin: 0; color: var(--muted); max-width: 62ch; }
.pdf-pack-text { flex: 1 1 320px; }
.pdf-pack .pdf-guide { margin-top: 6px; font-weight: 600; }
.pdf-pack-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.pdf-pack-controls .segmented span { white-space: nowrap; padding-left: 12px; padding-right: 12px; }
.paper-field { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.92rem; }
.paper-field[hidden] { display: none; }
.back-field, .flip-field, .offset-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.back-field[hidden], .flip-field[hidden], .offset-field[hidden] { display: none; }
.offset-input { display: inline-flex; align-items: center; gap: 4px; font-size: 0.9rem; }
.offset-input input {
  width: 4.5em; padding: 5px 6px; font: inherit; font-family: var(--mono); text-align: right;
  border: 2px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink);
}
.offset-input input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--ink); }
.field-label { font-weight: 600; font-size: 0.92rem; }
.back-name { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.back-name b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.back-name.back-warn { color: var(--fail); }
.pdf-status { flex-basis: 100%; }
.pdf-status:empty { display: none; }
.pdf-status.inline-error { color: var(--fail); }

/* ---------- footer ---------- */
.footer { background: var(--surface-2); border-top: 1px solid var(--line); }
.footer-inner { padding-top: 20px; padding-bottom: 28px; color: var(--muted); }
.footer p { margin: 0 0 8px; max-width: 80ch; }
.footer b { color: var(--text); }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }

/* ---------- shop spec pages ---------- */
.spec-page { max-width: 860px; }
.spec-page h1 { font-size: 1.9rem; color: var(--ink); margin: 0 0 8px; }
.spec-page .lede { font-size: 1.1rem; color: var(--muted); margin: 0 0 24px; }
.spec-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: start; }
.spec-table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: var(--radius); overflow: hidden; }
.spec-table th, .spec-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec-table th { width: 38%; font-weight: 600; color: var(--muted); }
.spec-diagram { width: 100%; height: auto; background: var(--paper); border-radius: var(--radius); padding: 8px; }
.spec-page .cta { display: inline-block; margin: 20px 0; text-decoration: none; }
.spec-page .source { color: var(--muted); font-size: 0.92rem; }
.howto-heading { font-size: 1.2rem; color: var(--ink); margin: 28px 0 10px; }
.spec-layout > div > .howto-heading:first-child { margin-top: 0; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 14px 44px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff;
  font: 700 0.95rem/30px var(--mono); text-align: center;
}
.problems { padding-left: 20px; margin: 0 0 16px; }
.problems li { margin-bottom: 8px; }
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
.size-table th, .size-table td { width: auto; font-size: 0.93rem; padding: 8px 10px; }
.size-table td { font-family: var(--mono); white-space: nowrap; }
.size-table thead th { color: var(--muted); font-family: inherit; }
.size-table tbody th { color: var(--text); }
.tile-reason .guide-link { font-weight: 600; }
.link-list { padding-left: 20px; }
.link-list li { margin-bottom: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .masthead-inner { grid-template-columns: 1fr; gap: 6px; }
  .promise { white-space: normal; }
  .shop-options { grid-template-columns: 1fr; gap: 6px; }
  .shop-option { flex-direction: row; justify-content: space-between; align-items: baseline; padding: 9px 12px; }
  .spec-line { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
  .spec-item { display: contents; }
  .spec-line .mono { font-size: 0.86rem; }
  .dropzone-compact .drop-actions { width: 100%; flex-wrap: nowrap; }
  .dropzone-compact .drop-actions .btn { flex: 1; padding: 10px 8px; font-size: 0.92rem; }
  /* A sticky bar would cover a third of a phone screen. */
  .deckbar { position: static; }
  .size-field { flex: 1 1 100%; }
  .dropzone { padding: 28px 16px; }
  .drop-title { font-size: 1.2rem; }
  .summary { font-size: 1.05rem; }
  .deckbar-actions { width: 100%; }
  .deckbar-actions .primary { flex: 1; }
  .deckbar-tools { gap: 4px 14px; }
  /* Cards become rows: preview on the left, verdict beside it. */
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .tile { display: grid; grid-template-columns: 116px minmax(0, 1fr); grid-auto-rows: min-content; column-gap: 12px; row-gap: 4px; padding: 10px; }
  .tile > * { grid-column: 2; }
  .tile > .tile-canvas, .tile > .tile-placeholder { grid-column: 1; grid-row: 1 / span 5; margin: 0; }
  .tile-reason { font-size: 0.9rem; }
  .tile-actions { padding-top: 2px; }
  .spec-layout { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
