/* A law report on paper: the passage is the exhibit. Tier and in-force state carry colour,
   always next to words that say the same; everything else is ink, rules and type. */

:root {
  --paper: #f7f4ec;
  --panel: #efe9dc;
  --ink: #1d1b16;
  --ink-soft: #5a5446;
  --rule: #d6cdb9;
  --rule-strong: #a99f88;
  --accent: #0d5e66;
  --accent-wash: #d5eae8;
  --ok: #1d6b39;
  --bad: #a1261d;
  --statute: #1f3f73;
  --guidance: #0d5e66;
  --note: #8a5300;
  --code-bg: #e8e1d1;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text: clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
  --small: 0.875rem;
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --fast: 150ms;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15140f;
    --panel: #1e1c16;
    --ink: #ece5d5;
    --ink-soft: #b0a793;
    --rule: #3b372d;
    --rule-strong: #645d4c;
    --accent: #7cc8cf;
    --accent-wash: #173a3d;
    --ok: #82cf9c;
    --bad: #f39188;
    --statute: #9db8ea;
    --guidance: #7cc8cf;
    --note: #e6b85a;
    --code-bg: #24221b;
  }
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--text) / 1.55 var(--sans);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1.1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}

h4 {
  font-family: var(--serif);
  font-size: 1rem;
  margin: 0;
}

code,
pre,
.kicker,
.label,
.case-id {
  font-family: var(--mono);
}

code {
  font-size: 0.9em;
}

.masthead {
  padding: var(--gutter) var(--gutter) 1rem;
  border-bottom: 4px double var(--rule-strong);
}

.kicker {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

h1 {
  font-size: clamp(1.6rem, 1.1rem + 2.6vw, 2.9rem);
  max-width: 22ch;
}

.notices {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem;
  max-width: 75ch;
}

.notice {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--accent);
  background: var(--panel);
  font-size: var(--small);
  max-width: 75ch;
}

.build,
.quiet {
  margin: 0;
  font-size: var(--small);
  color: var(--ink-soft);
}

main {
  padding: 0 var(--gutter) var(--gutter);
  min-height: 100svh;
}

/* Until the first file loads, the sections keep their place but stay unseen, so nothing on
   screen moves when the data arrives. */
main[aria-busy="true"] > :not(noscript) {
  visibility: hidden;
}

.runs {
  margin: 0;
  padding-left: 1.1rem;
}

.controls {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}

.field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

label {
  font-weight: 600;
}

select,
button {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 0.4rem 0.7rem;
  min-height: 2.5rem;
  max-width: 100%;
}

.alert {
  border-left: 4px solid var(--bad);
  padding: 0.5rem 0.75rem;
  background: var(--panel);
}

/* The case list and the detail, side by side on wide screens. */
.workspace {
  display: grid;
  gap: 1.5rem;
  padding-top: 1.5rem;
}

.workspace > * {
  min-width: 0;
}

@media (min-width: 64rem) {
  .workspace {
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    align-items: start;
  }

  .cases {
    position: sticky;
    top: 1rem;
  }

  .case-list {
    max-height: calc(100vh - 13rem);
  }

  .detail {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-bottom: 0.5rem;
}

/* The list scrolls on its own, so the detail stays one swipe away on a phone. */
.case-list {
  max-height: 60vh;
  overflow-y: auto;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border-top: 2px solid var(--rule-strong);
}

.case-list button {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  transition: background-color var(--fast);
}

.case-list button:hover {
  background: var(--panel);
}

.case-list button[aria-current="true"] {
  background: var(--accent-wash);
  box-shadow: inset 4px 0 0 var(--accent);
}

.case-id {
  font-size: var(--small);
  font-weight: 700;
}

.case-q {
  font-family: var(--serif);
}

.case-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: var(--small);
}

.tag {
  font-size: 0.75rem;
  padding: 0 0.4rem;
  margin-left: 0.4rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-soft);
}

.case-tags .tag {
  margin-left: 0;
}

.outcome::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 0.05em;
}

[data-outcome="correct"] {
  color: var(--ok);
}

[data-outcome="not_correct"],
[data-outcome="attack_through"] {
  color: var(--bad);
}

/* The detail: the question as a citation, the answer, then the exhibits. */
.detail {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--ink);
  padding: 1rem clamp(0.75rem, 0.5rem + 1vw, 1.5rem) 1.5rem;
}

.question {
  margin: 0 0 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--rule-strong);
  font-family: var(--serif);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 1rem;
  margin: 0 0 1rem;
  font-size: var(--small);
}

.facts dt {
  color: var(--ink-soft);
}

.facts dd {
  margin: 0;
}

.part {
  margin-bottom: 1rem;
}

.verdict {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

.repeats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--small);
  color: var(--ink-soft);
}

.model-text {
  font-family: var(--serif);
  font-size: 1.05rem;
  white-space: pre-wrap;
}

.claims {
  padding-left: 1.25rem;
}

.claims > li {
  margin-bottom: 0.75rem;
}

.claims > li > p {
  margin: 0 0 0.4rem;
}

.passage {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--guidance);
  padding: 0.6rem 0.75rem;
  margin: 0 0 0.6rem;
}

.passage[data-tier="T1"] {
  border-left-color: var(--statute);
}

.passage[data-tier="T3"] {
  border-left-color: var(--note);
  border-left-style: dashed;
}

.passage p {
  margin: 0.15rem 0;
}

.label {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.passage .id {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.in-force,
.out-of-force {
  font-size: var(--small);
}

.in-force {
  color: var(--ok);
}

.out-of-force {
  color: var(--bad);
}

.in-force::before {
  content: "\2713  ";
}

.out-of-force::before {
  content: "\2717  ";
}

details {
  margin: 0.25rem 0;
}

summary {
  cursor: pointer;
  font-size: var(--small);
  font-weight: 600;
}

pre {
  margin: 0.4rem 0;
  padding: 0.6rem;
  background: var(--code-bg);
  border-radius: 3px;
  font-size: 0.8125rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 22rem;
  white-space: pre-wrap;
}

.attempt {
  border-left: 2px solid var(--rule-strong);
  padding-left: 0.75rem;
  margin-bottom: 0.75rem;
}

.errors {
  padding-left: 1.25rem;
}

.accepted {
  color: var(--ok);
  font-weight: 600;
}

.refused {
  color: var(--bad);
  font-weight: 600;
}

.footer {
  padding: 1.5rem var(--gutter) 2.5rem;
  border-top: 4px double var(--rule-strong);
  color: var(--ink-soft);
  font-size: var(--small);
}

.footer p {
  max-width: 75ch;
  margin: 0;
}

.panel {
  background: var(--panel);
  padding: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
