/* Certfax pages. Tokens and type come from the approved sketch (docs/sketch.html):
   a filled-in government form, ink on field stock, green for the customer's next action.
   Square corners, no shadows, no gradients, no hover motion. */

@font-face { font-family: "Public Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/PublicSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/PublicSans-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/PublicSans-Bold.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 800; font-style: normal; font-display: swap; src: url("/fonts/PublicSans-ExtraBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/IBMPlexMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/IBMPlexMono-Medium.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); }

:root {
  --paper: #f1f3ea;
  --field: #f8f9f2;
  --ink: #16211b;
  --ink-2: #47544c;
  --rule: #b4bfb3;
  --form: #0d5a3c;
  --form-fill: #dde7da;
  --band: #0d5a3c;
  --on-band: #f1f3ea;
  --stop: #a2271b;
  --skel: #dfe3d8;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111713; --field: #18201b; --ink: #e6ebe3; --ink-2: #a8b4aa; --rule: #3a463e;
    --form: #7fcaa4; --form-fill: #1e2c24; --band: #17503a; --on-band: #eef2ea; --stop: #f08d7e;
    --skel: #26302a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111713; --field: #18201b; --ink: #e6ebe3; --ink-2: #a8b4aa; --rule: #3a463e;
  --form: #7fcaa4; --form-fill: #1e2c24; --band: #17503a; --on-band: #eef2ea; --stop: #f08d7e;
  --skel: #26302a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--field);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
}
[hidden] { display: none !important; }
a { color: var(--form); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--form); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0; text-wrap: pretty; }
h1 + .sub { margin-top: 6px; }
/* Headings get focus from the script after a step change; the ring is for keyboard moves, not that. */
[tabindex="-1"]:focus { outline: none; }
img { max-width: 100%; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.label { font: 500 0.75rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.sub { color: var(--ink-2); }
.fine { font-size: 0.875rem; color: var(--ink-2); }
.mono { font-family: var(--mono); }

/* Shell: top bar, one column, footer */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 56px;
  /* Lines the bar up with the 36rem column on wide screens. */
  padding: 4px max(16px, env(safe-area-inset-right, 0px), calc((100% - 36rem) / 2 + 16px)) 4px max(16px, env(safe-area-inset-left, 0px), calc((100% - 36rem) / 2 + 16px));
  border-bottom: 1.5px solid var(--ink);
  background: var(--field);
}
.top .wm { font-weight: 800; font-size: 1.125rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.top .lk { color: var(--ink-2); font-size: 0.95rem; display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: flex-end; }
.top .title { font-weight: 800; font-size: 1.125rem; }
.top .back {
  font: inherit; font-size: 0.95rem; color: var(--ink); background: none; border: 0; padding: 0 8px 0 0;
  min-height: 44px; min-width: 44px; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
main {
  flex: 1;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.foot {
  border-top: 1px solid var(--rule);
  padding: 8px max(16px, env(safe-area-inset-right, 0px), calc((100% - 36rem) / 2 + 16px)) max(8px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px), calc((100% - 36rem) / 2 + 16px));
}
.foot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 20px; }
.foot a { color: var(--ink-2); font-size: 0.9rem; display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }

/* Buttons: green is the next action, ink is paying, outline is the other choice */
.btn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 100%; min-height: 52px; padding: 10px 14px;
  font: 700 1rem/1.25 var(--sans);
  border: 2px solid var(--band); background: var(--band); color: var(--on-band);
  border-radius: 0; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn.alt { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.pay { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.small { min-height: 44px; font-size: 0.95rem; padding: 8px 10px; }
.btn[aria-disabled="true"], .btn:disabled { background: transparent; color: var(--ink-2); border-color: var(--rule); border-style: dashed; cursor: not-allowed; text-decoration: none; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.linkbtn { font: inherit; color: var(--form); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; }

/* Fields */
.inp { display: flex; flex-direction: column; gap: 4px; }
.inp label { font-weight: 600; font-size: 0.95rem; }
.inp input, .inp textarea {
  font: 400 1.0625rem/1.4 var(--sans); color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--ink-2); border-radius: 0;
  padding: 10px 12px; min-height: 48px; width: 100%;
}
.inp textarea { min-height: 88px; resize: vertical; }
.inp input:focus-visible, .inp textarea:focus-visible { outline: 3px solid var(--form); outline-offset: 0; border-color: var(--ink); }
.inp .hint { font-size: 0.875rem; color: var(--ink-2); }
.inp .err { font-size: 0.95rem; color: var(--stop); font-weight: 600; }
.inp [aria-invalid="true"] { border-color: var(--stop); border-width: 2px; }

/* Messages */
.boxnote { border: 1px solid var(--rule); background: var(--paper); padding: 10px 12px; }
.problem { border: 2px solid var(--stop); background: var(--paper); padding: 10px 12px; }
.problem .label { color: var(--stop); font-weight: 600; display: block; margin-bottom: 2px; }
.msg:empty { display: none; }

/* Summary box */
.sum { border: 1.5px solid var(--ink); background: var(--paper); padding: 10px 12px; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.sum .r { display: flex; justify-content: space-between; gap: 12px; }
.sum .r.t { border-top: 1px solid var(--rule); padding-top: 6px; font-weight: 800; }
.sum .fp { border-top: 1px solid var(--rule); padding-top: 6px; font-size: 0.875rem; color: var(--ink-2); display: grid; gap: 2px; }
.sum .fp code { font: 500 0.875rem var(--mono); color: var(--ink); overflow-wrap: anywhere; }

/* Page thumbnails */
.thumbs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(4.25rem, 1fr)); gap: 8px; }
.pg {
  position: relative; display: block; width: 100%; aspect-ratio: 8.5 / 11; padding: 0;
  border: 1px solid var(--ink-2); background: var(--paper); color: var(--ink);
  cursor: pointer; overflow: hidden; font: inherit;
}
.pg img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pg .n { position: absolute; right: 0; bottom: 0; padding: 1px 5px; background: var(--paper); border-top: 1px solid var(--ink-2); border-left: 1px solid var(--ink-2); font: 600 0.75rem/1.3 var(--mono); }
.pg .kind { position: absolute; left: 0; top: 0; padding: 1px 5px; background: var(--paper); border-right: 1px solid var(--ink-2); border-bottom: 1px solid var(--ink-2); font: 600 0.6875rem/1.3 var(--mono); }
.pg .lines { position: absolute; inset: 22px 7px 22px; display: flex; flex-direction: column; gap: 5px; }
.pg .lines span { display: block; height: 2px; background: var(--rule); }
.pg .lines span:first-child { height: 3px; width: 55%; background: var(--ink-2); }
.pg .lines span:nth-child(4) { width: 62%; }
.pg[aria-pressed="true"] { outline: 3px solid var(--form); outline-offset: 1px; border-color: var(--form); }
.pg.dark { border: 2px solid var(--stop); }
.pg.dark .kind { color: var(--stop); border-color: var(--stop); }
.pg.add { border-style: dashed; display: flex; align-items: center; justify-content: center; font: 600 0.8125rem/1.2 var(--mono); color: var(--ink); text-align: center; padding: 4px; }
#count { margin-top: 8px; }
.pages-panel { border: 1.5px solid var(--ink); background: var(--paper); padding: 10px 12px; display: grid; gap: 8px; }
.pages-panel .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }

/* Status steps: square markers, never color alone */
.tl { list-style: none; margin: 0; padding: 0; display: grid; }
.tl li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.tl li::before { content: ""; width: 12px; height: 12px; margin-top: 5px; border: 2px solid var(--ink); }
.tl li.done::before { background: var(--ink); }
.tl li.now::before { background: var(--form); border-color: var(--form); }
.tl li.bad::before { background: var(--stop); border-color: var(--stop); }
.tl li.wait { color: var(--ink-2); }
.tl li.wait::before { border-color: var(--ink-2); }
.tl .lab { font-weight: 600; }
.tl .t { display: block; font: 500 0.8125rem/1.4 var(--mono); color: var(--ink-2); }
.tl .note { display: block; font-size: 0.95rem; color: var(--ink); }

/* Skeletons: gray shapes in the layout they are about to fill */
.skel { display: grid; gap: 12px; }
.sk { display: block; background: var(--skel); }
.sk.h { height: 28px; width: 70%; }
.sk.l { height: 16px; width: 85%; }
.sk.s { height: 16px; width: 45%; }
.sk.row { height: 44px; width: 100%; }
.sk.box { height: 56px; width: 100%; }
.sk.pg { cursor: default; border-color: var(--skel); }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: sk-pulse 1.6s ease-in-out infinite; }
  @keyframes sk-pulse { 50% { opacity: 0.55; } }
}

/* Payment panel */
.checkout { border: 1.5px solid var(--ink); background: var(--paper); padding: 12px; display: grid; gap: 10px; }
.checkout .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
#stripe-checkout { min-height: 1px; }
.turnstile-box { min-height: 65px; }

/* Long-form pages: terms, privacy, refunds, help */
.doc { gap: 0; }
.doc h1 { margin-bottom: 6px; }
.doc .updated { margin-bottom: 8px; }
.doc section { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 18px; }
.doc h2 { margin-bottom: 6px; }
.doc p + p, .doc p + ul, .doc ul + p { margin-top: 8px; }
.doc ul { margin: 6px 0 0; padding-left: 1.25em; display: grid; gap: 6px; }
.doc table { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: 0.95rem; background: var(--paper); }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 8px 10px; border: 1px solid var(--rule); }
.doc thead th { background: var(--form-fill); }
.draft { border: 2px dashed var(--stop); padding: 10px 12px; margin-bottom: 8px; }
.todo { background: none; color: var(--stop); font-weight: 600; border-bottom: 1.5px dashed var(--stop); }

/* Home page steps */
.step { display: flex; flex-direction: column; gap: 16px; }
.step > div:empty { display: none; }
#details { display: flex; flex-direction: column; gap: 16px; }
.draft-offer { display: grid; gap: 10px; }

/* The two doors, as the sketch's tabs: the chosen one is filled with ink */
.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1.5px solid var(--ink); }
.tabs [role="tab"] {
  font: 600 0.95rem/1.25 var(--sans); color: var(--ink); background: transparent; border: 0; border-radius: 0;
  min-height: 44px; padding: 8px 6px; cursor: pointer;
}
.tabs [role="tab"] + [role="tab"] { border-left: 1.5px solid var(--ink); }
.tabs [role="tab"][aria-selected="true"] { background: var(--ink); color: var(--paper); }
.tabs [role="tab"]:hover { text-decoration: underline; text-underline-offset: 3px; }
.tabs [role="tab"]:focus-visible { outline-offset: -5px; outline-color: var(--paper); }
.tabs [role="tab"][aria-selected="false"]:focus-visible { outline-color: var(--form); }
.door { display: flex; flex-direction: column; gap: 16px; }

/* Address groups */
#l-details { display: flex; flex-direction: column; gap: 16px; }
.addr { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.addr legend { font-weight: 800; font-size: 1.05rem; padding: 0; margin-bottom: 8px; }
.addr .hint { font-size: 0.875rem; color: var(--ink-2); }
.row2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
@media (max-width: 300px) { .row2 { grid-template-columns: minmax(0, 1fr); } }
.inp select {
  font: 400 1.0625rem/1.4 var(--sans); color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink-2); border-radius: 0; padding: 10px 8px; min-height: 48px; width: 100%;
}
.inp select:focus-visible { outline: 3px solid var(--form); outline-offset: 0; border-color: var(--ink); }
.addr-check:empty { display: none; }
.addr-check { display: grid; gap: 8px; }
.ok { color: var(--form); font-weight: 700; }
.addr-check .lines { font-family: var(--mono); font-size: 0.9rem; }
.warn { font-weight: 700; }
.pg.static { cursor: default; }
.faxno { font: 600 1.6rem/1.2 var(--mono); margin-top: 4px; }
.office-go { margin-top: 14px; }
.nowrap { white-space: nowrap; }

/* The optional Redact step. The page itself is the document as drawn (white paper); a black box is the black that
   will be burned in. A picked box turns see-through with a green edge so what's under it can be lined up. */
.redact-row { display: grid; gap: 6px; }
.r-step { gap: 12px; }
.r-step h1 { font-size: 1.4rem; }
.r-step h1 + .sub { margin-top: 4px; }
.r-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.r-tools .btn { padding: 6px 4px; }
/* Add a box is for the keyboard: out of sight until it has focus, like a skip link. */
.r-add:not(:focus) { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; }
.r-mode { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.r-mode [aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.r-frame { border: 1.5px solid var(--ink); background: var(--paper); overflow: auto; padding: 8px; overscroll-behavior: contain; }
.r-frame.zoomed { max-height: 62vh; }
.r-page { position: relative; width: 100%; aspect-ratio: 8.5 / 11; margin: 0 auto; background: var(--field); outline: 1px solid var(--rule); }
.r-page canvas, .r-page img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.r-skel { position: absolute; inset: 0; }
.r-layer { position: absolute; inset: 0; touch-action: pinch-zoom; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.r-layer.pan { touch-action: auto; cursor: grab; }
.r-layer:focus-visible { outline: 3px solid var(--form); outline-offset: -3px; }
.r-box { position: absolute; background: #000; cursor: move; }
.r-box.sel { background: rgb(0 0 0 / 0.55); outline: 3px solid var(--form); }
.r-box.unchecked { outline: 2px dashed var(--stop); outline-offset: 1px; }
.r-box:focus-visible { outline: 3px solid var(--form); outline-offset: 2px; }
.r-draft { position: absolute; background: rgb(0 0 0 / 0.35); outline: 2px dashed var(--form); pointer-events: none; }
/* The resize square: drawn small, but a 44px target centred on the box's corner. */
.r-grip { position: absolute; right: -22px; bottom: -22px; width: 44px; height: 44px; cursor: nwse-resize; }
.r-grip::after { content: ""; position: absolute; inset: 12px; background: var(--paper); border: 3px solid var(--form); }
.r-nav { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; }
.r-nav .mono { font-size: 0.9rem; text-align: center; }
/* The count and Done stay at the bottom of the screen while the page is worked on. */
.r-foot {
  position: sticky; bottom: 0; z-index: 1; display: grid; gap: 6px;
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-right, 0px))) -32px calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--field); border-top: 1.5px solid var(--ink);
}
.r-foot p { font-variant-numeric: tabular-nums; }
