/* InkReceipt — vanilla CSS, no build step. Palette + type per UX plan. */

:root {
  --paper: #FAF8F4;
  --ink: #1B1B18;
  --verdigris: #2E5E4E;
  --terracotta: #B3542E;
  --card-bg: #F5F1E9;
  --border: #E4DFD3;
  --muted: #8A8478;
  --toast-bg: #FFF9F0;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, ui-sans-serif, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

img { max-width: 100%; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 96px; /* bottom room for sticky action bar */
}
.container.narrow { max-width: 480px; }

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

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 720px; margin: 0 auto; padding: 16px 20px;
}
.wordmark {
  font-family: var(--mono); font-weight: 700; font-size: 18px;
  color: var(--verdigris); text-decoration: none; letter-spacing: 0.02em;
}
.topbar nav a { color: var(--verdigris); text-decoration: none; font-size: 16px; }
.topbar nav a:hover, .topbar nav a:focus { text-decoration: underline; }

/* Type */
h1 {
  font-size: 28px; font-weight: 700; line-height: 1.3;
  margin: 8px 0 8px;
}
h2 { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }

/* Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
section.card { display: flow-root; } /* contain floats if ever used */

/* Form bits */
.field-label {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--ink); margin-bottom: 4px;
}
input[type="text"], textarea {
  width: 100%;
  font: inherit; color: var(--ink);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
input[type="text"]:focus, textarea:focus {
  outline: 2px solid var(--verdigris); outline-offset: 1px;
}

.status-line {
  font-size: 13px; color: var(--verdigris);
  margin: 12px 0 8px; letter-spacing: 0.02em;
}

/* Editor */
#editor-textarea {
  display: block;
  width: 100%;
  min-height: 60vh;
  resize: vertical;
  line-height: 1.6;
}
.doc-limit-hint { color: var(--terracotta); font-weight: 600; margin: 8px 0 0; }

.stat-strip { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600;
  min-height: 44px; padding: 0 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: var(--verdigris); color: #fff; border-color: var(--verdigris);
}
.btn-primary:hover:not(:disabled) { background: #27513f; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--card-bg); }

/* Sticky action bar (mobile-first reachable) */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--border);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.action-bar .container { padding-bottom: 0; }
.action-bar .btn { width: 100%; }
#issue-btn { width: 100%; }

/* Spinner (shown while issuing) */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px; margin-right: 8px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Banners */
.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 16px;
  font-weight: 600;
}
.banner-error { background: var(--terracotta); color: #fff; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(27,27,24,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 520px; width: 100%;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(27,27,24,0.25);
}
.modal-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; }

/* Success panel */
.success-title { color: var(--verdigris); }
.link-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill-link {
  font-family: var(--mono); font-size: 13px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px;
  word-break: break-all;
}
.pill-hash {
  font-family: var(--mono); font-size: 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
  display: inline-block;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom;
}
.cert-link { color: var(--verdigris); font-weight: 600; text-decoration: none; }
.cert-link:hover, .cert-link:focus { text-decoration: underline; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--toast-bg); color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(27,27,24,0.15);
  z-index: 60;
  opacity: 1; transition: opacity 0.5s ease;
}
.toast.fade-out { opacity: 0; }

/* Footer links */
.footer-links { text-align: center; margin: 24px 0 0; }
.footer-links a, .footer-note { color: var(--muted); font-size: 14px; }
.footer-links a { color: var(--verdigris); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* Certificate page bits */
.verdict {
  width: 100%;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 20px;
  color: #fff;
}
.verdict svg { vertical-align: -3px; margin-right: 8px; }
.verdict h2 { margin: 0; font-size: 22px; }
.verdict p { margin: 4px 0 0; font-size: 14px; opacity: 0.92; }
.verdict-valid { background: var(--verdigris); }
.verdict-broken { background: var(--terracotta); }

.meta-line { color: var(--muted); font-size: 14px; margin: 4px 0 16px; }

/* Stat chips */
.chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.chip .chip-value { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.chip .chip-label { font-size: 12px; color: var(--muted); }
.chip-warn { border-color: var(--terracotta); }
.chip-warn .chip-value { color: var(--terracotta); }

/* Timeline */
details.sitting { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin-bottom: 8px; }
details.sitting summary {
  cursor: pointer; padding: 10px 12px; font-size: 14px;
  list-style-position: outside;
}
details.sitting[open] summary { border-bottom: 1px solid var(--border); }
.cpt-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--mono); }
.cpt-table th, .cpt-table td { text-align: left; padding: 4px 12px; border-bottom: 1px solid var(--border); }
.cpt-table th { color: var(--muted); font-family: var(--sans); font-weight: 600; }

/* Verify section */
.verify-line { font-size: 14px; }
#reverify-result { font-size: 14px; font-weight: 600; margin: 8px 0 0; min-height: 22px; }
#reverify-result.ok { color: var(--verdigris); }
#reverify-result.bad { color: var(--terracotta); }

/* Mobile */
@media (max-width: 640px) {
  body { font-size: 18px; }
  h1 { font-size: 28px; }
  #editor-textarea { min-height: 50vh; }
  .chips { grid-template-columns: 1fr; }
  .modal-actions .btn { width: 100%; flex-basis: 100%; }
  .link-row .btn { width: 100%; }
  .cpt-table { font-size: 11px; }
  .cpt-table th, .cpt-table td { padding: 4px 6px; }
}