/* ============================================================================
   Design tokens
   Subject: a physical, signed paper petition. The visual language borrows
   from registries, stamped receipts, and hairline-ruled ledgers rather than
   a generic product UI — this is a civic record-keeping tool, not a landing page.
   ============================================================================ */
:root {
  --ink: #1c2430;
  --ink-soft: #4a5568;
  --paper: #efece2;
  --paper-raised: #f8f6ee;
  --line: #cdc6b0;
  --line-soft: #e3ddc9;
  --red: #a23327;
  --red-soft: #f3e2df;
  --blue: #2c4a70;
  --green: #3f6b4f;
  --green-soft: #e2ecdf;
  --amber: #92651b;
  --amber-soft: #f2e6d2;

  --font-display: "Fraunces", "Source Serif 4", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--blue); }

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* -- Header, styled like a registry letterhead -------------------------- */
.letterhead {
  border-bottom: 2px solid var(--ink);
  padding: 28px 0 16px;
  margin-bottom: 28px;
}

.letterhead .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
}

.letterhead h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  margin: 6px 0 4px;
  letter-spacing: -0.01em;
}

.letterhead p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
}

nav.tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
}

nav.tabs a {
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
}

nav.tabs a.active {
  color: var(--ink);
  border-color: var(--ink);
  background: #fff;
}

/* -- Form card ------------------------------------------------------------ */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field .hint {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 400;
  margin-left: 6px;
}

.field input[type="text"],
.field input[type="tel"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font-body);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.field input:focus-visible,
button:focus-visible,
.photo-input label:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* -- Photo picker ---------------------------------------------------------- */
.photo-input {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  background: var(--paper);
}

.photo-input input[type="file"] { display: none; }

.photo-input label.trigger {
  display: inline-block;
  cursor: pointer;
  font-weight: 600;
  color: var(--blue);
  padding: 10px 16px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
}

.photo-input .sub {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

.thumbs .thumb {
  width: 72px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  background: #fff;
}

.thumbs .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumbs .thumb .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(28,36,48,0.75);
  color: #fff;
  border: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

/* -- Submit button ---------------------------------------------------------- */
.submit-btn {
  width: 100%;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.submit-btn:disabled { opacity: 0.5; cursor: wait; }
.submit-btn:not(:disabled):hover { background: var(--blue); }

#turnstile-container { margin: 16px 0; display: flex; justify-content: center; }

.error-box {
  background: var(--red-soft);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

/* -- The stamp: signature confirmation moment ------------------------------- */
.stamp-wrap {
  display: flex;
  justify-content: center;
  padding: 28px 0 8px;
}

.stamp {
  border: 3px solid var(--green);
  color: var(--green);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 22px;
  border-radius: 4px;
  transform: rotate(-3deg);
  background: var(--green-soft);
}

.stamp .small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  margin-top: 4px;
  opacity: 0.85;
}

/* -- Recognition results, styled as a ledger ------------------------------- */
.results h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 24px 0 10px;
}

.ledger {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}

.ledger .page-photo {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--line);
}

.ledger-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.ledger-row:last-child { border-bottom: none; }

.ledger-row .num {
  font-family: var(--font-mono);
  color: var(--ink-soft);
  font-size: 12px;
  padding-top: 2px;
}

.ledger-row .field-line {
  margin-bottom: 2px;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
}

.tag.unclear { background: var(--amber-soft); color: var(--amber); }
.tag.no-sig { background: var(--red-soft); color: var(--red); }

/* -- /records gallery -------------------------------------------------------- */
.registry-entry {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.registry-entry:first-child {
  padding-top: 0;
}

.registry-entry img {
  width: 64px;
  height: 86px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: zoom-in;
}

.registry-entry .meta {
  font-size: 13.5px;
  color: var(--ink-soft);
}

.registry-entry .meta .name {
  color: var(--ink);
  font-weight: 600;
}

.registry-entry .meta .ts {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.registry-entry .badge-new {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--red);
  letter-spacing: 0.08em;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(28,36,48,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 2px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-size: 14px;
}

.load-more {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

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