/* ==========================================================================
   Handbook - styles.css
   Engineering handbook. Dark. Exo 2 + IBM Plex Mono. Brand: #ff5e00.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
  --brand:          #ff5e00;
  --brand-dim:      rgba(255, 94, 0, 0.12);
  --brand-mid:      rgba(255, 94, 0, 0.28);
  --brand-old:      #fabd6e;
  --soft-white:     #f2f2f7;
  --bg:             #0a0a0c;
  --surface:        #141418;
  --surface-2:      #1c1c22;
  --border:         rgba(255, 255, 255, 0.08);
  --border-subtle:  rgba(255, 255, 255, 0.05);
  --text:           #e8e8ec;
  --muted:          #9a9aa8;
  --font:           "Exo 2", system-ui, sans-serif;
  --mono:           "IBM Plex Mono", ui-monospace, monospace;
  --topbar-h:       3rem;     /* 48px */
  --content:        740px;
  --radius:         6px;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Reading progress bar
   -------------------------------------------------------------------------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 100;
  pointer-events: none;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--brand);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.08s linear;
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  background: rgba(10, 10, 12, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* Back link */
.topbar__back {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}

.topbar__back:hover {
  color: var(--text);
}

/* Anchor index: sticky left rail */
.toc {
  position: fixed;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 180px;
  z-index: 40;
}

.toc__part {
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.03em;
  font-weight: 500;
  color: var(--soft-white);
  text-decoration: none;
}

.toc__part:first-child {
  margin-top: 0;
}

.toc__link {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-decoration: none;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border-subtle);
  transition: color 0.15s, border-color 0.15s;
}

.toc__link:hover {
  color: var(--text);
}

.toc__link.is-on {
  color: var(--brand);
  border-left-color: var(--brand);
}

@media (max-width: 1199px), (max-height: 640px) {
  .toc {
    display: none;
  }
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  margin-left: auto;
}

.lang-switch button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.25rem 0.4rem;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.lang-switch button:hover {
  color: var(--text);
}

.lang-switch button.active {
  color: var(--brand);
  background: var(--brand-dim);
}

/* --------------------------------------------------------------------------
   Page wrapper
   -------------------------------------------------------------------------- */
.page {
  max-width: var(--content);
  margin: 0 auto;
  padding: 3rem 1.25rem 6rem;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  margin-bottom: 4.5rem;
  padding-top: 0.5rem;
}

.hero__eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 0.875rem;
}

.hero h1 {
  font-family: var(--font);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--soft-white);
  margin-bottom: 1.375rem;
  letter-spacing: -0.025em;
}

.hero__lede {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 560px;
}

/* --------------------------------------------------------------------------
   Part: names the group of anchors that follows
   -------------------------------------------------------------------------- */
.part {
  margin: 7rem 0 1.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-family: var(--font);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--soft-white);
  scroll-margin-top: calc(var(--topbar-h) + 2rem);
}

.part__intro {
  margin: 0 0 4rem;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--muted);
}

.hero + .part {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* --------------------------------------------------------------------------
   Anchor: personal reference at the start of a part
   -------------------------------------------------------------------------- */
.anchor {
  margin: 0 0 5rem;
  scroll-margin-top: calc(var(--topbar-h) + 2rem);
}

.anchor:last-child {
  margin-bottom: 0;
}

.anchor__quote {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--soft-white);
  line-height: 1.35;
  margin: 0;
  padding-left: 1.5rem;
  border-left: 3px solid var(--brand);
}

.anchor__source {
  margin: 0.625rem 0 0 1.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.anchor__pic {
  display: block;
  width: 100%;
  height: auto;
  margin: 1.25rem 0 0;
  border-radius: 12px;
}

.anchor__body {
  margin: 1.75rem 0 0;
}

.anchor__body p {
  font-size: 1.0625rem;
  color: var(--soft-white);
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 0.9rem;
}

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

.anchor__body .key {
  margin-top: 1.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--brand);
}

/* --------------------------------------------------------------------------
   Section block
   -------------------------------------------------------------------------- */
.section {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Section title */
.section h3 {
  font-family: var(--font);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.125rem;
  letter-spacing: -0.01em;
}

/* Body paragraphs */
.section p {
  color: var(--text);
  line-height: 1.72;
  margin-bottom: 0.9rem;
}

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

/* Lists */
.section ul,
.section ol {
  margin: 0 0 0.9rem 1.375rem;
}

.section li {
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 0.4rem;
}

.section li:last-child {
  margin-bottom: 0;
}

/* Key phrase: the one highlighted statement per section */
.key {
  position: relative;
  margin: 1.375rem 0;
  padding: 0.875rem 1.125rem 0.875rem 1.25rem;
  border-left: 3px solid var(--brand);
  background: var(--brand-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-weight: 500;
  font-size: 1rem;
  color: var(--soft-white);
  line-height: 1.65;
}

/* When .key is used as a <p> inside .section */
.section .key {
  margin-top: 1.375rem;
  margin-bottom: 0.9rem;
}

.section .key:last-child {
  margin-bottom: 0;
}
/* Lead paragraph: first <p> after h3 - the core idea, slightly bolder */
.section h3 + p {
  font-size: 1.0625rem;
  color: var(--soft-white);
  font-weight: 500;
  line-height: 1.65;
}


/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .page {
    padding: 2rem 1rem 4rem;
  }

  .topbar {
    padding: 0 1rem;
  }

  .topbar__back {
    display: none; /* save horizontal space on narrow screens */
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero__lede {
    font-size: 1rem;
  }

  .anchor__quote {
    font-size: 1.125rem;
    padding-left: 1rem;
  }

  .anchor__source {
    margin-left: 1rem;
  }

  .anchor__body {
    margin-top: 1.25rem;
  }

  .anchor__body p {
    font-size: 1rem;
  }

}

@media (min-width: 601px) and (max-width: 760px) {
  .hero h1 {
    font-size: 2.5rem;
  }

}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
  .progress,
  .topbar,
  .toc {
    display: none !important;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  html {
    scroll-behavior: auto;
  }

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

  .hero h1 {
    color: #111;
  }

  .hero__eyebrow {
    color: #333;
  }

  .hero__lede,
  .section p,
  .section li {
    color: #333;
  }

  .key {
    border-left-color: #555;
    background: #f5f5f5;
    color: #111;
  }

  .section {
    page-break-inside: avoid;
  }

  .anchor__quote {
    border-left-color: #555;
    color: #111;
  }

  .anchor__source {
    color: #555;
  }

  .anchor__body p {
    color: #333;
  }

  .anchor {
    page-break-inside: avoid;
  }



  code {
    background: #eee;
    color: #333;
  }
}
