/* ============================================================
   FONTS, brand fonts from the Spark Shark identity kit
   WOFF2 only: every supported browser takes WOFF2, and serving the
   raw desktop binaries is not covered by the web licenses.
   Licensed via I Love Typography order 12213 (2026-06-11), web
   license up to 250,000 pageviews/month.
   ============================================================ */
@font-face {
  font-family: "Brown Pro";
  src: url("fonts/brown-pro-400-normal-096d51b3.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Brown Pro";
  src: url("fonts/brown-pro-500-italic-7d6df252.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Brown Pro";
  src: url("fonts/brown-pro-700-normal-5cb17576.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Brown Pro";
  src: url("fonts/brown-pro-800-normal-f29f100f.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Brown Pro";
  src: url("fonts/brown-pro-900-normal-c514c860.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}
/* Blambot Pro webfont license: MyFonts order 7319636050090 (2026-06-11),
   annual, 10,000 pageviews/month. */
@font-face {
  font-family: "Blambot Pro";
  src: url("fonts/blambot-pro-400-italic-cb53c063.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ============================================================
   BRAND TOKENS
   ============================================================ */
:root {
  /* Primary palette from brand sheet */
  --ss-orange:      #f28c28;
  --ss-orange-deep: #b04500;   /* warning-headline orange on light backgrounds, passes WCAG AA on #fff5ee */
  --ss-teal:        #4a9ba5;
  --ss-deep:        #0c192b;   /* deep navy */
  --ss-black:       #000000;
  --ss-paper:       #f0f5f9;   /* off-white background tint */
  --ss-white:       #ffffff;
  --ss-yellow:      #f8c81e;   /* electric yellow accent (from mascot bolt) */

  /* Functional */
  --ink:         #14202e;
  --ink-soft:    #41546b;
  --ink-faint:   #7a8a9c;
  --rule:        #d8e0e8;
  --rule-soft:   #e8edf2;

  /* Type */
  --body-font: "Brown Pro", "Helvetica Neue", Arial, sans-serif;
  --display-font: "Brown Pro", "Helvetica Neue", Arial, sans-serif;
  --accent-font: "Blambot Pro", "Brown Pro", sans-serif;

  /* Layout */
  --measure: 38rem;       /* readable line length */
  --measure-wide: 56rem;  /* tables, callouts */
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
}

/* ============================================================
   BASE
   ============================================================ */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ss-paper);
  color: var(--ink);
  font-family: var(--body-font);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 4rem var(--gutter) 6rem;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
p {
  margin: 0 0 1.1em;
  max-width: var(--measure);
}

strong, b { font-weight: 700; color: var(--ink); }
em, i { font-style: italic; }

a {
  color: var(--ss-teal);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--ss-orange); }

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--display-font);
  color: var(--ss-deep);
  line-height: 1.15;
  margin: 0 0 0.6em;
  letter-spacing: -0.01em;
}

/* h1 used for: Part titles, Chapter titles, top-level front-matter sections */
h1 {
  font-weight: 900;
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 4px solid var(--ss-deep);
  position: relative;
}
h1::before {
  content: "";
  display: block;
  position: absolute;
  top: -4px;
  left: 0;
  width: 96px;
  height: 4px;
  background: var(--ss-orange);
}
/* The very first h1 in the body shouldn't have the top rule pushed away */
.page > h1:first-of-type { margin-top: 0; }

h2 {
  font-weight: 800;
  font-size: clamp(1.4rem, 2.5vw, 1.7rem);
  margin-top: 2.4rem;
  color: var(--ink);
}

h3 {
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: 1.8rem;
  color: var(--ink);
  text-transform: none;
}

h4 {
  font-weight: 700;
  font-size: 1rem;
  margin-top: 1.4rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Lists */
ul, ol {
  max-width: var(--measure);
  margin: 0 0 1.2em;
  padding-left: 1.25rem;
}
ul li, ol li {
  margin-bottom: 0.45em;
}
ul { list-style: none; padding-left: 0; }
ul > li {
  position: relative;
  padding-left: 1.25rem;
}
ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 7px;
  height: 7px;
  background: var(--ss-orange);
  border-radius: 1px;
  transform: rotate(45deg);
}
ol { list-style-type: decimal; padding-left: 1.5rem; }
ol > li::marker {
  color: var(--ss-orange);
  font-weight: 700;
}

/* Nested lists keep going */
li > ul, li > ol { margin: 0.4em 0 0.2em; }

/* Blockquotes (rare, used for italic asides) */
blockquote {
  margin: 1.5em 0;
  padding: 0.5em 0 0.5em 1.25rem;
  border-left: 3px solid var(--ss-orange);
  color: var(--ink-soft);
  font-style: italic;
  max-width: var(--measure);
}

/* Horizontal rule, used as section divider in the source */
hr {
  border: none;
  height: 1px;
  background: var(--rule);
  margin: 2.5rem 0;
  max-width: var(--measure-wide);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  margin: 1.5em 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--ss-white);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
thead th {
  background: var(--ss-deep);
  color: var(--ss-white);
  text-align: left;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.7rem 0.85rem;
  white-space: nowrap;
}
tbody td {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--rule-soft);
  vertical-align: top;
}
tbody tr:nth-child(even) td {
  background: rgba(74, 155, 165, 0.05);
}

@media (max-width: 700px) {
  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 0.55rem 0.6rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* ============================================================
   CALLOUTS, variant-aware styling
   ============================================================ */
.callout {
  max-width: var(--measure-wide);
  margin: 2rem 0;
  padding: 1.5rem 1.75rem;
  border-radius: 6px;
  background: var(--ss-white);
  border: 1px solid var(--rule);
  border-left: 6px solid var(--ss-teal);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout h2 {
  margin-top: 0;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ss-deep);
}
.callout h3 {
  font-size: 1rem;
  margin-top: 0.6rem;
  color: var(--ink);
}
.callout p,
.callout ul,
.callout ol {
  max-width: none;
}

/* What's Next, forward-looking, calm teal */
.callout--whats-next {
  border-left-color: var(--ss-teal);
  background: linear-gradient(180deg,
    rgba(74, 155, 165, 0.06),
    rgba(74, 155, 165, 0.02));
}

/* Side Note, Spark Shark voice, warm orange */
.callout--side-note {
  border-left-color: var(--ss-orange);
  background: linear-gradient(180deg,
    rgba(242, 140, 40, 0.07),
    rgba(242, 140, 40, 0.02));
}
.callout--side-note h2 {
  color: var(--ss-orange);
}

/* Part dividers, full bleed style */
.callout--part-divider {
  background: var(--ss-deep);
  color: var(--ss-white);
  border: none;
  padding: 2.5rem 2rem;
  border-radius: 8px;
}
.callout--part-divider h2,
.callout--part-divider h3 {
  color: var(--ss-white);
}
.callout--part-divider h2 {
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  color: var(--ss-orange);
  margin-bottom: 0.4rem;
}
.callout--part-divider h3 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  text-transform: none;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}
.callout--part-divider a { color: var(--ss-yellow); }
.callout--part-divider strong { color: var(--ss-white); }
.callout--part-divider ul li::before {
  background: var(--ss-orange);
}

/* Part V "note before this part", heavy warning, deep + orange */
.callout--part-v-note {
  border-left-color: var(--ss-orange);
  border-left-width: 8px;
  background: #fff8f0;
}
.callout--part-v-note h2 {
  color: var(--ss-orange);
}

/* Chapter warning for Part V, strongest treatment */
.callout--chapter-warning-part-v {
  background: #fff5ee;
  border: 2px solid var(--ss-orange);
  border-left: 10px solid var(--ss-orange);
}
.callout--chapter-warning-part-v h2 {
  color: var(--ss-orange-deep);
  font-size: 1rem;
}

/* Code currency notice, neutral but stands out */
.callout--code-currency-notice {
  background: #f4f7fa;
  border-left-color: var(--ss-deep);
}
.callout--code-currency-notice h2 {
  color: var(--ss-deep);
}

/* Before-diagnosing (Part VI), analytical teal */
.callout--before-diagnosing {
  border-left-color: var(--ss-teal);
  background: #f1f7f8;
}

/* ============================================================
   FRONT-MATTER CALLOUTS
   ============================================================ */

/* Colophon, title page / copyright / code refs / trademarks / no-advice.
   Bibliographic meta that should sit quietly in the page flow. */
.callout--colophon {
  background: transparent;
  border: none;
  border-left: 2px solid var(--rule);
  padding: 0.5rem 0 0.5rem 1.5rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 2rem 0;
}
.callout--colophon h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--ink-faint);
  margin-bottom: 0.8rem;
}
.callout--colophon h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--ink-faint);
  margin-top: 1.6rem;
  margin-bottom: 0.6rem;
}
.callout--colophon p {
  max-width: none;
}
.callout--colophon strong {
  color: var(--ink);
  font-weight: 700;
}

/* Safety notice, the IMPORTANT-READ-BEFORE-USING-THIS-BOOK block.
   Strongest treatment in the whole book, matched to chapter-warning-part-v. */
.callout--safety-notice {
  background: #fff5ee;
  border: 2px solid var(--ss-orange);
  border-left: 10px solid var(--ss-orange);
}
.callout--safety-notice h2 {
  color: var(--ss-orange-deep);
  font-size: 1.1rem;
}

/* Legal block, No Warranty + Limitation of Liability. The all-caps legal
   text needs to look serious but not shouty. Tighter line-height, smaller
   size, restrained palette. */
.callout--legal-block {
  background: #f7f8fa;
  border-left-color: var(--ink-faint);
  font-size: 0.88rem;
  line-height: 1.55;
}
.callout--legal-block h2 {
  color: var(--ink-soft);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
  margin-bottom: 0.8rem;
}
.callout--legal-block h2:not(:first-child) {
  margin-top: 1.5rem;
}
.callout--legal-block p {
  color: var(--ink-soft);
  max-width: none;
}

/* Agreement, the numbered "Before You Use This Book" contract.
   Each numbered item gets clear visual separation. */
.callout--agreement {
  background: var(--ss-white);
  border-left-color: var(--ss-deep);
  border-left-width: 8px;
}
.callout--agreement h2 {
  color: var(--ss-deep);
  font-size: 1.3rem;
  text-transform: none;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}
.callout--agreement h3 {
  color: var(--ss-orange);
  font-size: 1rem;
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule-soft);
  text-transform: none;
  letter-spacing: 0;
}
.callout--agreement h3:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 1.2rem;
}
.callout--agreement p:last-of-type strong {
  display: block;
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  color: var(--ss-orange);
  font-family: var(--accent-font);
  font-style: italic;
  font-size: 1.4rem;
  letter-spacing: 0.05em;
  background: rgba(242, 140, 40, 0.08);
  border-radius: 4px;
}

/* Table of Contents, the chapter directory. Multi-column on wide
   screens, single-column on narrow. */
.callout--toc {
  background: var(--ss-white);
  border-left-color: var(--ss-teal);
  border-left-width: 8px;
}
.callout--toc h2 {
  color: var(--ss-deep);
  font-size: 1.4rem;
  text-transform: none;
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
}
.callout--toc h3 {
  color: var(--ink-faint);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.callout--toc h4 {
  color: var(--ss-orange);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  font-weight: 800;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ss-deep);
}
.callout--toc h4:first-of-type {
  margin-top: 0.4rem;
}
.callout--toc ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0.5rem;
  max-width: none;
}
.callout--toc ul li {
  padding-left: 0;
  margin-bottom: 0.35em;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.callout--toc ul li::before {
  display: none;
}
.callout--toc ul li strong {
  flex: 0 0 auto;
  min-width: 1.8em;
  color: var(--ss-orange);
  font-weight: 800;
  text-align: right;
}
.callout--toc ul li em {
  margin-left: auto;
  color: var(--ink-faint);
  font-style: normal;
  font-size: 0.82rem;
  white-space: nowrap;
  padding-left: 0.5rem;
}
.callout--toc ul li a {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem;
  border-radius: 4px;
  width: 100%;
  transition: background 0.1s, color 0.1s;
}
.callout--toc ul li a:hover {
  background: rgba(74, 155, 165, 0.08);
  color: var(--ss-deep);
}
.callout--toc ul li a:hover strong { color: var(--ss-orange); }

/* Book close, celebratory, deep + orange */
.callout--book-close {
  background: var(--ss-deep);
  color: var(--ss-white);
  border: none;
  padding: 2rem;
  text-align: center;
  border-radius: 8px;
}
.callout--book-close strong { color: var(--ss-orange); font-size: 1.25rem; }
.callout--book-close em { color: var(--ss-yellow); font-style: italic; }

/* ============================================================
   DIAGRAM PLACEHOLDERS
   ============================================================ */
.diagram-placeholder {
  max-width: var(--measure-wide);
  margin: 2rem 0;
  padding: 1.5rem;
  background: repeating-linear-gradient(
    -45deg,
    #fafbfd,
    #fafbfd 8px,
    #f1f4f8 8px,
    #f1f4f8 16px
  );
  border: 2px dashed var(--ss-teal);
  border-radius: 6px;
  position: relative;
}
.diagram-placeholder__chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ss-white);
  background: var(--ss-teal);
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
  margin-bottom: 0.6rem;
}
.diagram-placeholder__slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ss-deep);
  margin-bottom: 0.5rem;
}
.diagram-placeholder__caption {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-top: 0.4rem;
  max-width: var(--measure);
}
.diagram-placeholder__meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.3rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   REAL DIAGRAMS (rendered from <slug>.svg files)
   ============================================================ */
.diagram {
  max-width: var(--measure-wide);
  margin: 2.5rem 0;
  padding: 0;
}
.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}
.diagram__caption {
  margin-top: 0.6rem;
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: center;
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   COVER / MASTHEAD (front matter top)
   ============================================================ */
.masthead {
  text-align: center;
  padding: 5rem var(--gutter) 4rem;
  background: var(--ss-deep);
  color: var(--ss-white);
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}
.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(242, 140, 40, 0.25), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(74, 155, 165, 0.25), transparent 50%);
  pointer-events: none;
}
.masthead > * { position: relative; }
.masthead .eyebrow {
  font-family: var(--accent-font);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: var(--ss-yellow);
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}
.masthead h1 {
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  color: var(--ss-white);
  border: none;
  padding: 0;
  margin: 0 0 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.masthead h1::before { display: none; }
.masthead .subtitle {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: var(--ss-paper);
  opacity: 0.85;
  font-weight: 400;
  font-style: italic;
  margin-bottom: 1.8rem;
}
.masthead .imprint {
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ss-orange);
  font-weight: 700;
}
.masthead .tagline {
  margin-top: 2rem;
  font-family: var(--accent-font);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--ss-yellow);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .page { padding: 2rem var(--gutter) 4rem; }
  .callout { padding: 1.25rem; }
  .callout--part-divider { padding: 1.75rem 1.25rem; }
}

/* Print, basic */
@media print {
  body { background: white; font-size: 11pt; padding-left: 0; }
  .masthead { background: white; color: black; }
  .masthead h1.masthead .subtitle { color: black; }
  h1 { page-break-before: always; }
  .page > h1:first-of-type { page-break-before: avoid; }
  .callout.diagram-placeholder.table-wrap { page-break-inside: avoid; }
  .sidebar.nav-toggle.back-to-top.progress-bar { display: none !important; }
}

/* ============================================================
   INTERACTIVE LAYER, sidebar, search, scroll progress, top button
   ============================================================ */

/* Scroll progress bar at the very top of the viewport */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--ss-orange), var(--ss-yellow));
  z-index: 200;
  transition: width 0.05s linear;
  pointer-events: none;
}

/* Mobile hamburger button, shown only on narrow screens */
.nav-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 150;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 6px;
  background: var(--ss-deep);
  color: var(--ss-white);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.nav-toggle:hover { background: var(--ss-orange); }
.nav-toggle:focus-visible {
  outline: 2px solid var(--ss-yellow);
  outline-offset: 2px;
}

/* Sidebar, fixed-position nav, always 300px wide on desktop */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 300px;
  height: 100vh;
  background: var(--ss-deep);
  color: var(--ss-white);
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
}

/* Body shift so content doesn't go under the sidebar on desktop */
body { padding-left: 300px; }

/* Sidebar header, title + search */
.sidebar__header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--ss-deep);
  flex-shrink: 0;
}
.sidebar__title {
  font-family: var(--display-font);
  font-weight: 900;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  color: var(--ss-white);
  margin: 0 0 0.15rem;
  line-height: 1.25;
}
.sidebar__subtitle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ss-orange);
  font-weight: 700;
  margin-bottom: 0.85rem;
}
.search-wrap {
  position: relative;
}
.search-input {
  width: 100%;
  padding: 0.55rem 2.2rem 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: var(--ss-white);
  font-family: var(--body-font);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.search-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.search-input:focus {
  border-color: var(--ss-orange);
  background: rgba(255, 255, 255, 0.1);
}
.search-shortcut {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.search-input:focus + .search-shortcut { display: none; }
.search-clear {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ss-white);
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  display: none;
  line-height: 1;
}
.search-clear:hover { background: var(--ss-orange); }
.sidebar.is-searching .search-clear { display: block; }
.sidebar.is-searching .search-shortcut { display: none; }

/* Sidebar scroll area, chapter nav OR search results */
.sidebar__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.sidebar__body::-webkit-scrollbar { width: 6px; }
.sidebar__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Chapter nav (default view) */
.chapter-nav {
  padding: 0.75rem 0;
}
.chapter-nav__part {
  margin-bottom: 0.25rem;
}
.chapter-nav__part-link {
  display: block;
  padding: 0.55rem 1.25rem 0.3rem;
  font-family: var(--display-font);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ss-orange);
  text-decoration: none;
  border: none;
}
.chapter-nav__part-link:hover { color: var(--ss-yellow); }
.chapter-nav__chapters {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
}
.chapter-nav__chapters li { padding: 0; margin: 0; }
.chapter-nav__chapters li::before { display: none; }
.chapter-nav__chapter-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 1.25rem 0.4rem 1.5rem;
  font-size: 0.86rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.chapter-nav__chapter-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ss-white);
}
.chapter-nav__chapter-link.is-active {
  background: rgba(242, 140, 40, 0.1);
  color: var(--ss-white);
  border-left-color: var(--ss-orange);
}
.chapter-nav__chapter-num {
  flex: 0 0 1.5em;
  text-align: right;
  font-weight: 700;
  color: var(--ss-orange);
  font-size: 0.78rem;
}
.chapter-nav__front-link {
  display: block;
  padding: 0.55rem 1.25rem;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 0.5rem;
}
.chapter-nav__front-link:hover { color: var(--ss-yellow); }

/* Search results view (replaces chapter-nav when active) */
.search-results {
  display: none;
  padding: 0.5rem 0;
}
.sidebar.is-searching .chapter-nav { display: none; }
.sidebar.is-searching .search-results { display: block; }
.search-status {
  padding: 0.6rem 1.25rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.search-result {
  display: block;
  padding: 0.7rem 1.25rem 0.7rem 1.5rem;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.1s, border-color 0.1s;
}
.search-result:hover.search-result.is-focused {
  background: rgba(255, 255, 255, 0.04);
  border-left-color: var(--ss-orange);
  color: var(--ss-white);
}
.search-result__chapter {
  font-size: 0.7rem;
  color: var(--ss-orange);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.search-result__snippet {
  font-size: 0.83rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
}
.search-result__snippet mark {
  background: var(--ss-yellow);
  color: var(--ss-deep);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 700;
}
.search-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}
.search-empty strong { color: var(--ss-orange); display: block; margin-bottom: 0.4rem; }

/* Sidebar footer, small attribution / tagline */
.sidebar__footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--accent-font);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ss-yellow);
  text-align: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

/* In-content match highlight, flashes when arriving via search/click */
:target,
.highlight-flash {
  animation: targetFlash 1.8s ease-out;
}
@keyframes targetFlash {
  0%   { background: rgba(248, 200, 30, 0.35); }
  100% { background: transparent; }
}

/* Back-to-top button */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--ss-orange);
  color: var(--ss-white);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
  z-index: 90;
}
.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--ss-deep);
  transform: translateY(-2px);
}

/* Sidebar overlay (mobile) */
.sidebar__overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 25, 43, 0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* RESPONSIVE, mobile: sidebar slides in over content */
@media (max-width: 900px) {
  body { padding-left: 0; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(320px, 85vw);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar.is-open ~ .sidebar__overlay {
    opacity: 1;
    pointer-events: auto;
  }
  .nav-toggle { display: block; }
  .masthead { padding-top: 4.5rem; }

  /* When the sidebar is open, the hamburger button sits on TOP of the
     sidebar header, push the sidebar title content right so it isn't
     hidden underneath the button. */
  .sidebar.is-open .sidebar__header {
    padding-left: 4rem;
  }
}
