/*
 * CT FOI Request Tracker: the tracker's own parts (forms, tables, badges,
 * timeline, letters), drawn on the terminal of retro.css with its colours.
 * Plain form fields are styled through :where() so retro.css's classes
 * (.field, .check) still win. No build step, no inline styles (the CSP
 * forbids them).
 */

/* --- text --- */
h1 {
  margin: 0 0 1rem;
  color: var(--crt-accent);
  text-shadow: var(--crt-glow);
  font-size: 1.45em;
  line-height: 1.35;
  letter-spacing: .02em;
}
h1::before { content: "> "; }
h2 { margin-top: 2.5rem; }
h2:first-child, h1.sr-only + h2, .page-head h2 { margin-top: 0; }
h3 { font-size: 1em; margin: 1.75rem 0 .5rem; }
h3:first-child { margin-top: 0; }
p, ul, ol, dl, address, table { margin-top: 0; margin-bottom: 1rem; }
ul, ol { padding-left: 3ch; }
li { margin-bottom: .3rem; }
small { font-size: .85em; }
cite { font-style: italic; }
.muted, small.muted { color: var(--crt-dim); }
.lead { font-size: 1.05em; }
.prose { max-width: 50rem; }
.prose h2 { margin-top: 2.75rem; }
.narrow { max-width: 40rem; }
.narrow-wide { max-width: 50rem; }
address { font-style: normal; padding-left: 1.5ch; border-left: 2px solid var(--crt-rule); }

/* --- forms: includes/form.html wraps each widget in its label --- */
:where(label) { display: block; margin: 0 0 1.1rem; color: var(--crt-dim); }
:where(label) > :where(input, select, textarea) { margin-top: .3rem; }
:where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="submit"], [type="button"]), select, textarea) {
  display: block;
  width: 100%;
  padding: .45rem .75ch;
  border: 1px solid var(--crt-rule);
  border-radius: 3px;
  background: rgb(0 0 0 / .35);
  color: var(--crt-text);
  caret-color: var(--crt-accent);
  font: inherit;
}
:where(input, select, textarea):focus { outline: none; border-color: var(--crt-accent); box-shadow: 0 0 0 1px var(--crt-accent), var(--crt-glow); }
:where(input, textarea)::placeholder { color: var(--crt-dim); opacity: .8; }
:where(input, textarea)[readonly] { background: rgb(0 0 0 / .2); }
:where(select) option { background: var(--crt-bg); color: var(--crt-text); }
:where(textarea) { resize: vertical; line-height: 1.55; }
textarea.letter { font-size: .9em; line-height: 1.5; }
:where(input[type="date"])::-webkit-calendar-picker-indicator { filter: invert(.8) sepia(1) saturate(3) hue-rotate(-10deg); cursor: pointer; }
:where(input[type="file"]) { display: block; margin-top: .4rem; color: var(--crt-dim); font: inherit; font-size: .9em; }
:where(input[type="file"])::file-selector-button {
  margin-right: 1.5ch;
  padding: .3rem 1.5ch;
  border: 1px solid var(--crt-accent);
  border-radius: 3px;
  background: transparent;
  color: var(--crt-accent);
  font: inherit;
  cursor: pointer;
}
:where(input[type="radio"]) { accent-color: var(--crt-accent); }
/* Drag and drop around a file field (app.js). */
.dropzone { display: block; margin-top: .4rem; padding: .9rem 2ch; border: 1px dashed var(--crt-rule); border-radius: 4px; background: rgb(0 0 0 / .2); transition: border-color .15s, background-color .15s; }
.dropzone > input[type="file"] { margin-top: .35rem; }
.dropzone-hint { display: block; color: var(--crt-text); }
.dropzone-status { display: block; margin-top: .35rem; color: var(--crt-dim); font-size: .9em; }
.dropzone.dragging { border-color: var(--crt-accent); border-style: solid; background: rgb(255 181 71 / .1); box-shadow: var(--crt-glow); }
.dropzone.has-file .dropzone-status { color: var(--crt-ok); }
.dropzone.error { border-color: var(--crt-alert); }
.dropzone.error .dropzone-status { color: var(--crt-alert); }
@media (prefers-reduced-motion: reduce) { .dropzone { transition: none; } }
label small { display: block; margin-top: .25rem; color: var(--crt-dim); }
small.error { color: var(--crt-alert); }
small.error::before { content: "Error: "; font-weight: 700; }
[aria-invalid="true"] { border-color: var(--crt-alert); }
/* A checkbox field: the box, its label, then the help text on its own line. */
label.check { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 1ch; margin: .25rem 0 1.25rem; color: var(--crt-text); }
label.check small { flex-basis: 100%; padding-left: 4ch; }
.check input:focus-visible { outline: 2px solid var(--crt-accent); outline-offset: 2px; }
fieldset { margin: 0 0 1rem; padding: .75rem 2ch; border: 1px dashed var(--crt-rule); }
legend { padding: 0 1ch; color: var(--crt-accent); }

/* --- buttons: amber for the main action, outlined for the rest --- */
button, input[type="submit"], [role="button"] {
  display: inline-block;
  padding: .45rem 2.5ch;
  border: 1px solid var(--crt-accent);
  border-radius: 3px;
  background: var(--crt-accent);
  color: var(--crt-bg);
  font: inherit;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.5;
  text-decoration: none;
  text-align: center;
  box-shadow: var(--crt-glow);
  cursor: pointer;
}
button:hover, input[type="submit"]:hover, [role="button"]:hover { background: #ffc66e; border-color: #ffc66e; }
:where(button, [role="button"]):focus-visible { outline: 2px solid var(--crt-text); outline-offset: 2px; }
.secondary, [role="button"].secondary { background: transparent; color: var(--crt-accent); box-shadow: none; font-weight: 600; }
.secondary:hover, [role="button"].secondary:hover { background: rgb(255 181 71 / .12); }
.small { font-size: .85em; }
[role="button"].small, button.small { padding: .2rem 1.5ch; }
.linklike, .linklike:hover {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--crt-accent);
  font-weight: inherit;
  letter-spacing: normal;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.linklike.small { padding: 0; }
.danger, .linklike.danger { color: var(--crt-alert); }
.danger-button, .danger-button:hover { background: var(--crt-alert); border-color: var(--crt-alert); box-shadow: 0 0 6px rgb(255 138 122 / .45); }
form.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem 1.5ch; align-items: center; margin-bottom: 1rem; }
.actions > * { margin: 0; }
.offscreen { position: fixed; left: -9999px; top: 0; }

/* --- layout --- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .5rem 2ch; margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .25rem; }
.page-head .actions { margin: 0; }
.meta { margin: 0; color: var(--crt-dim); }
.grid { display: grid; gap: 0 2ch; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); align-items: start; }
.grid-2 { display: grid; gap: 1rem 2ch; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); margin-bottom: 1rem; }
.grid-auto { display: grid; gap: 0 2ch; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.grid-2 > article { padding: 1rem 2ch; border: 1px solid var(--crt-rule); border-radius: 3px; background: rgb(0 0 0 / .2); }
.grid-2 > article > :last-child { margin-bottom: 0; }
.split { display: grid; gap: 2rem 3ch; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin-bottom: 1rem; }
.split aside { align-self: start; padding: 1.25rem 2ch; border: 1px solid var(--crt-rule); border-radius: 4px; background: rgb(0 0 0 / .25); }
.split aside h2 { font-size: 1.05em; }
.split aside ol { padding-left: 3ch; }

/* --- disclosure boxes, like the workflow's "What counts as prompt?" --- */
details { margin: 0 0 1rem; padding: .5rem 1.5ch; border: 1px dashed var(--crt-rule); border-radius: 3px; }
details > summary { color: var(--crt-accent); cursor: pointer; }
details > summary::marker { content: "[+] "; }
details[open] > summary::marker { content: "[-] "; }
details[open] > summary { margin-bottom: .75rem; }
details > :last-child { margin-bottom: 0; }
.add-event { padding: 0; border: 0; }
.add-event > summary[role="button"] { display: inline-block; list-style: none; }
.add-event > summary[role="button"]::marker, .add-event > summary::-webkit-details-marker { content: ""; display: none; }
.add-event > summary::before { content: "+ "; }
.add-event[open] > summary::before { content: "- "; }
.add-event form { max-width: 40rem; margin-top: 1rem; }

/* --- tables --- */
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.table-wrap table { margin-bottom: 0; }
table { width: 100%; border-collapse: collapse; font-size: .92em; }
th, td { padding: .5rem 1.5ch; text-align: left; vertical-align: top; }
th {
  color: var(--crt-dim);
  font-weight: 600;
  font-size: .85em;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--crt-rule);
}
td { border-bottom: 1px dashed var(--crt-rule); }
table.striped tbody tr:nth-child(odd) { background: rgb(0 0 0 / .2); }
tbody tr:hover { background: rgb(255 181 71 / .05); }
td small { color: var(--crt-dim); }

/* --- filters, tabs, pages --- */
.filters { margin-bottom: 1rem; }
/* Group dashboard: totals by stage. */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .5rem 1.5ch; margin: 0 0 1.75rem; padding: 0; }
.totals div { padding: .5rem 1.5ch; border: 1px solid var(--crt-rule); border-radius: 3px; background: rgb(0 0 0 / .2); }
.totals dt { color: var(--crt-dim); font-size: .85em; }
.totals dd { margin: 0; color: var(--crt-accent); font-size: 1.4em; font-weight: 700; }
.totals .alert dd { color: var(--crt-alert); }
.filters :where(input, select, button) { margin: 0 0 .75rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem 2.5ch; margin: 0 0 .75rem; padding: 0; list-style: none; }
.tabs li { margin: 0; }
.tabs a { text-decoration: none; }
.tabs a::before { content: "[ ] "; color: var(--crt-dim); }
.tabs a[aria-current="page"] { color: var(--crt-text); font-weight: 700; }
.tabs a[aria-current="page"]::before { content: "[x] "; color: var(--crt-accent); }
.pager { display: flex; flex-wrap: wrap; gap: 1rem 3ch; justify-content: center; margin-block: 1rem; color: var(--crt-dim); }
.pager a:first-child::before { content: "< "; }
.pager a:last-child::after { content: " >"; }

/* --- messages and callouts --- */
.messages { margin-bottom: 1.5rem; }
.message { margin: 0 0 .5rem; padding: .5rem 1.5ch; border-left: 3px solid var(--crt-dim); background: rgb(0 0 0 / .25); }
.message-success { border-color: var(--crt-ok); }
.message-success::before { content: "OK: "; color: var(--crt-ok); font-weight: 700; }
.message-error { border-color: var(--crt-alert); }
.message-error::before { content: "Error: "; color: var(--crt-alert); font-weight: 700; }
.message-warning { border-color: var(--crt-accent); }
.message-warning::before { content: "Warning: "; color: var(--crt-accent); font-weight: 700; }
.message .errorlist, .message ul { margin: 0; padding: 0; list-style: none; }
.callout {
  margin: 0 0 1.75rem;
  padding: 1rem 2ch;
  border: 1px solid var(--crt-rule);
  border-left: 4px solid var(--crt-dim);
  border-radius: 3px;
  background: rgb(0 0 0 / .25);
}
.callout h2 { margin: 0 0 .75rem; font-size: 1.05em; }
.callout-warning { border-left-color: var(--crt-alert); }
.callout-warning h2 { color: var(--crt-alert); text-shadow: 0 0 6px rgb(255 138 122 / .4); }
.callout-info { border-left-color: var(--crt-accent); }
.callout > :last-child { margin-bottom: 0; }

/* --- status and deadline badges --- */
.badge, .status {
  display: inline-block;
  padding: 0 .75ch;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-size: .8em;
  line-height: 1.6;
  white-space: nowrap;
  color: var(--crt-dim);
}
.badge.urgent { color: var(--crt-alert); font-weight: 700; }
.badge.soon { color: var(--crt-accent); font-weight: 600; }
.badge.later { color: var(--crt-ok); }
.status { color: var(--crt-text); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.status-draft, .status-withdrawn, .status-closed { color: var(--crt-dim); }
.status-fulfilled { color: var(--crt-ok); }
.status-denied { color: var(--crt-alert); }
.status-complaint_filed, .status-hearing, .status-decided, .status-appealed { color: var(--crt-case); }

/* --- home --- */
.hero { padding: 0 0 1rem; }
.hero h1 { font-size: 1.7em; max-width: 40rem; }
.hero .actions { margin-top: 1.25rem; }
.hero-more { margin: 0 0 1.5rem; }
.steps-brief { counter-reset: step; margin: 0 0 1rem; padding: 0; list-style: none; }
.steps-brief li { counter-increment: step; margin: 0 0 .4rem; }
.steps-brief li::before { content: "[" counter(step) "] "; color: var(--crt-accent); font-weight: 700; text-shadow: var(--crt-glow); }
.steps-brief strong { text-transform: uppercase; letter-spacing: .04em; }
.stepper { counter-reset: step; display: grid; gap: .75rem 2ch; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); padding: 0; list-style: none; }
.stepper li { counter-increment: step; margin: 0; padding: .9rem 1.5ch; border: 1px solid var(--crt-rule); border-radius: 3px; background: rgb(0 0 0 / .2); }
.stepper li::before { content: "[" counter(step) "] "; color: var(--crt-accent); font-weight: 700; text-shadow: var(--crt-glow); }
.stepper strong { text-transform: uppercase; letter-spacing: .04em; }
.stepper span { display: block; margin-top: .35rem; font-size: .88em; color: var(--crt-dim); }

/* --- request page --- */
.stages { display: flex; margin: 0 0 1.75rem; padding: 0; list-style: none; overflow-x: auto; border: 1px solid var(--crt-rule); border-radius: 3px; }
.stages li { flex: 1 1 0; min-width: 7rem; margin: 0; padding: .4rem .5ch; text-align: center; font-size: .82em; color: var(--crt-dim); border-right: 1px solid var(--crt-rule); }
.stages li:last-child { border-right: 0; }
.stages li.done { color: var(--crt-text); background: rgb(255 181 71 / .08); }
.stages li.done::before { content: "✓ "; color: var(--crt-ok); }
.stages li.current { color: var(--crt-bg); background: var(--crt-accent); font-weight: 700; }
.stages a { color: inherit; }
.deadlines ul, ul.deadlines { padding: 0; list-style: none; }
.deadlines li { margin-bottom: .75rem; }
.deadlines small { color: var(--crt-dim); }
.inline-list { display: flex; flex-wrap: wrap; gap: .5rem 3ch; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 2ch; }
.facts dt { color: var(--crt-dim); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.records { margin-bottom: 1rem; padding: .75rem 2ch; border: 1px solid var(--crt-rule); border-radius: 3px; background: rgb(0 0 0 / .25); }
.records > :last-child { margin-bottom: 0; }
/* The timeline: entries on a dashed line, like the workflow's steps. */
.timeline { margin: 0 0 1.5rem 1ch; padding: 0; list-style: none; border-left: 1px dashed var(--crt-rule); }
.timeline li { position: relative; display: grid; grid-template-columns: 9rem 1fr; gap: .25rem 2ch; margin: 0; padding: 0 0 1.25rem 3ch; }
.timeline li::before { content: "■"; position: absolute; left: -.5ch; top: 0; line-height: 1.7; background: var(--crt-bg); color: var(--crt-accent); }
.timeline li.kind-denied::before { color: var(--crt-alert); }
.timeline li.kind-fulfilled::before, .timeline li.kind-partial::before { color: var(--crt-ok); }
.timeline li[class*="kind-complaint"]::before, .timeline li[class*="kind-hearing"]::before, .timeline li.kind-final_decision::before, .timeline li.kind-report_issued::before, .timeline li.kind-docketed::before { color: var(--crt-case); }
.timeline time { color: var(--crt-dim); font-size: .9em; }
.timeline .details { font-size: .95em; }
.timeline .details > :last-child, .timeline p { margin-bottom: .25rem; }

/* --- copy-and-paste email parts (foi/includes/email_parts.html) --- */
.email-parts { margin: 1.25rem 0 1.5rem; padding: .75rem 1.5ch; border: 1px dashed var(--crt-rule); border-radius: 3px; }
.email-parts h3 { margin: 0 0 .25rem; font-size: 1em; }
.email-parts dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1.5ch; align-items: center; margin: .5rem 0 .75rem; }
.email-parts dt { color: var(--crt-dim); font-size: .9em; }
.email-parts dt label { display: inline; margin: 0; color: inherit; font-weight: inherit; }
.email-parts dd { display: flex; gap: 1ch; margin: 0; min-width: 0; }
.email-parts dd input { margin: 0; padding: .2rem .75ch; min-width: 0; font-size: .9em; }
.email-parts dd button { flex: none; margin: 0; }
.email-parts .copy-status { margin: .5rem 0 0; font-size: .85em; }
.email-parts .copy-status:empty { display: none; }

/* --- agency page: the contact details typed on a ruled index card --- */
.index-card {
  --card-line: 1.75rem;
  --card-ink: #2a2620;
  position: relative;
  z-index: 11; /* above the CRT scanlines: paper, not phosphor */
  max-width: 38rem;
  margin: .5rem 0 2.5rem;
  padding: .55rem 3ch var(--card-line);
  color: var(--card-ink);
  background:
    linear-gradient(transparent calc(2.8rem - 2px), #d9534f calc(2.8rem - 2px), #d9534f 2.8rem, transparent 2.8rem) no-repeat,
    repeating-linear-gradient(transparent 0 calc(var(--card-line) - 1px), #a9c4e0 calc(var(--card-line) - 1px) var(--card-line)) 0 2.8rem / 100% calc(100% - 2.8rem) no-repeat,
    #f5eedb;
  border-radius: 2px;
  box-shadow: 0 1px 0 #d8ceb4, 0 10px 24px rgb(0 0 0 / .55);
  transform: rotate(-.7deg);
  font: 16px/var(--card-line) "Courier New", Courier, monospace;
  text-shadow: 0 0 .6px rgb(42 38 32 / .7);
}
.index-card h2 {
  margin: 0 0 .55rem;
  color: var(--card-ink);
  text-shadow: inherit;
  font: inherit;
  font-weight: 700;
  line-height: 2.2rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.index-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 0 3ch; margin: 0; }
.index-card dt { text-transform: uppercase; }
.index-card dt::after { content: ":"; }
.index-card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.index-card a { color: #1d3f8a; text-decoration-color: rgb(29 63 138 / .4); }
.index-card a:focus-visible { outline-color: #1d3f8a; }
.index-card .muted { color: #8a8170; }

/* --- groups --- */
.role-form { display: flex; gap: 1ch; align-items: center; }
.role-form select { width: auto; padding-block: .15rem; }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.4em; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: .6rem; }
  /* Narrow screens: a straight card, each label on its own ruled line. */
  .index-card { transform: none; padding-inline: 2ch; }
  .index-card dl { grid-template-columns: 1fr; }
  .index-card dd { padding-left: 2ch; }
}

/* Statute links (core/statutes.py): never break "§ 1-206(a)" at the hyphen. */
a.statute { white-space: nowrap; }
