/* @SGN-016 one stylesheet for the signer, verify and test pages. Mobile first, RTL-aware
   (logical properties throughout), light and dark. */
@font-face {
  font-family: 'Naskh';
  src: url('/fonts/noto-naskh-arabic-arabic-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: 'Naskh';
  src: url('/fonts/noto-naskh-arabic-arabic-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}

:root {
  color-scheme: light;
  --bg: #f4f6f6;
  --surface: #ffffff;
  --sunk: #eef2f2;
  --ink: #15232a;
  --muted: #5a6970;
  --line: #d5dee1;
  --accent: #0d6b5a;
  --accent-ink: #ffffff;
  --accent-soft: #e0f0eb;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --bad: #a3322a;
  --bad-soft: #f8e6e3;
  --good: #1d7a3a;
  --good-soft: #e3f3e7;
  --radius: 12px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Naskh', sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f171b;
    --surface: #16222a;
    --sunk: #1c2a33;
    --ink: #e4ecef;
    --muted: #9aaab1;
    --line: #2b3b44;
    --accent: #5cc8b0;
    --accent-ink: #0b1a17;
    --accent-soft: #16352f;
    --warn: #e8b65a;
    --warn-soft: #352a14;
    --bad: #f08a80;
    --bad-soft: #3a1f1d;
    --good: #7fd49a;
    --good-soft: #17301f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
}
[lang='ar'] body, body[dir='rtl'] { font-family: 'Naskh', var(--font); line-height: 1.7; }
.ar { font-family: 'Naskh', var(--font); direction: rtl; text-align: start; line-height: 1.8; }
.en { direction: ltr; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-block-end: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card h1 { font-size: 22px; line-height: 1.25; margin: 0; }
.card h2 { font-size: 17px; margin: 0; }
.card h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.mono { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate; }
.hidden { display: none !important; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

.banner { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.good { background: var(--good-soft); color: var(--good); }
.banner.info { background: var(--accent-soft); color: var(--ink); }
.banner b { display: block; margin-block-end: 2px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; min-height: 44px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; }

.seg { display: inline-flex; background: var(--sunk); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; min-height: 36px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.seg button[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Steps */
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.steps li { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps li.done, .steps li.on { background: var(--accent); }
.steplabel { font-size: 13px; color: var(--muted); }

/* Contract reading */
.doc { display: flex; flex-direction: column; gap: 14px; }
.doc .pair { display: grid; grid-template-columns: 1fr; gap: 6px; }
.doc.both .pair { grid-template-columns: 1fr; }
@media (min-width: 700px) { .doc.both .pair { grid-template-columns: 1fr 1fr; gap: 20px; } }
.doc .clause h3 { border-block-end: 1px solid var(--line); padding-block-end: 4px; margin-block-end: 4px; }
.doc p { margin: 0; }
.party { background: var(--sunk); border-radius: 10px; padding: 10px 12px; }
.party .who { font-weight: 600; }
.party .yours { color: var(--accent); }
.fp { display: flex; flex-direction: column; gap: 2px; background: var(--sunk); border-radius: 10px; padding: 10px 12px; }

/* Progress */
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.people li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--sunk); }
.people li.you { outline: 1.5px solid var(--accent); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: 14px; }
.field .opt { font-weight: 400; color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 16px; /* stops iOS zoom on focus */
}
.field input[readonly] { background: var(--sunk); color: var(--muted); }
.field.err input { border-color: var(--bad); }
.field .msg { color: var(--bad); font-size: 13px; }
.code-input { letter-spacing: 0.4em; font-family: var(--mono); text-align: center; font-size: 22px !important; direction: ltr; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }

/* Signature pad */
.pad { position: relative; border: 1.5px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; height: 200px; overflow: hidden; }
.pad canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.pad .hint { position: absolute; inset-block-end: 34px; inset-inline: 24px; border-block-start: 1px solid #c9d2d5; pointer-events: none; }
.pad .hint span { position: absolute; inset-block-start: 4px; inset-inline-start: 0; font-size: 12px; color: #8a979c; }
.preview-sig { background: #fff; border: 1px solid var(--line); border-radius: 10px; max-width: 100%; height: 110px; object-fit: contain; }

/* Bottom action bar */
.bar {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 6;
  background: var(--surface); border-block-start: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bar .in { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; }
.bar .btn { flex: 1; }

.center { text-align: center; }
.big { font-size: 40px; line-height: 1; }
.list { margin: 0; padding-inline-start: 1.2em; display: flex; flex-direction: column; gap: 4px; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple td { padding: 6px 4px; border-block-end: 1px solid var(--line); vertical-align: top; }
table.simple td:first-child { color: var(--muted); width: 40%; }
.scroll { overflow-x: auto; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 24px 16px; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
details > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.ok-text { color: var(--good); }
.bad-text { color: var(--bad); }
.blockline { display: block; }
a.brand { color: inherit; text-decoration: none; }
