/* The review interface.
 *
 * The look follows bentraytech.com's own grammar, read out of its stylesheet:
 * Roboto headings at weight 700, an uppercase steel-blue eyebrow label above
 * each one, white cards on a light wash with a soft blue-grey shadow, and a
 * navy band across the top.
 *
 * One deliberate departure. On that site the last word of each heading is
 * bronze, decoratively - nothing there carries a verdict. Here bronze
 * (--attention) is the single colour that means "this is a contradiction", so
 * it is spent nowhere else. The eyebrow colour (--span-color) is the site's
 * own, so the layout grammar is intact and only that one hue is reserved.
 *
 * Two rules are asserted by tests:
 *   1. The verdict carries no colour. Painting `fail` red would make, in CSS,
 *      the accusation the rule catalogue never makes in words - and would fire
 *      on every genuine certificate from an unsourced district.
 *   2. --attention is referenced by the contradiction rules and nowhere else.
 */

:root {
  /* Palette, from bentraytech.com's own :root. */
  --ink: #071a3e;         /* tb-color1   - navy band, headings */
  --primary: #145e82;     /* first-color - interactive */
  --accent: #29abe2;      /* tb-color6   - focus ring */
  --attention: #b06f26;   /* main-color  - contradictions, and nothing else */
  --eyebrow: #23527c;     /* span-color  - the uppercase label above a heading */
  --heading: #232323;     /* heading-color */
  --muted: #878d97;       /* body-color  - body text */
  --wash: #eff1f5;        /* smoke-color - page background */
  --tint: #eef2fb;        /* secondary-color */
  --surface: #ffffff;
  --line: #dddddd;

  --shadow: 0 10px 31px rgba(169, 177, 193, 0.17);
  --shadow-sm: 0 10px 21px rgba(169, 177, 193, 0.15);

  --radius: 5px;
  --radius-card: 10px;
  --measure: 1080px;
  --gutter: 30px;
  /* A line of body text is read, not scanned: the card may be 1080px wide, a
   * sentence inside it may not. */
  --read: 68ch;
  --ease: 160ms cubic-bezier(0.2, 0, 0.2, 1);

  /* A 4px step. The site's 120px section rhythm suits a brochure; a findings
   * list needs a working density. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  --line-latin: 1.45;
  --line-deva: 1.75;

  --font-body: "Inter", system-ui, sans-serif;
  --font-head: "Roboto", "Inter", system-ui, sans-serif;
  --font-deva: "Noto Sans Devanagari", "Inter", sans-serif;
}

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("/static/fonts/Roboto-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Devanagari";
  src: url("/static/fonts/NotoSansDevanagari.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 var(--s6);
  background: var(--wash);
  color: var(--muted);
  font-family: var(--font-body), var(--font-deva);
  line-height: var(--line-latin);
  font-size: 16px;
}

/* Devanagari sits taller than Latin: the shirorekha above and the matras below
 * are clipped at a line-height comfortable for Inter. */
:lang(ne), [lang="ne"], .deva {
  font-family: var(--font-deva), var(--font-body);
  line-height: var(--line-deva);
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ------------------------------------------------------------- the navy band */

/* Stays put: the language control and the page's identity are the two things
 * worth having in reach while scrolling a long result. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ink);
  color: #fff;
  padding: var(--s4) 0;
  box-shadow: var(--shadow-sm);
}

.topbar .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
}

.brand span {
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.lang {
  display: flex;
  gap: var(--s2);
  align-items: center;
  font-size: 0.8125rem;
  color: #cfd6e4;
}

/* ------------------------------------------------------------------- headings */

main { padding-top: var(--s6); }

.eyebrow {
  display: block;
  margin: 0 0 var(--s2);
  font-family: var(--font-head);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--eyebrow);
}

.card h2 {
  margin: 0 0 var(--s3);
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--heading);
}

/* --------------------------------------------------------------------- cards */

.card {
  margin: 0 0 var(--s5);
  padding: var(--s6) var(--s5);
  border: 1px solid rgba(169, 177, 193, 0.25);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hint {
  max-width: var(--read);
  margin: 0 0 var(--s4);
  color: var(--muted);
  font-size: 0.875rem;
}

/* ------------------------------------------------------------------- controls */

select, input[type="file"], input[type="text"] {
  font: inherit;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--heading);
}

.lang select {
  padding: var(--s1) var(--s2);
  border-color: #2b3f66;
  background: #0d2650;
  color: #fff;
}

button {
  font-family: var(--font-head);
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--s3) var(--s5);
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--ease), transform var(--ease), box-shadow var(--ease);
}

button:hover {
  background: var(--ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

button:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button[disabled] { opacity: 0.55; cursor: progress; }

/* Two equal tiles, one per side of the card, rather than two bare inputs
 * sized by whatever filename happens to be in them. */
.sides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s5);
}

.side {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  background: var(--tint);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--heading);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

.side:hover,
.side:focus-within { border-color: var(--primary); background: var(--surface); }

.side input[type="file"] {
  width: 100%;
  padding: var(--s2);
  background: var(--surface);
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}

.side input[type="file"]::file-selector-button {
  margin-right: var(--s3);
  padding: var(--s1) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--wash);
  color: var(--heading);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.side input[type="file"]:hover::file-selector-button { border-color: var(--primary); }

/* ----------------------------------------------------------- the field table */

.side-block { margin-bottom: var(--s5); }

.side-block h3 {
  margin: 0 0 var(--s3);
  font-family: var(--font-head);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--eyebrow);
}

.field {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr auto;
  gap: var(--s3);
  align-items: center;
  padding: var(--s2) var(--s2);
  border-radius: var(--radius);
  border-bottom: 1px solid var(--wash);
  transition: background var(--ease);
}

.field:hover { background: var(--tint); }

.field > .name {
  font-size: 0.8125rem;
  color: var(--muted);
  word-break: break-word;
}

.field input[type="text"] {
  width: 100%;
  line-height: var(--line-deva);
}

.field > .state {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* On the card, but examined by no rule. Dimmed so it cannot be mistaken for a
 * field that drives a check - a placeholder here changes nothing. */
.unchecked {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px dashed var(--line);
}

.unchecked > summary {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}

.unchecked > summary::marker { color: var(--line); }
.unchecked .hint { margin: var(--s2) 0 var(--s3); font-size: 0.8125rem; }
.field[data-checked="no"] { opacity: 0.72; }

.field[data-state="low"] input[type="text"] { border-color: var(--primary); }
.field[data-state="missing"] input[type="text"] { border-style: dashed; }
.field[data-state="corrected"] input[type="text"] { border-color: var(--accent); }

/* ---------------------------------------------------------------- the result */

/* The plain-language status, in one neutral colour for all three outcomes.
 * Colouring it would re-create the pass/fail traffic light the whole result is
 * designed to avoid. */
.result-status {
  margin: 0 0 var(--s3);
  font-family: var(--font-head);
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.result-sentence {
  max-width: var(--read);
  margin: 0 0 var(--s2);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--heading);
}

/* The arithmetic behind the sentence above, set as a line of data rather than
 * as more prose. */
.result-passed {
  display: inline-block;
  margin: 0 0 var(--s4);
  padding: var(--s1) var(--s3);
  border-radius: 9999px;
  background: var(--wash);
  color: var(--muted);
  font-size: 0.875rem;
}

/* The field a reader can act on, beside the heading rather than behind a
 * disclosure. Not the emphasis colour - naming a field is not an accusation. */
.affects {
  padding: 0 var(--s2);
  border-radius: var(--radius);
  background: var(--tint);
  color: var(--primary);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 400;
}

/* No colour, by design. See the note at the top of this file. Last on the
 * page and small: a reader who stops before it has still read the result. */
.result-verdict {
  margin: var(--s5) 0 0;
  padding-top: var(--s3);
  border-top: 1px solid var(--wash);
  color: var(--muted);
  font-size: 0.8125rem;
}

.result-asserted {
  margin: 0 0 var(--s4);
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  background: var(--tint);
  color: var(--primary);
  font-size: 0.875rem;
}

/* A group that is a wall of rows is collapsed to its heading; a contradiction
 * is never collapsed, because it is the thing worth reading. */
/* Each group is a band of its own, so a long result reads as a few sections
 * rather than one undifferentiated column. */
.group {
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--wash);
}

.group > h3 {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: baseline;
  margin: 0 0 var(--s2);
  font-family: var(--font-head);
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--heading);
}

.group details > summary {
  display: inline-flex;
  gap: var(--s2);
  align-items: center;
  width: fit-content;
  cursor: pointer;
  margin-bottom: var(--s2);
  padding: var(--s1) 0;
  color: var(--primary);
  font-size: 0.8125rem;
  list-style: none;
}

.group details > summary::-webkit-details-marker { display: none; }

/* A disclosure the reader can see is a disclosure: a chevron that turns, in
 * place of the browser's triangle, which several of them hide outright. */
.group details > summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--ease);
}

.group details[open] > summary::before { transform: rotate(45deg); }
.group details > summary:hover { text-decoration: underline; }
.group details[open] > summary { margin-bottom: var(--s3); }

.group .count {
  padding: 0 var(--s2);
  border-radius: 9999px;
  background: var(--wash);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
}

.group .why {
  max-width: var(--read);
  margin: 0 0 var(--s3);
  color: var(--muted);
  font-size: 0.875rem;
}

.findings { margin: 0; padding: 0; list-style: none; }

.finding {
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s2);
  border-radius: var(--radius);
  background: var(--wash);
  border-left: 3px solid transparent;
}

.finding-message { max-width: var(--read); margin: 0; color: var(--heading); }

.finding-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin: var(--s1) 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.finding-meta code {
  padding: 0 var(--s1);
  border-radius: 3px;
  background: rgba(169, 177, 193, 0.18);
  font-size: 0.75rem;
}

/* The one emphasis on the page. --attention appears here and nowhere else. */
.group[data-reason="contradiction"] > h3 { color: var(--attention); }
.finding[data-reason="contradiction"] {
  border-left-color: var(--attention);
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

/* An instruction to re-photograph, not a finding about the paper. */
.finding[data-reason="unreadable"] {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
}

/* "We cannot say." Lowest contrast on the page. */
.finding[data-reason="unsupported"],
.finding[data-reason="not_applicable"] {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.finding[data-reason="satisfied"] {
  padding: var(--s2) var(--s4);
  background: transparent;
  border-left-color: var(--wash);
  color: var(--muted);
  font-size: 0.875rem;
}

/* ----------------------------------------------------------------- the rules */

.rules { margin: 0; padding: 0; list-style: none; }

.rules li {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: baseline;
  padding: var(--s3) var(--s2);
  border-radius: var(--radius);
  border-bottom: 1px solid var(--wash);
  transition: background var(--ease);
}

.rules li:hover { background: var(--tint); }
.rules li:last-child { border-bottom: 0; }

.rules code { font-size: 0.8125rem; color: var(--primary); }

.rules .rule-text { flex: 1 1 18rem; font-size: 0.875rem; }

.rules .sev {
  padding: 0 var(--s2);
  border-radius: 9999px;
  font-family: var(--font-head);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rules .sev[data-severity="hard"] {
  background: var(--ink);
  color: #fff;
}

.rules .sev[data-severity="soft"] {
  background: var(--wash);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ------------------------------------------- what was read, folded under it */

.working {
  margin: var(--s3) 0 0;
  color: var(--primary);
  font-size: 0.875rem;
}

.read-back {
  margin-top: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--wash);
}

.read-back > summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
}

.read-back > summary::marker { color: var(--muted); }
.read-back[open] > summary { margin-bottom: var(--s3); }

#step-rules > details > summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
}

.read-back > summary:hover,
#step-rules > details > summary:hover { text-decoration: underline; }

/* --------------------------------------------------------------- a problem */

.problem {
  margin: var(--s4) 0 0;
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--heading);
  font-size: 0.875rem;
}

@media (max-width: 640px) {
  /* The site's 30px gutter is too much of a phone's width. */
  :root { --gutter: 16px; }
  .field { grid-template-columns: 1fr; gap: var(--s2); }
  .field > .state { white-space: normal; }
  .card { padding: var(--s5) var(--s4); }
  .card h2, .result-sentence { font-size: 1.1875rem; }
  .result-status { font-size: 1.5rem; }
  button { width: 100%; }
  .topbar { position: static; }
}

/* Every transition above is decoration on a state change that is already
 * visible without it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
