/* foliom's stylesheet. Hand-written, one file, no build step.
 *
 * The page this has to get right is the job page, and the thing on it that matters is the
 * pre-flight report: a dense list of findings an author reads once and acts on. So the
 * design is typographic rather than decorative -- a readable measure, real hierarchy,
 * status carried by a small monospace pill instead of by colour alone, and no card
 * shadows, gradients or icons competing with the words.
 *
 * There are no inline styles anywhere in the templates, because the Content-Security-Policy
 * has no unsafe-inline for styles either. Anything that varies is a class.
 */

:root {
  color-scheme: light dark;

  /* Paper and ink, warm rather than blue-grey: the content is a manuscript. */
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #1b1a18;
  --muted: #6a6862;
  --line: #e3e0d9;
  --line-strong: #cdc9c0;
  --accent: #24547b;
  --accent-ink: #ffffff;
  --bad: #9e2b20;
  --warn: #7d5300;
  --ok: #23663c;
  --bad-bg: #fbeceb;
  --warn-bg: #fbf4e4;
  --ok-bg: #ecf5ee;
  --neutral-bg: #f1efeb;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --panel: #1c1f23;
    --ink: #e7e5e1;
    --muted: #9b9892;
    --line: #2c3036;
    --line-strong: #3d434b;
    --accent: #8ab4d8;
    --accent-ink: #10161c;
    --bad: #e69086;
    --warn: #d7a95e;
    --ok: #84c39c;
    --bad-bg: #2c1c1a;
    --warn-bg: #2a2317;
    --ok-bg: #182620;
    --neutral-bg: #23272c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 0.5rem; background: var(--panel); padding: 0.5rem 0.75rem; z-index: 5; }

.masthead {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: baseline;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.wordmark { font-weight: 650; font-size: 1.1rem; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.masthead nav { display: flex; gap: 1.25rem; font-size: 0.94rem; }
.masthead nav a { color: var(--muted); text-decoration: none; }
.masthead nav a:hover { color: var(--ink); }
.masthead nav a[aria-current="page"] { color: var(--ink); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

main { max-width: 60rem; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

h1 { font-size: 1.7rem; line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 0.75rem; max-width: 34ch; }
h2 { font-size: 1.12rem; margin: 2.25rem 0 0.75rem; letter-spacing: -0.005em; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 0.75rem; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 68ch; }
.hint { font-size: 0.87rem; color: var(--muted); margin: 0.25rem 0 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.86em; }
.break { overflow-wrap: anywhere; }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

/* ---- notices ---- */

.notice, .failure, .empty, .allclear {
  border: 1px solid var(--line-strong); border-left-width: 3px;
  padding: 0.7rem 0.9rem; margin: 1rem 0; background: var(--panel);
}
.notice, .failure { border-left-color: var(--bad); background: var(--bad-bg); }
.allclear { border-left-color: var(--ok); background: var(--ok-bg); }

/* ---- the form ---- */

.convert { margin-top: 2rem; }
.field { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: 1.75rem; }
.field > h2 { margin-top: 0; display: flex; align-items: center; gap: 0.6rem; }
.step {
  display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 0.8rem; font-weight: 600;
}

.dropzone { border: 2px dashed var(--line-strong); background: var(--panel); padding: 1.25rem; }
.dropzone label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
input[type="file"] { font: inherit; font-size: 0.94rem; max-width: 100%; }

.targets { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
fieldset { border: 1px solid var(--line); margin: 0; padding: 0.5rem 0.9rem 0.9rem; background: var(--panel); }
legend { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 0.35rem; }

.target { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; padding: 0.5rem 0; cursor: pointer; }
.target + .target { border-top: 1px solid var(--line); }
.target input { margin: 0.3rem 0 0; grid-row: span 3; }
.target-name { font-weight: 600; font-size: 0.96rem; }
.target-desc { font-size: 0.88rem; color: var(--muted); }
.target-tech { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); }
.target:has(input:checked) { background: var(--neutral-bg); }
.target:has(input:checked) .target-name { color: var(--accent); }

.input { display: grid; gap: 0.2rem; max-width: 34rem; margin: 0 0 1rem; }
.input label { font-weight: 600; font-size: 0.94rem; }
.input input { font: inherit; padding: 0.45rem 0.55rem; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); }
.input input:focus-visible, input[type="file"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.req { color: var(--bad); font-size: 0.8rem; font-weight: 600; }
.check { margin: 0.5rem 0; font-size: 0.94rem; }
.check label { display: flex; gap: 0.5rem; align-items: baseline; }

.notes { margin: 0 0 1rem; padding-left: 1.1rem; font-size: 0.9rem; color: var(--muted); }
.notes li { margin-bottom: 0.2rem; }

details.more { margin: 1rem 0; }
details.more > summary { cursor: pointer; font-size: 0.92rem; color: var(--accent); }
details.more[open] > summary { margin-bottom: 0.75rem; }

.actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 2rem; }
button, .button {
  font: inherit; font-weight: 600; padding: 0.55rem 1.2rem; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  text-decoration: none; display: inline-block;
}
button:hover, .button:hover { filter: brightness(1.08); }
.button.ghost { background: var(--panel); color: var(--accent); }

.explainer { border-top: 1px solid var(--line); margin-top: 3rem; padding-top: 1.5rem; }
.explainer-list { max-width: 72ch; padding-left: 1.1rem; }
.explainer-list li { margin-bottom: 0.4rem; }

/* ---- the job page ---- */

.job-head { border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 1rem; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.state { margin: 1.5rem 0; }
/* The failed state gets a rule of its own, so a conversion that produced nothing reads as a
   different kind of thing at a glance rather than as a differently coloured word. */
.state-failed { border-left: 3px solid var(--bad); padding-left: 0.8rem; }
.state-line { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0; }
.state-note { font-size: 0.94rem; }

.pill {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem; border: 1px solid currentColor; white-space: nowrap;
}
.pill-bad { color: var(--bad); background: var(--bad-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-info, .pill-neutral { color: var(--muted); background: var(--neutral-bg); }

/* An indeterminate bar. Nothing knows how far along a LaTeX compile is, so it says
   "working" and not a made-up percentage. */
.working { height: 3px; background: var(--line); overflow: hidden; margin-top: 0.9rem; }
.working span { display: block; height: 100%; width: 30%; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(333%); } }
@media (prefers-reduced-motion: reduce) {
  .working span { animation: none; width: 100%; opacity: 0.4; }
}

.downloads { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0; }

/* htmx's own indicator rules, which it would otherwise inject as an inline <style> element
   that this application's `style-src 'self'` policy refuses. Turned off in the htmx-config
   meta tag and written here instead, so the class behaves as htmx documents it. */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---- the report: the lead content of the application ---- */

.report { border-top: 2px solid var(--ink); padding-top: 0.75rem; margin-top: 2rem; }
.counts { display: flex; flex-wrap: wrap; gap: 0.9rem; font-size: 0.9rem; margin-bottom: 1rem; }
.count { font-variant-numeric: tabular-nums; }
.count.bad { color: var(--bad); font-weight: 600; }
.count.warn { color: var(--warn); font-weight: 600; }

.checks, .issue-list, .log-list { list-style: none; margin: 0; padding: 0; }
.checks > li, .issue-list > li, .log-list > li {
  display: grid; grid-template-columns: 4.2rem 1fr; gap: 0.75rem;
  padding: 0.8rem 0; border-top: 1px solid var(--line);
}
.checks > li > .pill, .issue-list > li > .pill, .log-list > li > .pill { justify-self: start; align-self: start; }
/* A grid item's default min-width is its content, so one unbreakable token -- a 200-character
   filename in a compiler message, a URL in a reference -- would push the whole row wider than
   the page. Both of these hold text that came out of somebody's document. */
.check-body, .issue-body, .log-body { min-width: 0; }
.issue-detail, .log-text, .log-where { overflow-wrap: anywhere; }
/* A compiler message is the one string here that TeX assembled out of the author's own
   document, so it can be a single unbreakable token of any length. */
.log-text { font-weight: 500; margin: 0 0 0.2rem; }
.log-where { margin: 0.15rem 0; font-size: 0.78rem; color: var(--muted); }
.check-title, .issue-message { font-weight: 600; margin: 0 0 0.2rem; }
.check-found, .check-want, .check-fix, .issue-detail, .issue-fix, .issue-code {
  margin: 0.15rem 0; font-size: 0.9rem;
}
.check-found { color: var(--ink); }
.check-want, .issue-detail { color: var(--muted); }
.check-fix, .issue-fix { color: var(--ink); }
.issue-code { color: var(--muted); font-size: 0.78rem; }
.checks.quiet .check-title { font-weight: 500; }
.checks.quiet .check-found { color: var(--muted); font-size: 0.86rem; }

.issues { margin-top: 2.5rem; }
.issue-head { margin: 1.5rem 0 0; font-size: 0.94rem; }

/* ---- the proof and the log ---- */

.proof { margin-top: 2.5rem; }
.pdf { display: block; width: 100%; height: 42rem; border: 1px solid var(--line-strong); background: var(--panel); }
@media (max-width: 40rem) { .pdf { height: 28rem; } }

.log { margin-top: 2rem; }
.logtail {
  font-family: var(--mono); font-size: 0.78rem; line-height: 1.45;
  max-height: 26rem; overflow: auto; padding: 0.75rem;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---- the job list ---- */

.joblist { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.joblist th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--line-strong); padding: 0.5rem 0.6rem 0.5rem 0; }
.joblist td { border-bottom: 1px solid var(--line); padding: 0.6rem 0.6rem 0.6rem 0; vertical-align: top; }
.joblist td.mono span { margin-right: 0.5rem; }

/* ---- the target list ---- */

.target-group { margin-top: 2.5rem; }
.target-detail { border-top: 1px solid var(--line); padding: 1rem 0; }
.target-detail h3 { margin-top: 0; }
.target-detail .target-desc { max-width: 72ch; margin-bottom: 0.6rem; }

/* ---- errors and the footer ---- */

.errorpage { padding: 2rem 0; }
.errorpage .status { font-size: 0.8rem; color: var(--muted); }

.footer {
  border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.25rem 1.5rem;
  font-size: 0.85rem; color: var(--muted);
}
.footer p { max-width: 60rem; margin: 0 auto; }

/* Two panes on a wide screen would halve the measure of the report, which is the one thing
   on the page that must stay readable. The layout stays one column at every width; only the
   proof grows. */
@media (min-width: 78rem) {
  main { max-width: 68rem; }
  .pdf { height: 48rem; }
}
