/* Forum Search — "Answer First".
 *
 * The fix is the headline. The thread title sits underneath it as a citation.
 * You read answers here; the link is there to check the source, not to go and
 * find out. Every other decision follows from that inversion.
 *
 * Hand-written, no build step, no framework. It has to be editable on the
 * server at 2am without a toolchain.
 *
 * Contrast: every foreground/background pair below is checked in
 * tests/test_forum_web.py against WCAG — AA everywhere, AAA for body text.
 * Change a colour and that test tells you what you broke.
 */

:root {
  --bg:      #FDFBF7;  /* warm off-white, not clinical white */
  --ink:     #16140F;  /* body text — 17.6:1 on --bg, AAA */
  --soft:    #57514A;  /* metadata  —  7.4:1 on --bg, AAA  */
  --rule:    #E7E0D3;
  --accent:  #14594A;  /* solved    —  7.4:1 on --bg, AAA  */
  --amber:   #7A5510;  /* inferred  —  6.4:1 on --bg, AA   */
  --mark-bg: #FBEFC4;
  --focus:   #14594A;
  --measure: 44rem;    /* ~72 characters — the readable line length */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Keyboard users get a real, visible focus ring everywhere. Never removed. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--ink); color: var(--bg);
  padding: .7rem 1.1rem; text-decoration: none;
}
.skip:focus { left: .5rem; top: .5rem; }

main:focus { outline: none; }

/* ───────────────────────────────────────────────────────────────── header */

.top { border-bottom: 1px solid var(--rule); }

.bar {
  max-width: var(--measure);
  margin: 0 auto;
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-weight: 650;
  letter-spacing: -.015em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand i { font-style: normal; color: var(--accent); }

/* ──────────────────────────────────────────────────────────── search form */

.find { flex: 1; display: flex; min-width: 0; }

.find input[type=search] {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: #fff;
  padding: .58rem .95rem;
  border: 1px solid var(--rule);
  border-right: 0;
  border-radius: 999px 0 0 999px;
}
.find input[type=search]::placeholder { color: var(--soft); opacity: 1; }

.find button {
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  padding: .58rem 1.15rem;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0 999px 999px 0;
  cursor: pointer;
}
.find button:hover { background: #10493C; border-color: #10493C; }

/* ─────────────────────────────────────────────────────────────────── home */

.hero {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 5rem 1.5rem 4rem;
}
.hero h1 {
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 0 0 .75rem;
}
.hero .lede {
  font-size: 1.06rem;
  color: var(--soft);
  margin: 0 0 2rem;
  max-width: 34rem;
}
.hero .lede em { color: var(--ink); font-style: normal; font-weight: 600; }
.hero .find { max-width: 34rem; }

.examples { margin: 2.25rem 0 0; }
.examples h2 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--soft);
  font-weight: 600;
  margin: 0 0 .6rem;
}
.examples ul { list-style: none; margin: 0; padding: 0; }
.examples li { margin: 0 0 .35rem; }
.examples a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.examples a:hover { border-bottom-color: currentColor; }

/* ──────────────────────────────────────────────────────────────── results */

.results-wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 5rem;
}

.asked {
  font-size: 1.3rem;
  line-height: 1.35;
  letter-spacing: -.01em;
  margin: 0 0 .35rem;
}

.sub { color: var(--soft); font-size: .9rem; margin: 0 0 1.25rem; }
.took { opacity: .75; }

.notice {
  border-left: 3px solid var(--amber);
  padding: .7rem 0 .7rem 1rem;
  color: var(--soft);
}

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .5rem; }
.chip {
  font-size: .84rem;
  padding: .26rem .75rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
}
.chip:hover { border-color: var(--soft); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* The list. Rules between items rather than boxes around them — a card grid
 * turns a reading surface into a dashboard, and this is for reading. */
.answers { list-style: none; margin: 0; padding: 0; }

.answers li {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}

/* The fix, as the headline. */
.fix {
  font-size: 1.14rem;
  line-height: 1.5;
  margin: 0 0 .6rem;
}
.fix::before {
  content: "";
  display: inline-block;
  width: .55rem; height: .55rem;
  border-radius: 50%;
  background: var(--accent);
  margin-right: .6rem;
  vertical-align: .11em;
  flex: none;
}
.answers li.inferred .fix::before { background: var(--amber); }
.answers li.unsolved .fix::before { background: var(--rule); }
.fix.quiet { color: var(--soft); font-size: 1.02rem; }

mark { background: var(--mark-bg); color: inherit; padding: 0 .1em; }

/* The citation. Smaller, quieter, but everything needed to judge and verify. */
.cite { font-size: .855rem; line-height: 1.55; color: var(--soft); margin: 0; }
.cite a { color: var(--soft); text-decoration: none; border-bottom: 1px solid var(--rule); }
.cite a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.cite .src { color: var(--ink); font-weight: 550; }
.cite .conf {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 650;
  color: var(--accent);
}
.answers li.inferred .cite .conf { color: var(--amber); }
.answers li.unsolved .cite .conf { color: var(--soft); }
.mirrors { font-style: italic; }

.empty { margin: 1.5rem 0 0; }
.empty h2 { font-size: 1rem; margin: 0 0 .6rem; }
.empty ul { margin: 0 0 1rem; padding-left: 1.15rem; color: var(--soft); }
.empty li { margin: 0 0 .4rem; }
.empty em { color: var(--ink); font-style: normal; font-weight: 600; }

.pager { display: flex; gap: 1.5rem; margin: 2.5rem 0 0; }
.pager a { color: var(--accent); text-decoration: none; font-weight: 550; }
.pager a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ──────────────────────────────────────────────────────────── prose pages */

.prose {
  max-width: 38rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}
.prose h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 1rem; letter-spacing: -.015em; }
.prose h2 { font-size: 1.06rem; margin: 2.25rem 0 .6rem; }
.prose p, .prose li { margin: 0 0 .9rem; }
.prose .lede { font-size: 1.05rem; color: var(--soft); }
.prose ul { padding-left: 1.15rem; }
.prose a { color: var(--accent); }
.prose code {
  font: .88em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #F3EEE3;
  padding: .1em .35em;
  border-radius: 3px;
}
.prose pre {
  background: #F3EEE3;
  padding: .9rem 1.1rem;
  border-radius: 4px;
  overflow-x: auto;          /* long robots.txt lines scroll, page never does */
}
.prose pre code { background: none; padding: 0; }

.facts { margin: 0; }
.facts dt { font-weight: 650; margin: 1rem 0 .2rem; }
.facts dd { margin: 0; color: var(--soft); }

/* ───────────────────────────────────────────────────────────────── footer */

.foot {
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
  padding: 1.75rem 0 3rem;
  font-size: .85rem;
  color: var(--soft);
}
/* Padding lives on the inner elements, not on .foot, so the footer's left edge
 * lines up with the content column above it. With padding on the outer box the
 * centring maths differ by the padding width and the mismatch is visible. */
.foot nav, .foot p {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.foot nav { margin-bottom: .6rem; display: flex; flex-wrap: wrap; gap: 1.25rem; }
.foot nav a { color: var(--soft); }

/* ───────────────────────────────────────────────────────────── responsive */

@media (max-width: 34rem) {
  body { font-size: 16px; }
  .bar { flex-wrap: wrap; padding: .75rem 1rem; }
  /* flex-basis, not width: `.find` carries `flex: 1` which sets flex-basis to
   * 0, and flex-basis beats width on a flex item — so `width: 100%` alone left
   * the input sharing the row with the wordmark and truncating the query to
   * about twelve characters on a phone. */
  .find { flex: 1 0 100%; order: 3; }
  .hero { padding: 2.75rem 1.25rem 3rem; }
  .hero h1 { font-size: 1.65rem; }
  .results-wrap, .prose { padding-left: 1.25rem; padding-right: 1.25rem; }
  .fix { font-size: 1.06rem; }
}

/* Respect the setting. Nothing here animates, but a future addition shouldn't
 * have to remember to. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Printing a repair answer to take out to the garage is a real thing people do. */
@media print {
  .top, .foot, .filters, .pager, .find { display: none; }
  body { background: #fff; font-size: 11pt; }
  .answers li { break-inside: avoid; border-top: 1px solid #ccc; }
  .cite a::after { content: " (" attr(href) ")"; font-size: .8em; }
}
