/* Exam Photo & Signature Resizer — mobile-first styles */

:root {
  --c-primary: #1a56db;
  --c-primary-dark: #1442a8;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-bg: #f5f7fb;
  --c-card: #ffffff;
  --c-ok: #047857;
  --c-ok-bg: #ecfdf5;
  --c-warn: #92400e;
  --c-warn-bg: #fffbeb;
  --c-err: #b91c1c;
  --c-err-bg: #fef2f2;
  --c-info: #1e40af;
  --c-info-bg: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
}

img { max-width: 100%; }
a { color: var(--c-primary); }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Header ---------- */
.site-header { background: var(--c-card); border-bottom: 1px solid var(--c-border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 52px; gap: 12px; }
.brand { font-weight: 800; font-size: 1.05rem; color: var(--c-text); text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--c-primary); }
.header-nav { display: flex; gap: 14px; font-size: .9rem; }
.header-nav a { color: var(--c-muted); text-decoration: none; }
.header-nav a:hover { color: var(--c-primary); }

/* ---------- Hero ---------- */
.hero { padding-top: 16px; padding-bottom: 4px; }
.hero h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 6px; letter-spacing: -.02em; }
.lead { margin: 0; color: #374151; font-size: .95rem; }
.privacy-pill {
  display: inline-block; margin-top: 6px;
  padding: 2px 10px; border-radius: 999px;
  background: var(--c-ok-bg); color: var(--c-ok);
  font-size: .82rem; font-weight: 600;
}

/* ---------- Ad slots ----------
   Hidden until ads go live: add class="ads-enabled" to <body> to reveal them.
   Fixed min-heights reserve space so ads never shift the tool (CLS),
   and generous margins keep them away from buttons (accidental clicks). */
.ad-slot {
  display: none;
  align-items: center; justify-content: center;
  margin: 16px 0;
}
.ads-enabled .ad-slot { display: flex; }
/* Striped preview look only while a slot still holds its placeholder label. */
.ad-slot:has(> .ad-label) {
  border: 1px dashed #cbd5e1; border-radius: 8px;
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 10px, #f1f5f9 10px, #f1f5f9 20px);
  color: #94a3b8;
}
.ad-slot--top { min-height: 60px; }
.ad-slot--below { min-height: 250px; margin-top: 32px; }
.ad-slot--content { min-height: 250px; margin: 28px 0; }
.ad-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Tool layout ---------- */
/* Collapses with the top ad slot's margin, so spacing is the same with ads on or off. */
.tool { margin-top: 16px; }
.tool-grid { display: grid; gap: 16px; }
.panel {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 16px 16px;
  min-width: 0;
}
.step { padding-top: 14px; }
.step + .step { border-top: 1px solid var(--c-border); margin-top: 14px; }
.step-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 0 0 10px; }
.step-num {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  font-size: .8rem; font-weight: 700; flex: none;
}

/* ---------- Form controls ---------- */
.select, input[type="text"], input[type="number"], input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}
.select:focus, input:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; border-color: var(--c-primary); }

.spec-summary { margin: 8px 0 0; font-size: .9rem; color: var(--c-muted); }
.spec-summary strong { color: var(--c-text); }

.custom-fields {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin: 12px 0 0; padding: 0; border: 0;
}
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 4px; color: #374151; }
.field-error { grid-column: 1 / -1; margin: 0; color: var(--c-err); font-size: .88rem; }

.option-group { margin: 0 0 12px; padding: 0; border: 0; }
.toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 600; font-size: .95rem; min-height: 32px; }
.toggle input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--c-primary); flex: none; }
.strip-fields { display: grid; gap: 10px; margin-top: 10px; }

.hint { margin: 6px 0 0; font-size: .84rem; color: var(--c-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 14px;
  font: inherit; font-weight: 600; font-size: .92rem;
  border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s;
}
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:not(:disabled):hover { background: var(--c-primary-dark); }
.btn:disabled, .btn[aria-disabled="true"] {
  background: #e5e7eb; color: #6b7280; border-color: #d1d5db;
  opacity: .55; cursor: not-allowed;
}
.btn--ghost { background: #fff; color: var(--c-text); border-color: #d1d5db; }
.btn--ghost:not(:disabled):hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn--block { width: 100%; margin-top: 12px; font-size: 1rem; }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 22px 14px;
  text-align: center;
  border: 2px dashed #93b4f5; border-radius: var(--radius);
  background: #f8faff;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.dropzone:hover, .dropzone.is-dragover { background: #eef4ff; border-color: var(--c-primary); }
.dropzone:focus-within { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.dropzone-icon { font-size: 1.8rem; line-height: 1; }
.dropzone-text { font-size: .98rem; }
.dropzone-hint { font-size: .8rem; color: var(--c-muted); }
.dropzone.is-compact { flex-direction: row; flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
.dropzone.is-compact .dropzone-icon { font-size: 1.2rem; }
.dropzone.is-compact .dropzone-hint { display: none; }

.upload-status { margin: 8px 0 0; font-size: .88rem; color: var(--c-muted); min-height: 0; }
.upload-status:empty { display: none; }

/* ---------- Alerts & badges ---------- */
.alert { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; font-size: .9rem; }
.alert--error { background: var(--c-err-bg); color: var(--c-err); border: 1px solid #fecaca; }

.badges { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.badge { padding: 8px 10px; border-radius: 8px; font-size: .86rem; line-height: 1.4; border: 1px solid transparent; }
.badge--ok { background: var(--c-ok-bg); color: var(--c-ok); border-color: #a7f3d0; font-weight: 600; }
.badge--warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: #fde68a; }
.badge--error { background: var(--c-err-bg); color: var(--c-err); border-color: #fecaca; font-weight: 600; }
.badge--info { background: var(--c-info-bg); color: var(--c-info); border-color: #bfdbfe; }

/* ---------- Cropper ---------- */
.crop-wrap {
  height: min(62vh, 420px);
  background: #111827;
  border-radius: 8px;
  overflow: hidden;
}
.crop-wrap img { display: block; max-width: 100%; }
.crop-empty {
  margin: 0; padding: 28px 12px;
  text-align: center; color: var(--c-muted); font-size: .9rem;
  border: 1px dashed var(--c-border); border-radius: 8px;
  background: #fafafa;
}
.crop-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.crop-toolbar .btn { flex: 1 1 auto; padding: 8px 10px; }
.cropper-view-box { outline: 2px solid #3b82f6; outline-color: rgba(59, 130, 246, .9); }
.cropper-line, .cropper-point { background-color: #3b82f6; }
.cropper-point { width: 10px; height: 10px; opacity: 1; }

/* ---------- Result ---------- */
.result { position: relative; min-height: 120px; }
.result-empty {
  margin: 0; padding: 28px 12px;
  text-align: center; color: var(--c-muted); font-size: .9rem;
  border: 1px dashed var(--c-border); border-radius: 8px;
}
.preview-box {
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--c-border); border-radius: 8px;
}
.preview-box img { display: block; height: auto; box-shadow: 0 0 0 1px #d1d5db, 0 2px 8px rgba(0, 0, 0, .12); background: #fff; }
.preview-note { text-align: center; }

.result-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; font-size: .9rem; }
.result-meta dt { color: var(--c-muted); }
.result-meta dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.result-busy {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center; gap: 8px;
  background: rgba(255, 255, 255, .75);
  font-size: .9rem; font-weight: 600; color: var(--c-primary);
  border-radius: 8px;
}
.result.is-busy .result-busy { display: flex; }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid #bfdbfe; border-top-color: var(--c-primary); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Content ---------- */
.content { padding-bottom: 32px; }
.content section {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 4px 16px 16px;
  margin-top: 20px;
}
.content h2 { font-size: 1.2rem; margin: 16px 0 8px; letter-spacing: -.01em; }
.content p, .content li { font-size: .95rem; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; border: 1px solid var(--c-border); border-radius: 8px; }
.spec-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: .88rem; }
.spec-table th, .spec-table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--c-border); }
.spec-table thead th { background: #f9fafb; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); }
.spec-table tbody tr:last-child > * { border-bottom: 0; }
.spec-table tbody th { white-space: nowrap; }
.spec-table td:nth-child(2), .spec-table td:nth-child(3) { white-space: nowrap; font-variant-numeric: tabular-nums; }

.declaration-quote {
  margin: 12px 0; padding: 12px 16px;
  font-size: .95rem; font-style: italic;
  background: #f9fafb; border-left: 4px solid var(--c-primary); border-radius: 0 8px 8px 0;
}

.steps-list, .tips-list { padding-left: 20px; margin: 8px 0 0; }
.steps-list li, .tips-list li { margin-bottom: 8px; }

details { border-top: 1px solid var(--c-border); padding: 4px 0; }
details:first-of-type { border-top: 0; }
summary { cursor: pointer; padding: 10px 0; font-weight: 600; list-style-position: outside; }
summary:hover { color: var(--c-primary); }
details p { margin: 0 0 10px; color: #374151; }

/* ---------- Breadcrumb & preset chips (exam pages) ---------- */
.breadcrumb { margin: 0 0 8px; font-size: .82rem; color: var(--c-muted); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: 4px; color: #9ca3af; }
.breadcrumb a { color: var(--c-muted); }

.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  min-height: 36px; padding: 6px 14px;
  font: inherit; font-size: .86rem; font-weight: 600;
  color: var(--c-primary); background: #fff;
  border: 1px solid #bfdbfe; border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: var(--c-primary); }
.chip[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* Reserve space while app.js renders the tool, so the page doesn't jump. */
#tool-root:empty { min-height: 480px; }

/* ---------- Exam tool directory ---------- */
.exam-grid { display: grid; grid-template-columns: 1fr; gap: 10px; list-style: none; margin: 12px 0 0; padding: 0; }
.exam-card {
  display: block; height: 100%;
  padding: 12px 14px;
  text-decoration: none; color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: 10px;
  background: #fafbff;
  transition: border-color .15s, background-color .15s;
}
.exam-card:hover { border-color: var(--c-primary); background: #f3f7ff; }
.exam-card strong { display: block; font-size: .95rem; color: var(--c-primary); }
.exam-card span { display: block; margin-top: 2px; font-size: .82rem; color: var(--c-muted); }
.exam-card[aria-current="page"] { border-color: var(--c-primary); background: #eef4ff; }

/* ---------- Text pages (About, Privacy, Terms, Contact) ---------- */
.prose { max-width: 780px; }
.prose section { padding-bottom: 8px; }
.prose h1 { font-size: 1.6rem; line-height: 1.25; margin: 20px 0 6px; letter-spacing: -.02em; }
.prose h3 { font-size: 1rem; margin: 16px 0 6px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.updated { margin: 0; font-size: .85rem; color: var(--c-muted); }

.contact-form { display: grid; gap: 12px; margin-top: 12px; }
.contact-form textarea {
  width: 100%; min-height: 140px; padding: 10px 12px;
  font: inherit; color: inherit;
  border: 1px solid #d1d5db; border-radius: 8px; resize: vertical;
}
.contact-form textarea:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; border-color: var(--c-primary); }
.contact-form .btn { justify-self: start; }
.form-note { margin: 0; font-size: .88rem; }

/* ---------- Footer ---------- */
.site-footer { background: #111827; color: #9ca3af; padding: 28px 0 24px; font-size: .85rem; }
.footer-grid { display: grid; gap: 20px; margin-bottom: 16px; }
.footer-heading { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: #e5e7eb; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-links a { color: #d1d5db; text-decoration: none; }
.footer-links a:hover { color: #fff; text-decoration: underline; }
.footer-note { margin: 6px 0 0; }

/* ---------- Larger screens ---------- */
@media (min-width: 600px) {
  .custom-fields { grid-template-columns: repeat(5, 1fr); }
  .strip-fields { grid-template-columns: 3fr 2fr; }
  .hero h1 { font-size: 1.75rem; }
  .exam-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 2fr 1fr; }
  .footer-grid .footer-links--exams { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
}

@media (min-width: 900px) {
  .exam-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { padding-top: 24px; }
  .tool-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
  .ad-slot--top { min-height: 90px; }
  .content section { padding: 8px 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation-duration: 2s; }
}
