/* ==========================================================================
   Client signing portal.

   A real stylesheet rather than inline styles, so the CSP can be
   style-src 'self' instead of 'unsafe-inline'. That keeps the policy
   meaningful: with unsafe-inline, an injected <style> could hide the consent
   text or overlay the sign button.

   DARK IS THE BASE, not a media-query variant. The theme is chosen on the
   server from a cookie and stamped on <html>, so there is no flash of the wrong
   theme and no JavaScript involved. Light is opt-in via [data-theme="light"].

   Designed for a phone first, because a client signing a contract usually is
   on one.
   ========================================================================== */

:root {
  --ink:    #e8eaed;
  --muted:  #9aa0aa;
  --line:   #2b303a;
  --bg:     #14161b;
  --card:   #1c1f26;
  --raised: #232730;
  --brand:  #6b8afd;
  --brand-ink: #0f1115;
  --ok:     #2fbf8f;
  --err:    #ff8787;
  --err-bg: #2a1b1d;
  --err-line:#5c2b2b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}

:root[data-theme="light"] {
  --ink:    #1a1d23;
  --muted:  #5c6370;
  --line:   #e2e5ea;
  --bg:     #f6f7f9;
  --card:   #ffffff;
  --raised: #f2f4f7;
  --brand:  #3b5bdb;
  --brand-ink: #ffffff;
  --ok:     #0ca678;
  --err:    #c92a2a;
  --err-bg: #fff5f5;
  --err-line:#ffc9c9;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;               /* never below 16: iOS zooms on focus otherwise */
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── chrome ──────────────────────────────────────────────────────────────── */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 13px 20px;
}
.brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}

.theme-form { margin: 0; line-height: 0; }
.theme-btn {
  width: 34px; height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}
.theme-btn:hover { color: var(--ink); border-color: var(--brand); }

.wrap { max-width: 820px; margin: 0 auto; padding: 22px 16px 64px; }

/* ── landing ─────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 34px 8px 26px; }
.mark {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 78px; height: 78px;
  margin-bottom: 16px;
  color: var(--brand);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.hero h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: -.02em; }
.lede { max-width: 33em; margin: 0 auto; color: var(--muted); font-size: 17px; }
.lede strong { color: var(--ink); font-weight: 600; }

.grid { display: grid; gap: 14px; margin-bottom: 20px; }
@media (min-width: 620px) { .grid { grid-template-columns: 1fr 1fr; } }

.tile {
  display: block;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.tile:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.tile-icon { display: block; color: var(--brand); margin-bottom: 10px; }
.tile-title { display: block; font-weight: 700; margin-bottom: 3px; }
.tile-sub { display: block; font-size: 14px; color: var(--muted); }

.trust {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  font-size: 14px;
  color: var(--muted);
}
.trust strong { color: var(--ink); }
.trust p { margin: 0; }

/* ── cards & type ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.card.ok { border-color: var(--ok); border-width: 2px; }

h1 { font-size: 22px; margin: 0 0 10px; }
h2 { font-size: 18px; margin: 0 0 12px; }
p  { margin: 0 0 12px; }

.muted   { color: var(--muted); font-size: 14px; }
.message { padding: 12px 14px; background: var(--raised); border-radius: 8px; border: 1px solid var(--line); }

.error {
  color: var(--err);
  background: var(--err-bg);
  border: 1px solid var(--err-line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

/* ── forms ───────────────────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
label { font-weight: 600; font-size: 14px; }

input[type="email"], input[type="text"] {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--raised);
  color: var(--ink);
  width: 100%;
}
input[type="email"]:focus, input[type="text"]:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

/* The typed name IS the signature, so it looks like one while being typed —
   the preview and the result are then the same thing. */
#typed { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 26px; padding: 14px; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
  font-size: 14px;
  padding: 12px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 8px;
}
/* 20px and a matched line-height: the box must be tappable and must sit on the
   first line of the disclosure, not float above it. */
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; }

button[type="submit"]:not(.theme-btn) {
  font: inherit;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 9px;
  padding: 14px 22px;
  cursor: pointer;
  width: 100%;
}
button[type="submit"]:not(.theme-btn):hover  { filter: brightness(1.08); }
button[type="submit"]:not(.theme-btn):active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* A link that acts as the primary action - the signed-copy download. Styled to
   match the submit button rather than sharing its selector, because it is an
   <a>: there is no form to post and no JavaScript to fake one with. */
a.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 9px;
  padding: 14px 22px;
  text-decoration: none;
}
a.btn:hover  { filter: brightness(1.08); text-decoration: none; }
a.btn:active { transform: translateY(1px); }

@media (min-width: 560px) {
  button[type="submit"]:not(.theme-btn) { width: auto; align-self: flex-start; }
}

/* ── the document ────────────────────────────────────────────────────────── */
.doc { margin-bottom: 18px; }
.page { margin: 0 0 16px; }
.page img {
  display: block;
  width: 100%;
  height: auto;              /* width/height attrs are set, so no layout shift */
  border: 1px solid var(--line);
  border-radius: 8px;
  /* The document itself stays white in both themes. It is paper, and a client
     should see exactly what they are signing, not a recoloured version of it. */
  background: #fff;
  box-shadow: var(--shadow);
}
.page figcaption {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding-top: 6px;
}

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 14px; margin: 12px 0 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }

/* ── footer ──────────────────────────────────────────────────────────────── */
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 16px 40px;
}
.foot p { margin: 0 0 6px; }
.foot-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.foot-links a:hover { color: var(--brand); }

/* Someone who has asked their OS to reduce motion is not asking for a hover
   lift on a page where they are signing a contract. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  button:active { transform: none; }
}
