/* AuditPrep.
 *
 * Everything here is fluid. There is no fixed-width shell anywhere in this
 * file: the standing law is that every page works on a phone, and the way
 * that gets broken is a `width: 1100px` on a wrapper that looks fine on the
 * laptop it was written on. Max-widths only, and every table that can
 * overflow is wrapped in .scroll-x rather than allowed to widen the document.
 *
 * Proven, not eyeballed: tests/mobile_layout.mjs loads every page at 360,
 * 375 and 390 CSS pixels and fails if scrollWidth exceeds the viewport.
 */

:root {
  --ink: #14181f;
  --ink-soft: #4a5566;
  --line: #dde3ec;
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --accent: #1f4fd8;
  --accent-ink: #ffffff;
  --good: #17683a;
  --warn: #8a5a00;
  --unknown: #55607a;
  --radius: 10px;
  --pad: clamp(1rem, 4vw, 2rem);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  /* Long tokens — a collector's source URL, a sha256 — must wrap rather than
     push the page sideways on a 360px screen. */
  overflow-wrap: break-word;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: #fff; padding: .6rem 1rem; z-index: 10;
}
.skip:focus { left: .5rem; top: .5rem; }

/* --- header / footer ----------------------------------------------------- */
header.site, footer.site {
  display: flex;
  flex-wrap: wrap;                 /* the whole mobile story in one line */
  align-items: center;
  gap: .5rem 1.25rem;
  padding: 1rem var(--pad);
  border-bottom: 1px solid var(--line);
}
footer.site {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  color: var(--ink-soft);
  font-size: .92rem;
}
header.site nav, footer.site nav {
  display: flex; flex-wrap: wrap; gap: .5rem 1.1rem;
  margin-left: auto; align-items: center;
}
footer.site nav { margin-left: auto; }
.brand { font-size: 1.15rem; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.brand strong { color: var(--accent); }
.law { margin: 0; font-weight: 600; color: var(--ink); }

a { color: var(--accent); }
header.site nav a, footer.site nav a { color: var(--ink-soft); text-decoration: none; }
header.site nav a:hover, footer.site nav a:hover { color: var(--ink); text-decoration: underline; }
.cta, button.primary {
  background: var(--accent); color: var(--accent-ink) !important;
  padding: .55rem 1rem; border-radius: var(--radius); border: 0;
  text-decoration: none; font: inherit; font-weight: 600; cursor: pointer;
}
.linkish {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--ink-soft); cursor: pointer; text-decoration: none;
}
.linkish:hover { color: var(--ink); text-decoration: underline; }
form.inline { display: inline; margin: 0; }

/* --- layout -------------------------------------------------------------- */
.wrap { max-width: 66rem; margin: 0 auto; padding: 0 var(--pad); }
.narrow { max-width: 42rem; }
.prose h2 { margin-top: 2.5rem; }
.prose h3 { margin-top: 1.75rem; }

.hero { padding: clamp(2.5rem, 8vw, 5rem) 0 1rem; }
.hero h1 {
  font-size: clamp(1.9rem, 6vw, 3rem); line-height: 1.15;
  letter-spacing: -.02em; margin: 0 0 1rem;
}
.hero .lede { font-size: clamp(1.05rem, 2.6vw, 1.25rem); color: var(--ink-soft); max-width: 40rem; }

.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; background: var(--bg);
}
.card h3 { margin: 0 0 .4rem; font-size: 1.02rem; }
.card p { margin: 0; color: var(--ink-soft); }

.panel { background: var(--bg-soft); border: 1px solid var(--line);
         border-radius: var(--radius); padding: 1.1rem 1.2rem; }

/* --- honesty markers ----------------------------------------------------- */
/* Three states, and "unknown" is a first-class one. A collector that could
   not see something says so; it never guesses and it never leaves a blank
   that reads as a pass. */
.pill { display: inline-block; padding: .12rem .5rem; border-radius: 999px;
        font-size: .8rem; font-weight: 600; border: 1px solid currentColor; }
.pill.collected { color: var(--good); }
.pill.unknown   { color: var(--unknown); }
.pill.failed    { color: var(--warn); }

.meta { color: var(--ink-soft); font-size: .88rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: .85em; }

/* --- forms --------------------------------------------------------------- */
label { display: block; margin: 1rem 0 .3rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=url],
select, textarea {
  width: 100%; padding: .6rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink);
}
/* 16px minimum, or iOS Safari zooms the whole page on focus and the user is
   left scrolled sideways on a layout that was never too wide. */
input, select, textarea { font-size: max(16px, 1rem); }

.error { color: #8a1414; background: #fdf1f1; border: 1px solid #f0caca;
         padding: .7rem .8rem; border-radius: var(--radius); margin: 1rem 0; }
.note  { color: var(--ink-soft); font-size: .9rem; }

/* --- tables -------------------------------------------------------------- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }

/* A two-column label/value table that becomes two stacked rows on a phone.
 *
 * The provenance block on an evidence page is the product: collected-at,
 * filed-at, source, hash, and a sentence under each explaining why it is
 * there. Wrapped in .scroll-x it technically "fits" -- the document is not
 * wider than the viewport -- and every one of those explanatory sentences was
 * cut off at the right edge, readable only by dragging the table sideways.
 * Passing the overflow measurement is not the same as being readable, and the
 * measurement cannot tell the difference. Caught by reading the screenshot.
 */
@media (max-width: 40rem) {
  table.stacked, table.stacked tbody, table.stacked tr,
  table.stacked th, table.stacked td { display: block; width: 100%; }
  table.stacked tr { padding: .75rem 0; border-bottom: 1px solid var(--line); }
  table.stacked tr:last-child { border-bottom: 0; }
  table.stacked th {
    border: 0; padding: 0 0 .2rem;
    font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  }
  table.stacked td { border: 0; padding: 0; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e9edf4; --ink-soft: #a3adbf; --line: #2a3140;
    --bg: #10141b; --bg-soft: #161c26; --accent: #7ea2ff; --accent-ink: #0b0f16;
    --good: #6ede9c; --warn: #e8b45c; --unknown: #9aa5bb;
  }
  input, select, textarea { background: #0c1017; }
  .error { color: #ffb4b4; background: #2a1618; border-color: #4a2427; }
}

/* htmx's indicator convention: hidden until a request is in flight. */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }
