/* css/app.css
 *
 * One screen, built for a phone held in one hand: the main buttons sit in a
 * bar at the bottom where a thumb reaches them, and every tap target is at
 * least 44 px tall. Colours are defined once as custom properties, with a
 * dark-mode set below. System fonts only: the app never loads remote fonts.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #5b6470;
  --border: #d5d9df;
  --accent: #1f2a37;
  --accent-text: #ffffff;
  --ok: #1d7a43;
  --warn: #9a5b00;
  --fail: #b3261e;
  --info: #3d5a80;
  --focus: #2563eb;
  --radius: 12px;
  --gap: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1b2026;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --border: #2f363e;
    --accent: #e8eaed;
    --accent-text: #111418;
    --ok: #6cc28f;
    --warn: #e5a54b;
    --fail: #f2948b;
    --info: #8fb3e0;
    --focus: #8ab4f8;
  }
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules below. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header */
.app-header {
  padding: calc(16px + env(safe-area-inset-top)) 16px 8px;
  max-width: 900px;
  margin: 0 auto;
}
.app-header h1 { margin: 0; font-size: 1.5rem; }
.tagline { margin: 4px 0 0; color: var(--muted); }

.app-main { max-width: 900px; margin: 0 auto; padding: 0 16px; }

/* Banners */
.banner, .tip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 8px 0;
}
.banner-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.banner-button:disabled { opacity: 0.55; }
.banner-note { margin: 8px 0 0; color: var(--muted); font-size: 0.9rem; }
.tip p { margin: 0 0 8px; }

.link-button {
  background: none;
  border: 0;
  padding: 10px 0;
  min-height: 44px;
  color: var(--focus);
  text-decoration: underline;
  cursor: pointer;
}

/* File list */
.empty-state { color: var(--muted); padding: 24px 0; text-align: center; }
.file-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: var(--gap); }

.file {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.file-head { display: grid; gap: 4px; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-status { color: var(--muted); font-size: 0.95rem; }
.file[data-status="error"] .file-status { color: var(--fail); }
.file[data-status="done"] .file-status { color: var(--ok); }
.file progress { width: 100%; height: 8px; }

.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-actions .button { flex: 1 1 auto; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.button.small { min-height: 40px; padding: 6px 12px; font-weight: 500; }
.button.quiet { flex: 0 0 auto; border-color: transparent; background: none; color: var(--muted); font-weight: 500; }
.button:disabled { opacity: 0.5; cursor: default; }

.file-body { margin-top: 12px; display: grid; gap: 16px; }

/* Report */
.summary { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.summary li { display: grid; grid-template-columns: 1.4em 1fr; gap: 6px; align-items: start; }
.summary .icon { font-weight: 700; text-align: center; }
.summary .level-ok .icon { color: var(--ok); }
.summary .level-warn .icon { color: var(--warn); }
.summary .level-fail .icon { color: var(--fail); }
.summary .level-info .icon { color: var(--info); }
.report-details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--muted); }
.report-details h4 { margin: 12px 0 4px; font-size: 0.95rem; }
.report-details ul { margin: 0; padding-left: 1.2em; }
.report-details table { border-collapse: collapse; font-size: 0.9rem; width: 100%; }
.report-details th, .report-details td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.difference { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }

/* Preview */
.preview { display: grid; gap: 8px; }
.preview-pages { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: start; }
.preview-pages.zoomed { grid-template-columns: 1fr; }
.preview figure { margin: 0; display: grid; gap: 4px; }
.preview figcaption { font-size: 0.85rem; color: var(--muted); }
.preview canvas {
  width: 100%;
  height: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: zoom-in;
}
.preview-pages.zoomed canvas { cursor: zoom-out; }
.preview-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.preview-nav .page-label { flex: 1 1 auto; text-align: center; color: var(--muted); }
.preview-options { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.preview-message { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* Settings */
.settings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  padding: 0 12px;
}
.settings > summary { min-height: 48px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.settings-form { display: grid; gap: 14px; padding-bottom: 12px; }
.field { display: grid; gap: 6px; }
.field-label { font-weight: 500; }
.field-label small { color: var(--muted); font-weight: 400; }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-row input[type="range"] { flex: 1 1 auto; }
.field select, .field input[type="number"] {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.field input[type="number"] { width: 6em; }
.field output { min-width: 5.5em; text-align: right; color: var(--muted); }
.settings-note { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* Bottom action bar: within thumb reach */
.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); /* for browsers without color-mix() */
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.action-bar .button { flex: 0 1 auto; }
.choose-button { flex: 1 1 auto; max-width: 320px; position: relative; }

@media (min-width: 700px) {
  .action-bar { justify-content: center; }
}
