/* ===========================================================================
   site.css — design system for the wrapper pages.

   The guide page is deliberately left alone. It is the primary source and
   should read as the document on the table; these pages are the reading room
   around it. Only defect fixes (§9) reach the guide.

   Loaded via _partials/components/site-styles.html.
   =========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */

/* Every value below is sampled from the brand artwork in static/images, so the
   page and the logo are literally the same ink. */
:root {
  --paper: #faf9fb;
  --paper-sunk: #f2f0f6;
  --ink: #21253d; /* the wordmark navy */
  --ink-soft: #4c5170;
  /* Held at 4.9:1 on --paper: sidenotes are 0.8rem and still have to pass AA. */
  --ink-faint: #6b6c86;
  --rule: #e3e0ea;
  --rule-strong: #c8c3d6;

  --brand: #60368a; /* the "Delusion" purple */
  --brand-deep: #45256a;
  --brand-wash: #f3eff8;
  /* Lifted purple, legible on the dark shell. From the app icon. */
  --brand-lift: #8358b0;
  /* The palette's lilac. --brand-lift only reaches 3.1:1 on --shell, so links
     on the dark footer use this instead. */
  --brand-pale: #c4bedb;

  /* Header rule and footer: the app icon's tile colour. */
  --shell: #11182c;

  /* Reserved. Used only where a vendor-published success is contradicted. */
  --contra: #9b2c22;
  --contra-wash: #fbf1ef;

  --serif: ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --measure: 34rem;
  --note-col: 15rem;
  --gutter: 2.5rem;
}

/* --- 2. Page shell ------------------------------------------------------- */

body {
  background-color: var(--paper);
  color: var(--ink);
}

/* Restyle the module's dark header into something slimmer and quieter.
   It is white rather than dark because the logo is drawn on a white artboard;
   on a dark bar it would show as a white slab. The rule below carries the
   weight the dark bar used to. */
header.bg-dark {
  background-color: #fff !important;
  padding: 0 !important;
  border-bottom: 1px solid var(--rule-strong);
}

header.bg-dark > .container {
  padding-top: 0.6rem !important;
  padding-bottom: 0.6rem !important;
}

header .nav-pills {
  gap: 0.1rem;
}

/* The module marks inactive links with Bootstrap's .text-white utility, which
   carries !important — so the override has to as well. */
header .nav-pills .nav-link,
header .nav-pills .nav-link.text-white {
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.75rem;
  border-radius: 2px;
  color: var(--ink-soft) !important;
  transition: background-color 0.15s, color 0.15s;
}

header .nav-pills .nav-link:hover,
header .nav-pills .nav-link:focus,
header .nav-pills .nav-link.text-white:hover,
header .nav-pills .nav-link.text-white:focus {
  background-color: var(--brand-wash);
  color: var(--brand) !important;
}

header .nav-pills .nav-link.active,
header .nav-pills .nav-link.active.text-white {
  background-color: transparent;
  color: var(--ink) !important;
  box-shadow: inset 0 -2px 0 var(--brand);
}

/* The module puts a breadcrumb inside the same header and paints it white for
   the dark bar. On the white bar it would be invisible. */
header .breadcrumb-nav .breadcrumb-item a {
  color: var(--ink-faint);
}

header .breadcrumb-nav .breadcrumb-item a:hover {
  color: var(--brand);
}

header .breadcrumb-nav .breadcrumb-item.active {
  color: var(--ink-soft);
}

header .breadcrumb-nav .breadcrumb-item + .breadcrumb-item::before {
  color: var(--rule-strong);
}

footer.footer {
  background-color: var(--shell) !important;
  font-family: var(--sans);
  font-size: 0.8rem;
}

footer.footer a {
  color: var(--brand-pale);
}

/* --- 2b. Bootstrap and module bridge -------------------------------------- */
/* Two blues arrive from outside this file: Bootstrap's default primary, and
   the guide nav's active pill, painted from params.brand.bg_colour in
   hugo.yaml. Neither is ours to edit, so both are mapped here instead —
   otherwise the retheme stops at the wrapper pages and the guide stays blue. */

:root {
  --bs-primary: #60368a;
  --bs-primary-rgb: 96, 54, 138;
  --bs-primary-text-emphasis: #45256a;
  --bs-link-color: #60368a;
  --bs-link-color-rgb: 96, 54, 138;
  --bs-link-hover-color: #45256a;
  --bs-link-hover-color-rgb: 69, 37, 106;
  --bs-nav-pills-link-active-bg: #60368a;
}

.btn-primary {
  --bs-btn-bg: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-deep);
  --bs-btn-hover-border-color: var(--brand-deep);
  --bs-btn-active-bg: var(--brand-deep);
  --bs-btn-active-border-color: var(--brand-deep);
  --bs-btn-disabled-bg: var(--brand);
  --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand);
  --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand);
  --bs-btn-active-border-color: var(--brand);
}

/* The guide's own section nav. One class more specific than the module rule. */
.guide-nav-menu .nav-pills .nav-link.active {
  background-color: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.guide-nav-menu .nav-pills .nav-link:hover {
  color: var(--brand);
  background-color: var(--brand-wash);
}

/* The module's own blue, #1d7fd5, set with !important throughout its
   style.css. Buttons first, then the version timeline on the guide's
   history page. Colour only — no geometry is touched. */

.btn-primary {
  background-color: var(--brand) !important;
  border-color: var(--brand) !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--brand-deep) !important;
  border-color: var(--brand-deep) !important;
}

.btn-outline-primary {
  color: var(--brand) !important;
  border-color: var(--brand) !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
  background-color: var(--brand) !important;
  border-color: var(--brand) !important;
}

.version-timeline::before {
  background: linear-gradient(to bottom, var(--brand) 0%, #6c757d 30%, #6c757d 100%);
}

.version-latest .card {
  box-shadow: 0 8px 25px rgba(96, 54, 138, 0.15) !important;
}

.version-fork-indicator .fork-text {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 4px 15px rgba(96, 54, 138, 0.2);
}

.version-fork-indicator .fork-text::before {
  border-bottom-color: var(--brand);
}

.version-latest::after {
  background: var(--brand);
  box-shadow: 0 2px 8px rgba(96, 54, 138, 0.3);
}

/* --- 3. Wrapper page canvas ---------------------------------------------- */

.wrapper-page {
  padding: 0 0 5rem;
}

.wrapper-masthead {
  border-bottom: 1px solid var(--rule);
  padding: 3.5rem 0 2rem;
  margin-bottom: 2.5rem;
}

.wrapper-eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 0.9rem;
}

.wrapper-title {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 0.9rem;
}

.wrapper-standfirst {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 38rem;
  margin: 0;
}

/* --- 4. The reading column ------------------------------------------------ */
/* Content sits in a fixed measure. Sources are floated into the margin beside
   it (see §6) rather than placed in a grid track, because a float attaches to
   the content that follows it — which matches how the notes are authored, with
   the note written immediately before the claim it supports. */

.wrapper-body {
  max-width: var(--measure);
}

@media (min-width: 62em) {
  .wrapper-body {
    /* Room for the note column to sit outside the measure without clipping. */
    padding-right: 0;
  }
}

/* --- 5. Prose ------------------------------------------------------------ */

.wrapper-body {
  font-family: var(--serif);
  font-size: 1.075rem;
  line-height: 1.68;
  color: var(--ink);
}

.wrapper-body p {
  margin: 0 0 1.35rem;
}

.wrapper-body h2 {
  font-family: var(--serif);
  font-size: 1.65rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 3.25rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.wrapper-body h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 2.25rem 0 0.75rem;
}

.wrapper-body ul,
.wrapper-body ol {
  margin: 0 0 1.35rem;
  padding-left: 1.15rem;
}

.wrapper-body li {
  margin-bottom: 0.6rem;
}

.wrapper-body strong {
  font-weight: 700;
}

.wrapper-body a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.wrapper-body a:hover {
  color: var(--brand-deep);
}

.wrapper-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
  opacity: 1;
}

.wrapper-body blockquote {
  margin: 1.75rem 0;
  padding-left: 1.25rem;
  border-left: 3px solid var(--rule-strong);
  color: var(--ink-soft);
  font-style: italic;
}

/* --- 6. Sidenotes -------------------------------------------------------- */
/* Every claim shows its receipt in the margin. Below the breakpoint they
   fold inline, indented behind a rule, rather than disappearing. */

.sidenote {
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-faint);
  margin: 0 0 1.35rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--rule-strong);
}

.sidenote .sidenote-who {
  display: block;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}

.sidenote a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px solid rgba(96, 54, 138, 0.35);
}

.sidenote a:hover {
  border-bottom-color: var(--brand);
}

@media (min-width: 62em) {
  .sidenote {
    float: right;
    clear: right;
    width: var(--note-col);
    margin-right: calc(-1 * (var(--note-col) + var(--gutter)));
    margin-top: 0.4rem;
    margin-bottom: 1rem;
    padding-left: 0;
    padding-top: 0.5rem;
    border-left: 0;
    border-top: 2px solid var(--rule-strong);
  }
}

/* --- 7. Two registers ----------------------------------------------------- */
/* The guide's evidence and this site's commentary must never look alike. */

.editor-note {
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.6;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-faint);
  padding: 1.15rem 1.35rem;
  margin: 2rem 0;
  color: var(--ink-soft);
}

.editor-note > .editor-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.5rem;
}

.editor-note p:last-child {
  margin-bottom: 0;
}

/* A contradiction: something the vendor published as a success. Rare by
   design — if this appears more than a few times site-wide it stops working. */
.contradiction {
  border-left: 3px solid var(--contra);
  background: var(--contra-wash);
  padding: 1rem 1.25rem;
  margin: 2rem 0;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: #5c1a15;
}

/* --- 8. Wayfinding ------------------------------------------------------- */

.spine {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.spine ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0.85rem 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.spine a {
  color: var(--ink-faint);
  text-decoration: none;
}

.spine a:hover {
  color: var(--brand);
}

.spine li[aria-current] a {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--brand);
}

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  border-top: 1px solid var(--rule);
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.page-nav a {
  color: var(--brand);
  text-decoration: none;
}

.page-nav a:hover {
  text-decoration: underline;
}

.page-nav .page-nav-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.2rem;
}

.provenance {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--ink-faint);
}

.provenance a {
  color: var(--ink-soft);
}

/* --- 8b. Home ------------------------------------------------------------- */

.home-hero {
  padding: 4.5rem 0 2.75rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}

.home-title {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 6vw, 3.9rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 1.1rem;
}

.home-lede {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 40rem;
  margin: 0;
}

.section-head {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1.5rem;
}

/* Symptoms: a list of hairlines, not a grid of cards. */
.symptom-list {
  list-style: none;
  margin: 0 0 3.5rem;
  padding: 0;
  border-top: 1px solid var(--rule);
  max-width: 52rem;
}

.symptom {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--rule);
}

.symptom-claim {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.4;
  flex: 1 1 22rem;
}

.symptom-src {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}

.symptom-src:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* The turn: the one full-bleed statement on the page. */
.turn {
  background: var(--brand-deep);
  color: #fff;
  padding: 3.5rem 0;
  margin: 0 0 3.5rem;
}

.turn-head {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 1.25rem;
  max-width: 30rem;
}

.turn-body {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 38rem;
  color: rgba(255, 255, 255, 0.93);
  margin: 0 0 1rem;
}

.turn-body-quiet {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 0;
}

/* Findings */
.findings {
  max-width: 40rem;
  margin-bottom: 3.5rem;
}

.findings-intro {
  font-family: var(--serif);
  font-size: 1.075rem;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
}

.findings-list {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 0 0 1.5rem;
  padding-left: 1.4rem;
}

.findings-list li {
  margin-bottom: 0.85rem;
  padding-left: 0.35rem;
}

.findings-list li::marker {
  color: var(--brand);
  font-family: var(--sans);
  font-size: 0.85rem;
}

.findings-src a,
.source-about a {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--brand);
  text-decoration: none;
}

.findings-src a:hover,
.source-about a:hover {
  text-decoration: underline;
}

/* Evidence scale: typographic, not stat tiles. */
.evidence-strip {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1.75rem 0;
  margin-bottom: 3rem;
}

@media (min-width: 48em) {
  .evidence-strip {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }
}

.evidence-figure {
  display: block;
  font-family: var(--serif);
  font-size: 2.75rem;
  line-height: 1;
  color: var(--brand);
  margin-bottom: 0.4rem;
}

.evidence-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-faint);
}

.editor-links {
  margin-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.editor-note a {
  color: var(--brand);
}

/* Doors */
.doors {
  list-style: none;
  margin: 0 0 4rem;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

@media (min-width: 48em) {
  .doors {
    grid-template-columns: repeat(3, 1fr);
  }
}

.door a {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--paper);
  text-decoration: none;
  transition: background-color 0.15s;
}

.door a:hover {
  background: var(--brand-wash);
}

.door-who {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.door-what {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  flex-grow: 1;
}

.door-go {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand);
}

/* The source */
.source-block {
  background: var(--paper-sunk);
  border-top: 1px solid var(--rule);
  padding: 3.5rem 0 4rem;
}

.source-title {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  line-height: 1.2;
  margin: 0 0 1rem;
  max-width: 34rem;
}

.source-desc {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 42rem;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin: 1.75rem 0 2.5rem;
}

.source-primary {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.5rem;
  border-radius: 2px;
  text-decoration: none;
}

.source-primary:hover {
  background: var(--brand-deep);
  color: #fff;
}

.source-meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.source-people {
  border-top: 1px solid var(--rule-strong);
  padding-top: 1.5rem;
}

.source-avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.source-about {
  margin: 2rem 0 0;
}

/* --- 9. Defect fixes that must also reach the guide page ------------------ */
/* Measured before these rules: 759px of horizontal scroll at 375px viewport,
   caused by ~74 unbroken raw URLs in Appendix 1; plus 12px of gutter escape
   from a .row rendered outside any .container. */

main a,
.external-link {
  overflow-wrap: anywhere;
  word-break: break-word;
}

main img,
main table,
main pre {
  max-width: 100%;
}

main pre {
  overflow-x: auto;
}

.row:has(> main.col-md-9),
.row:has(> aside.col-md-3) {
  margin-left: 0;
  margin-right: 0;
}

/* Reading measure for the guide's own body copy. */
main p,
main li,
main blockquote {
  max-width: 72ch;
}

/* --- 9b. Skip link -------------------------------------------------------- */
/* Visible only on keyboard focus. */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 0.7rem 1.1rem;
  border: 2px solid var(--brand);
  border-radius: 0 0 3px 0;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* --- 10. Focus ------------------------------------------------------------ */

a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 3px solid #d9a441;
  outline-offset: 2px;
}

/* --- 11. Print — /brief/ is forwarded and printed ------------------------- */

@media print {
  header,
  footer,
  .spine,
  .page-nav {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 11pt;
  }

  .wrapper-body {
    display: block;
    font-size: 11pt;
  }

  .wrapper-masthead {
    padding-top: 0;
  }

  .sidenote {
    border-left: 1px solid #999;
    color: #333;
    page-break-inside: avoid;
  }

  .wrapper-body h2 {
    page-break-after: avoid;
  }

  .wrapper-body a {
    color: #000;
    text-decoration: none;
  }

  .wrapper-body a[href^="/"]::after {
    content: " (safedelusion.com" attr(href) ")";
    font-size: 8pt;
    color: #555;
  }
}
