/* NI Underskrift: roligt og sagligt. Mobil først (320 px), systemfont, NI-mørkegrøn som accent.
   Al styling bor her: siderne har ingen inline-styles (CSP style-src 'self'). */

:root {
  --accent: #1f3a2e;
  --accent-hover: #2c5241;
  --accent-soft: #e9f0ec;
  --text: #1b1f1d;
  --muted: #59615d;
  --border: #cfd6d2;
  --bg: #ffffff;
  --surface: #f5f7f6;
  --danger: #8f1d1d;
  --danger-soft: #fcecec;
  --warn: #6e4600;
  --warn-soft: #fff4df;
  --ok: #1d5a38;
  --ok-soft: #e8f4ed;
  --radius: 10px;
  --gutter: 16px;
  --sig-font: "Segoe Script", "Bradley Hand", "Snell Roundhand", "Apple Chancery", "URW Chancery L", "Brush Script MT", cursive;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 0.85em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus, h1:focus, h2:focus, .result:focus { outline: none; }

/* --- Ramme --------------------------------------------------------------------------- */

.topbar { border-bottom: 1px solid var(--border); background: var(--bg); }
.topbar-inner, .wrap, .foot-inner {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; color: var(--accent); font-size: 1.1rem; text-decoration: none; }
.brand-sub { color: var(--muted); font-size: 1rem; }

.lang { display: flex; align-items: center; gap: 8px; }
.lang label { font-size: 1rem; color: var(--muted); }
.lang select { min-height: 44px; width: auto; max-width: 13rem; }

main.wrap { flex: 1; padding-top: 20px; padding-bottom: 32px; }
.foot { border-top: 1px solid var(--border); color: var(--muted); font-size: 1rem; }
.foot-inner { padding-top: 14px; padding-bottom: 18px; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
  background: var(--bg);
}
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: 1rem; margin: 0 0 2px; }
.wait { margin: 10px 0 0; font-size: 1rem; }
.prose { white-space: pre-line; overflow-wrap: anywhere; }
.view > h1, .view > .card > h1 { overflow-wrap: anywhere; }

/* --- Fakta (afsender, dokument, sider, frist, fingeraftryk) ------------------------ */

.facts { margin: 0; display: grid; gap: 10px; }
.facts > div { display: grid; grid-template-columns: 1fr; gap: 2px; }
.facts dt { color: var(--muted); font-size: 1rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 520px) {
  .facts > div { grid-template-columns: 9.5rem 1fr; gap: 12px; }
  /* Sekundær tekst må først blive mindre end 16 px på større skærme. */
  .brand-sub, .eyebrow, .facts dt { font-size: 0.875rem; }
  .lang label, .foot, .pdf-page-placeholder { font-size: 0.9rem; }
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; overflow-wrap: anywhere; }

.fp {
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color: var(--text);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 44px;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-all;
  cursor: pointer;
  max-width: 100%;
}

/* --- Formularer ------------------------------------------------------------------- */

.field { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin: 0 0 6px; }
input[type="text"], input[type="email"], input:not([type]), input[inputmode], textarea, select {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1rem; /* 16 px: iOS zoomer ellers ind på feltet */
  color: var(--text);
  background: var(--bg);
  border: 1px solid #8b9590;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 48px;
}
textarea { min-height: 6.5rem; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.code-input { letter-spacing: 0.35em; font-size: 1.4rem; max-width: 12rem; text-align: center; font-variant-numeric: tabular-nums; }

.check {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  margin: 0 0 14px;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
}
.check input[type="checkbox"] { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.check label { font-weight: 400; margin: 0; white-space: pre-line; cursor: pointer; }

.sig-preview {
  font-family: var(--sig-font);
  font-size: 1.9rem;
  line-height: 1.3;
  min-height: 3.2rem;
  padding: 6px 4px 4px;
  border-bottom: 2px solid var(--text);
  margin: -4px 0 16px;
  overflow-wrap: anywhere;
}

/* --- Knapper ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link {
  background: none;
  color: var(--accent);
  border: none;
  padding: 10px 4px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-large { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn-block { width: 100%; }
@media (min-width: 520px) { .btn-block { width: auto; } }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.secondary-actions { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 14px; }

/* --- Beskeder --------------------------------------------------------------------- */

.alert {
  border-left: 4px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 6px;
  margin: 12px 0;
}
.notice { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 10px 12px; border-radius: 6px; margin: 12px 0; }

.loading { display: flex; align-items: center; gap: 12px; padding: 24px 0; color: var(--muted); }
.spinner {
  width: 26px;
  height: 26px;
  flex: none;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* --- Dokumentvisning (pdf.js) ------------------------------------------------------ */

.viewer-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.viewer { background: #e6eae8; border-radius: var(--radius); padding: 8px; margin: 8px 0 20px; }
.pdf-page {
  position: relative;
  width: 100%;
  margin: 0 auto 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.pdf-page:last-child { margin-bottom: 0; }
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page-placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1rem; }

/* --- Dialoger --------------------------------------------------------------------- */

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 20px 16px;
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 32px);
  overflow: auto;
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(20, 28, 24, 0.5); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* --- Verifikation og forside -------------------------------------------------------- */

.drop {
  position: relative;
  border: 2px dashed #8b9590;
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: var(--surface);
  margin: 16px 0;
}
.drop-active { border-color: var(--accent); background: var(--accent-soft); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.drop label { margin: 0; }

.result { border-width: 2px; }
.result-ok { border-color: var(--ok); background: var(--ok-soft); }
.result-info { border-color: var(--accent); background: var(--accent-soft); }
.result-warn { border-color: var(--warn); background: var(--warn-soft); }
.result-headline { font-size: 1.15rem; }
.result-signers { margin: 0 0 12px; padding-left: 1.2em; }
.result-signers li { margin: 0 0 4px; }
.signer-name { font-weight: 600; }

.home-links { list-style: none; padding: 0; margin: 20px 0 0; }
.home-links li { margin: 0 0 10px; }
