/* Layout and components: design/source/MakePdfScanPrototype.dc.html */
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
*:focus { outline: none; }
*:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
/* ?frame=1: screenshot mode like a design frame (content height, no page scrollbar) */
:root[data-frame] { scrollbar-gutter: auto; scrollbar-width: none; }
:root[data-frame] .app { min-height: auto; }

.col { width: 100%; max-width: var(--colw); margin: 0 auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* text utilities */
.t16 { font-size: 16px; line-height: 24px; }
.t18 { font-size: 18px; line-height: 28px; }
.t20 { font-size: 20px; line-height: 30px; }
.muted { color: var(--text2); }
.measure { max-width: 70ch; text-wrap: pretty; }
.anywhere { overflow-wrap: anywhere; }
.center { text-align: center; }
.w600 { font-weight: 600; }
.w700 { font-weight: 700; }
.mt4 { margin-top: 4px; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mt24 { margin-top: 24px; }
.mt32 { margin-top: 32px; }

.h1 { font-size: var(--h1); line-height: var(--h1lh); font-weight: 700; }
.h1--upload { max-width: 24ch; text-wrap: pretty; }

/* buttons: no borders, text centred (Design-system 4) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 18px; line-height: 24px; font-weight: 600;
  text-align: center; cursor: pointer;
  transition: background-color var(--tr);
}
.btn--primary { min-height: 56px; padding: 0 24px; background: var(--accent); color: var(--accentText); }
.btn--secondary { min-height: 56px; padding: 0 24px; background: var(--fill); color: var(--text); }
.btn--quiet { min-height: 48px; padding: 0 12px; background: transparent; color: var(--text); }
.btn--icon { width: 48px; height: 48px; padding: 0; background: var(--fill); color: var(--text); }
.btn--run { display: flex; width: 100%; min-height: 64px; font-size: 20px; line-height: 28px; }
.btn--wide { width: var(--btnW); max-width: 100%; }

@media (hover: hover) {
  .btn--primary:hover { background: var(--accentHover); }
  .btn--secondary:hover, .btn--icon:hover { background: var(--fillHover); }
  .btn--quiet:hover { background: var(--fill); }
  .opt:hover { background: var(--fillHover); }
  .opt[aria-pressed="true"]:hover { background: var(--accentHover); }
  .link:hover { text-decoration-thickness: 3px; }
}

/* header */
.hdr { border-bottom: 1px solid var(--border); }
.hdr__in {
  padding: 12px var(--pad); min-height: 72px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
}
.brand {
  min-height: 48px; padding: 0; border: none; background: none; color: var(--text);
  font-family: inherit; font-size: 20px; line-height: 30px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; gap: 12px;
}
.brand img { display: block; border: none; border-radius: 0; }
.hdr__ctl { display: flex; gap: 4px; align-items: center; margin-left: var(--hdrShift); }
/* phone < 640: the widened brand button (logo + gap) needs the same room back from the
   language button's own padding and the control gap, or the header wraps to a second line. */
@media (max-width: 639px) {
  .hdr__ctl { gap: 0; }
  .lang > .btn--quiet { padding: 0 6px; }
}
.lang { position: relative; }
.lang__list {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 220px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 0;
}
.lang__opt {
  width: 100%; min-height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text);
  font-family: inherit; font-size: 18px; line-height: 24px; font-weight: 400; text-align: left; cursor: pointer;
}
.lang__check { width: 24px; height: 24px; flex: 0 0 24px; display: inline-flex; align-items: center; justify-content: center; }
.theme-label { display: none; }
@media (min-width: 640px) {
  .theme-label { display: inline; }
}

/* main column */
.main { flex: 1 0 auto; width: 100%; max-width: var(--colw); margin: 0 auto; padding: 32px var(--pad) 64px; }

.alert { display: flex; gap: 8px; align-items: flex-start; color: var(--error); font-size: 18px; line-height: 28px; }
.alert svg { flex: 0 0 24px; margin-top: 2px; }
.alert span { max-width: 70ch; text-wrap: pretty; }

/* 7.1 upload */
.drop {
  padding: 32px; min-height: 0;
  background: var(--surface); border: 2px dashed var(--bstrong); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  transition: background-color var(--tr), border-color var(--tr);
}
:root[data-pointer="mouse"] .drop[data-state="idle"] { min-height: 280px; }
:root[data-pointer="touch"] .mouse-only { display: none; }
.drop[data-state="dragover"] { background: var(--bg); border-style: solid; border-color: var(--accent); }
.drop[data-state="dragover"] * { pointer-events: none; }
.stack { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.stack--12 { gap: 12px; }
.self-start { align-self: flex-start; }
.bar { height: 12px; border-radius: var(--radius); background: var(--border); overflow: hidden; }
.bar__fill { height: 100%; border-radius: var(--radius); background: var(--accent); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* 7.2 settings */
.filecard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
}
.filecard__txt { min-width: 0; }
.bignote { padding: 16px; border-left: 4px solid var(--bstrong); }
.groups { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; }
.group { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.group__title { font-size: 24px; line-height: 32px; font-weight: 700; }
.param { margin-top: 24px; }
.param__title { font-size: 20px; line-height: 30px; font-weight: 600; }
.opts { margin-top: 12px; display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) {
  .opts { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
  .opts--many { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
.opt {
  display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 16px;
  border: none; border-radius: var(--radius); background: var(--fill); color: var(--text);
  font-family: inherit; font-size: 18px; line-height: 24px; font-weight: 600; text-align: center; cursor: pointer;
  transition: background-color var(--tr);
}
.opt[aria-pressed="true"] { background: var(--accent); color: var(--accentText); }
.opt span { min-width: 0; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: normal; word-break: normal; }
.setbottom { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.reset { align-self: flex-start; } /* no -12px from the prototype: the hover fill stuck out past the column edge */

/* 7.3 processing */
.actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }

/* 7.4 result: comparison */
.cmp {
  margin-top: 24px;
  height: min(calc(100vh * var(--cmpK)), calc(min(var(--colw), 100vw - 2 * var(--pad)) * 1.4142));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
@supports (height: round(nearest, 10.4px, 1px)) {
  .cmp { height: round(nearest, min(calc(100vh * var(--cmpK)), calc(min(var(--colw), 100vw - 2 * var(--pad)) * 1.4142)), 1px); }
}
.cmp__page { position: relative; height: 100%; max-width: 100%; aspect-ratio: 0.7071; }
.cmp__loading {
  position: absolute; inset: 0; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 24px; color: var(--text2);
}
.sheet { position: absolute; inset: 0; overflow: hidden; }
.sheet--scan { z-index: 1; }
.sheet--orig { z-index: 2; background: #FFFFFF; }
.sheet__lines { position: absolute; inset: 0; padding: 9% 10%; display: flex; flex-direction: column; gap: 1.7%; }
.sheet__line { background: #24252A; opacity: 0.84; border-radius: 1px; }
.sheet__grain {
  position: absolute; inset: 0; mix-blend-mode: multiply; background-size: 180px 180px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
}
.sheet__light { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: multiply; }
.cmp__label {
  position: absolute; top: 12px; z-index: 5; padding: 4px 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--bstrong); border-radius: var(--radius);
  font-size: 16px; line-height: 24px; font-weight: 700;
}
.cmp__label--orig { left: 12px; }
.cmp__label--scan { right: 12px; }
.cmp__line {
  position: absolute; top: 0; bottom: 0; z-index: 6; width: 3px;
  background: var(--slider); outline: 1px solid var(--sliderContrast); transform: translateX(-1.5px);
}
.cmp__handle {
  position: absolute; z-index: 7; top: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--slider); border: 2px solid var(--sliderContrast); color: var(--sliderContrast);
  display: flex; align-items: center; justify-content: center; cursor: ew-resize;
}
.cmp__handle:focus-visible { outline: 3px solid var(--slider); outline-offset: 0; }

.resbar { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.pager { display: flex; gap: 12px; align-items: center; }
.links { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.link {
  min-height: 48px; display: inline-flex; align-items: center;
  font-size: 18px; line-height: 28px; color: var(--accent);
  text-decoration-line: underline; text-decoration-thickness: 1px;
}
.why { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.why__btn {
  min-height: 48px; padding: 0; border: none; background: none; color: var(--text);
  font-family: inherit; font-size: 18px; line-height: 28px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-align: left;
}
.why__btn svg { flex: 0 0 24px; }
.resactions { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }

/* footer */
.ftr { border-top: 1px solid var(--border); margin-top: auto; }
.ftr__in {
  padding: 32px var(--pad); display: flex; flex-direction: column; gap: 8px;
  font-size: 16px; line-height: 24px; color: var(--text2);
}
