/* SPDX-License-Identifier: Apache-2.0
   Copyright 2026 Michael Schertz */

:root {
  --ink: #1b1f24;
  --dim: #6a737d;
  --line: #d8dee4;
  --bg: #f6f8fa;
  --panel: #ffffff;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --fatal: #b30000;
  --error: #c05600;
  --warning: #8a6d00;
  --ok: #1a7f37;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* an ID/class `display:` rule outranks the UA [hidden] rule; restore it */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--accent); }

.site-header {
  background: linear-gradient(180deg, #fff, var(--bg));
  border-bottom: 1px solid var(--line);
  padding: 1.75rem 0 1.25rem;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark { display: block; border-radius: 9px; flex: none; }
.site-header h1 { margin: 0; font-size: 1.9rem; letter-spacing: -0.02em; }
.site-header .dim { color: var(--dim); font-weight: 400; }
.plain { color: inherit; text-decoration: none; }
.plain:hover { text-decoration: underline; }
.tagline { margin: .5rem 0 0; color: var(--dim); max-width: 48rem; }
.tagline + .tagline { margin-top: .4rem; }

main { padding: 1.5rem 0 3rem; }

.privacy {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin: 0 0 1.5rem;
  padding: .8rem 1rem;
  border: 1px solid #bfe0cb;
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  background: #f1f8f3;
  font-size: .9rem;
  color: var(--ink);
}
.privacy-icon { flex: none; color: var(--ok); margin-top: .1rem; }
.privacy strong { color: var(--ok); }

#edi-form { display: flex; flex-direction: column; gap: .75rem; }

.field-label { font-weight: 600; }

textarea {
  width: 100%;
  min-height: 11rem;
  font: 13px/1.5 var(--mono);
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  resize: vertical;
  color: var(--ink);
}
#corrected { min-height: 8rem; background: #fbfdff; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
}

label.inline { display: inline-flex; align-items: center; gap: .4rem; color: var(--dim); font-size: .9rem; }
label.inline input[type="number"], select {
  font: inherit;
  padding: .3rem .4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}
label.inline input[type="number"] { width: 4rem; }

.file-pick { position: relative; cursor: pointer; }
.file-pick input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-pick span {
  display: inline-block; padding: .4rem .7rem;
  border: 1px dashed var(--line); border-radius: 6px; background: var(--panel);
}

button {
  font: inherit;
  padding: .45rem .9rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--dim); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.05); }
button.ghost { background: transparent; }

.form-error {
  margin: 0;
  color: var(--fatal);
  font-weight: 600;
}

#results { margin-top: 2rem; display: flex; flex-direction: column; gap: 1.25rem; }

.verdict {
  padding: .9rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-left-width: 5px;
  background: var(--panel);
}
.verdict::before { margin-right: .55rem; font-weight: 700; }
.verdict.ok       { border-color: #bfe0cb; border-left-color: var(--ok); background: #f1f8f3; }
.verdict.ok::before       { content: "\2713"; color: var(--ok); }
.verdict.residual { border-color: #eed9b6; border-left-color: var(--error); background: #fdf6ec; }
.verdict.residual::before { content: "\0021"; color: var(--error); }
.verdict.fail     { border-color: #eec4c4; border-left-color: var(--fatal); background: #fdf1f1; }
.verdict.fail::before      { content: "\2715"; color: var(--fatal); }
.verdict small { display: block; font-weight: 400; color: var(--dim); margin-top: .3rem; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 46rem) { .result-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.2rem;
}
.panel h2 { margin: 0 0 .6rem; font-size: 1.1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.panel-actions { display: flex; gap: .4rem; align-items: center; }
.panel-actions.download { flex-wrap: wrap; }

.hint { color: var(--dim); font-size: .85rem; margin: .5rem 0 0; }

.exploded-box { margin-top: .6rem; }
.exploded-box > summary { cursor: pointer; font-size: .9rem; color: var(--accent); }
.exploded-box pre {
  margin: .5rem 0 0;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  font: 12px/1.5 var(--mono);
  overflow-x: auto;
  white-space: pre;
}

table.facts { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.facts th, table.facts td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--bg); vertical-align: top; }
table.facts th { color: var(--ink); font-weight: 500; width: 30%; white-space: nowrap; vertical-align: baseline; }
table.facts td > span:first-child { font-weight: 500; }
.fact-src { display: block; color: var(--dim); font-size: .8rem; line-height: 1.4; margin-top: .2rem; }

.legend { margin: .25rem 0 .5rem; display: flex; flex-direction: column; gap: .4rem; }
.legend > div { display: flex; gap: .6rem; align-items: baseline; }
.legend dt { flex: 0 0 4.5rem; margin: 0; text-align: left; }
.legend dd { margin: 0; color: var(--dim); font-size: .88rem; }

.pass {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: .75rem;
  overflow: hidden;
}
.pass > summary {
  cursor: pointer;
  padding: .6rem .9rem;
  background: var(--bg);
  font-weight: 600;
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
}
.pass > summary::-webkit-details-marker { display: none; }
.pass > summary::marker { content: ""; }
.pass .pass-body { padding: .5rem .9rem 1rem; }

/* disclosure caret — makes it obvious a pass row expands */
.caret { color: var(--dim); font-size: .8rem; transition: transform .12s ease; }
.caret::before { content: "▶"; }
.pass[open] > summary .caret { transform: rotate(90deg); }

.pass-label { font-weight: 700; }
/* plain status text, deliberately NOT a pill */
.pass-status { font-weight: 400; font-size: .82rem; font-style: italic; color: var(--dim); }
.pass-status::before { content: "· "; font-style: normal; }
.pass-status.ok { color: var(--ok); font-style: normal; }

.pill {
  font: 600 .72rem/1 var(--mono);
  padding: .28rem .5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: #fff;
  white-space: nowrap;
}
.pill.fatal   { background: var(--fatal); }
.pill.error   { background: var(--error); }
.pill.warning { background: #f2e2a0; border-color: #d9c168; color: #5c4900; }
.pill.clean   { background: var(--ok); }
.pill.neutral { background: var(--bg); border-color: var(--line); color: var(--dim); }

/* the severity chips in a pass summary double as filter toggles */
button.pill { cursor: pointer; font-family: var(--mono); transition: box-shadow .1s, opacity .1s; }
button.pill:hover { filter: brightness(1.08); }
button.pill[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
button.pill.dim { opacity: .38; }

.linklike {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer;
}

table.findings { width: 100%; border-collapse: collapse; margin-top: .5rem; font-size: .9rem; }
table.findings th, table.findings td {
  text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top;
}
table.findings th { color: var(--dim); font-weight: 500; }
table.findings code { font: 12px var(--mono); background: var(--bg); padding: .1rem .3rem; border-radius: 4px; }
.sev { font-weight: 700; font-size: .78rem; }
.sev.fatal { color: var(--fatal); }
.sev.error { color: var(--error); }
.sev.warning { color: var(--warning); }
.finding-msg { display: block; margin-top: .15rem; }
.finding-expl { color: var(--dim); font-size: .85rem; margin: .3rem 0 0; }

.site-footer { color: var(--dim); font-size: .85rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); }
.site-footer p { margin: 0; }
.navlinks { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.navlinks a { font-weight: 500; }
.navlinks .here { font-weight: 600; color: var(--dim); }
.navbar { background: var(--panel); border-bottom: 1px solid var(--line); font-size: .85rem; }
.navbar .wrap { padding-top: .55rem; padding-bottom: .55rem; }
.site-footer .navlinks { margin-bottom: .5rem; }
.demo-nav { align-items: baseline; margin: 0 0 1.25rem; font-size: .9rem; }
.demo-nav strong { color: var(--ink); }

/* /codes reference page */
.codes-table { table-layout: fixed; }
.codes-table th:nth-child(1), .codes-table td:nth-child(1) { width: 5.5rem; }
.codes-table th:nth-child(2), .codes-table td:nth-child(2) { width: 16rem; }
.codes-table code { overflow-wrap: anywhere; }
tr.deprecated { opacity: .55; }
.codes-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 1.1rem; }
.codes-filter > span { color: var(--dim); font-size: .85rem; }
.discuss { display: inline-block; margin-top: .35rem; font-size: .78rem; font-weight: 500; white-space: nowrap; }

.busy { opacity: .6; pointer-events: none; }
