/* The Hitchhiker's Guide pages (guide/*.html). Builds on styles/notes.css;
   everything is scoped under `.guide`. */

.guide .guide-sub {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.guide .dont-panic {
  justify-self: start;
  margin: 6px 0 0;
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Cards come from styles/site.css (.note-cards / .note-card). */
.guide .note-cards {
  margin-top: 4px;
}

.guide .note-card-meta {
  color: var(--muted); /* the note's --faint is a surface tint, not a text colour */
}

.guide .note-cards.one {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 18px;
}

.guide .note-card.soon {
  border-style: dashed;
}

.guide .note-card.soon .note-card-title,
.guide .note-card.soon .note-card-text {
  color: var(--muted);
}

.guide .note-card.soon .note-card-title::after {
  content: none;
}

/* Lists */
.guide .steps,
.guide .ticks {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.guide .steps b,
.guide .ticks b {
  color: var(--ink);
  font-weight: 600;
}

.guide .thm {
  margin-top: 22px;
}

.guide details.math {
  margin-top: 14px;
}

/* Tables with wrapping text columns */
.guide .tool-table {
  margin-top: 14px;
}

.guide .tool-table td {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  white-space: normal;
  text-align: left;
  vertical-align: top;
}

.guide .tool-table th {
  text-align: left;
}

.guide .tool-table td:first-child {
  min-width: 150px;
  color: var(--ink);
  font-weight: 600;
}

.guide .tool-table td:last-child {
  color: var(--ink-2);
}

/* Entry cards: tools on question pages, assumptions on the field guide */
.guide .entry-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.guide .entry {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.guide .entry-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  justify-content: space-between;
}

/* Reset the site's divider-style h3. */
.guide .entry-title {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: normal;
  line-height: 1.4;
  text-transform: none;
}

.guide .entry-title::after {
  content: none;
}

.guide .entry-math {
  margin: 0;
  overflow-x: auto;
  color: var(--ink-2);
}

.guide .entry-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.guide .entry dl {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 6px 14px;
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.55;
}

.guide .entry dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 2.1;
  text-transform: uppercase;
}

.guide .entry dd {
  margin: 0;
  color: var(--ink-2);
}

.guide .verdict {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.guide .verdict.harmless {
  background: color-mix(in srgb, var(--good) 14%, transparent);
  color: var(--good);
}

.guide .verdict.ok {
  background: color-mix(in srgb, var(--mix) 14%, transparent);
  color: var(--mix);
}

.guide .verdict.red {
  background: color-mix(in srgb, var(--tail) 14%, transparent);
  color: var(--tail);
}

/* Light theme: darken badge text so it clears 4.5:1 on its tint. */
:root:not([data-theme='dark']) .guide .verdict.harmless {
  color: color-mix(in srgb, var(--good) 80%, #000);
}

:root:not([data-theme='dark']) .guide .verdict.ok {
  color: color-mix(in srgb, var(--mix) 85%, #000);
}

:root:not([data-theme='dark']) .guide .verdict.red {
  color: color-mix(in srgb, var(--tail) 70%, #000);
}

/* Worked examples */
.guide .examples {
  display: grid;
  gap: 18px;
  margin: 0;
  padding-left: 22px;
}

.guide .examples li {
  display: grid;
  gap: 6px;
}

.guide .examples p {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
}

.guide .examples .ex-cite {
  color: var(--ink);
  font-size: 15px;
}

/* "From my own work" callout */
.guide .own-work {
  display: grid;
  gap: 8px;
  margin-top: 24px;
  padding: 14px 18px;
  border-left: 2px solid var(--link);
  border-radius: 0 8px 8px 0;
  background: var(--surface);
}

.guide .own-work .label {
  color: var(--link);
}

.guide .own-work p {
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
}

.guide .guide-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* Previous / next */
.guide .pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: 44px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
}

.guide .next-link {
  margin-top: 26px;
}

@media (max-width: 640px) {
  .guide .guide-sub {
    font-size: 16.5px;
  }

  .guide .entry dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .guide .entry dd {
    margin-bottom: 8px;
  }
}

/* ---------- Question tree (hub) ---------- */

.guide .qtree-wrap {
  max-width: 692px; /* same measure as the text column */
  margin: 10px auto 0;
}

.guide .qtree {
  position: relative;
}

.guide .qtree-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.guide .qtree-root {
  display: flex;
  justify-content: center;
}

.guide .qtree-root span {
  position: relative;
  z-index: 1;
  padding: 7px 18px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide .qtree-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 46px;
}

.guide .qtree .qtree-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
}

.guide .qtree .qtree-node:hover {
  background: transparent;
  color: var(--ink);
}

.guide .qtree .qtree-node[aria-selected='true'] {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
}

.guide .qtree .qtree-node.soon {
  font-weight: 500;
}

.guide .qtree .qtree-node.soon[aria-selected='false'] {
  color: var(--muted);
}

.guide .qtree-dot {
  position: relative;
  z-index: 1;
  flex: none;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  background: var(--bg);
  transition:
    background-color 120ms ease,
    border-color 120ms ease;
}

.guide .qtree-node[aria-selected='true'] .qtree-dot {
  border-color: var(--link);
  background: var(--link);
}

.guide .qtree-dot.sm {
  width: 10px;
  height: 10px;
  border-color: var(--link);
}

.guide .qtree-chip {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--faint);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.guide .qtree-detail {
  display: grid;
  justify-items: center;
  width: min(380px, 100%);
  margin-top: 26px;
}

.guide .qtree-detail[hidden] {
  display: none;
}

.guide .qtree-detail.enter {
  animation: qtree-in 220ms ease-out;
}

@keyframes qtree-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.guide .qtree-refine,
.guide .qtree-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.4;
}

.guide .qtree-refine {
  max-width: 230px;
  color: var(--ink-2);
}

.guide .qtree-branches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-top: 30px;
}

.guide .qtree-branch {
  gap: 4px;
}

.guide .qtree-ask {
  margin-top: 2px;
  color: var(--ink);
  font-weight: 600;
}

.guide .qtree-tool {
  color: var(--muted);
}

.guide .qtree-tools {
  display: grid;
  gap: 6px;
  width: 100%;
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.guide .qtree-toollist {
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
}

.guide .qtree-costs {
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 13.5px;
}

.guide .qtree-explore {
  justify-self: start;
  font-size: 14.5px;
  font-weight: 600;
}

.guide .qtree-soon {
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Question list (hub) ---------- */

.guide .qlist-head {
  display: block;
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.guide .qlist {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.guide .qlist li {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(0, 230px);
  gap: 12px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
}

.guide .qlist-num {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13.5px;
}

.guide .qlist-title {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  color: var(--ink);
}

.guide .qlist-title a::after {
  content: ' \2192';
}

.guide .qlist-tags {
  color: var(--muted);
  font-size: 13.5px;
}

/* Narrow screens: the tree becomes a vertical list with the open branch under its question. */
@media (max-width: 720px) {
  .guide .qtree-root,
  .guide .qtree-wires {
    display: none;
  }

  .guide .qtree-row {
    display: block;
    margin-top: 6px;
  }

  .guide .qtree .qtree-node {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    text-align: left;
  }

  .guide .qtree-detail {
    justify-items: start;
    width: auto;
    margin: 4px 0 12px 5px;
    padding: 6px 0 4px 18px;
    border-left: 1.5px solid var(--link);
  }

  .guide .qtree-refine,
  .guide .qtree-branch {
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    text-align: left;
    max-width: none;
  }

  .guide .qtree-branches {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 12px;
  }

  .guide .qtree-branch .qtree-tool::before {
    content: '\2192\00a0';
  }

  .guide .qlist li {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .guide .qlist-tags {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guide .qtree-detail.enter {
    animation: none;
  }
}

/* "On this page" table of contents on chapter pages */
.guide .toc {
  margin-top: 8px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.guide .toc ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.guide .toc li {
  counter-increment: toc;
  font-size: 15px;
  line-height: 1.5;
}

.guide .toc li::before {
  content: counter(toc) '. ';
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Worked proof: claim, assumptions, first move, proof, failure mode, relaxations */
.guide .worked {
  display: grid;
  gap: 0;
  margin-top: 18px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.guide .w-step,
.guide .w-proof {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px 18px;
  border-top: 1px solid var(--rule);
}

.guide .worked > :first-child {
  border-top: 0;
}

.guide .w-step p,
.guide .w-proof p {
  margin: 0;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
}

.guide .w-step .eq,
.guide .w-proof .eq {
  overflow-x: auto;
}

.guide .w-proof summary {
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}

.guide .w-proof[open] summary {
  margin-bottom: 8px;
}

.guide .w-proof > div {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.guide .w-proof .w-comment {
  padding: 6px 12px;
  border-left: 2px solid var(--link);
  color: var(--muted);
  font-size: 14.5px;
}

/* Hub: who it is for, who wrote it */
.guide .guide-meta {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.guide .guide-meta p {
  margin: 0;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
}

/* Field guide: filter and index */
.guide .assume-filter {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.guide .filter-count {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.guide .assume-index {
  columns: 2 220px;
  column-gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  line-height: 1.7;
}

.guide .assume-index li::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--muted);
  vertical-align: 1px;
}

.guide .assume-index li[data-verdict='harmless']::before {
  background: var(--good);
}

.guide .assume-index li[data-verdict='ok']::before {
  background: var(--mix);
}

.guide .assume-index li[data-verdict='red']::before {
  background: var(--tail);
}

.guide [data-filtered],
.guide .entry[data-filtered] {
  display: none;
}

:root:not([data-theme='dark']) .guide .status.ok b {
  color: color-mix(in srgb, var(--good) 80%, #000);
}

:root:not([data-theme='dark']) .guide .status.bad b {
  color: color-mix(in srgb, var(--tail) 70%, #000);
}

/* Feedback and last-updated line at the foot of every guide page */
.guide .guide-feedback {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.guide .guide-feedback span {
  display: block;
  margin-top: 4px;
}

/* Let long display math scroll inside its box instead of widening the column. */
.guide .prose,
.guide .steps,
.guide .ticks {
  grid-template-columns: minmax(0, 1fr);
}

/* Colour swatch tying a readout value to its line in the chart */
.guide .readout .sw {
  display: inline-block;
  width: 14px;
  height: 3px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}
