/* ============================================================
   The Linux Deep Dive — warm dark, quietly retro.
   One accent colour (amber), serif body, no neon.
   ============================================================ */

:root {
  --bg:          #1c1a17;   /* warm near-black, like an old terminal bezel */
  --bg-sidebar:  #161412;
  --bg-code:     #14120f;
  --bg-inline:   #2a2722;
  --text:        #d8d0c0;   /* warm cream */
  --text-dim:    #8f8676;
  --accent:      #d9a05b;   /* single amber accent */
  --accent-dim:  #a4783f;
  --rule:        #35312a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono:  "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ============================================================
   Micro-interactions & polish
   ============================================================ */

::selection { background: rgba(217, 160, 91, 0.25); color: var(--text); }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  opacity: 0.6;
}

#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  z-index: 9998;
  width: 0;
  box-shadow: 0 0 8px rgba(217, 160, 91, 0.3);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.article.fade-in { animation: fadeSlideIn 0.4s ease-out; }

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
}

.layout { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--rule);
  padding: 2rem 1.5rem 2rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.site-title a {
  font-size: 1.55rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.site-subtitle {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.site-title { padding-bottom: 1.25rem; border-bottom: 1px solid var(--rule); }

#toc { margin-top: 1.25rem; }

.toc-part {
  margin: 1.4rem 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.toc-list { list-style: none; margin: 0; padding: 0; }

.toc-list a {
  display: block;
  padding: 0.28rem 0.6rem;
  margin-left: -0.6rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  border-radius: 3px;
  border-left: 2px solid transparent;
}

.toc-list a:hover { color: var(--accent); }

.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(217, 160, 91, 0.07);
  border-radius: 0 3px 3px 0;
}

.toc-num {
  display: inline-block;
  width: 1.6em;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.sidebar-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.5;
}

#sidebar-toggle { display: none; }

/* ---------------- Article ---------------- */

.content { flex: 1; min-width: 0; }

.article {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 2.5rem 2rem;
}

.loading { color: var(--text-dim); font-style: italic; }

.article h1 {
  font-size: 2.2rem;
  line-height: 1.2;
  color: var(--accent);
  margin: 0 0 0.5rem;
  font-weight: 700;
}

/* the little ornament under each title — the gentle retro touch */
.article h1::after {
  content: "· · ─────────────────── · ·";
  display: block;
  color: var(--rule);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin-top: 0.9rem;
  font-family: var(--mono);
}

.article h2 {
  font-size: 1.5rem;
  color: var(--text);
  margin: 2.6rem 0 0.8rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--rule);
}

.article h3 {
  font-size: 1.15rem;
  color: var(--accent);
  margin: 2rem 0 0.6rem;
  font-weight: 700;
}

.article p { margin: 0 0 1.1rem; }

.article a {
  color: var(--accent);
  text-decoration: none;
  background: linear-gradient(var(--accent-dim), var(--accent-dim)) 0 100% / 0 1px no-repeat;
  transition: background-size 0.3s ease, color 0.2s ease;
}
.article a:hover { background-size: 100% 1px; }

.article strong { color: #efe8d8; }

.article em { color: var(--text); }

.article ul, .article ol { padding-left: 1.6rem; margin: 0 0 1.1rem; }
.article li { margin-bottom: 0.35rem; }
.article li::marker { color: var(--accent-dim); }

.article blockquote {
  margin: 1.4rem 0;
  padding: 0.7rem 1.2rem;
  border-left: 3px solid var(--accent-dim);
  background: rgba(217, 160, 91, 0.05);
  color: var(--text);
  font-style: italic;
}
.article blockquote p:last-child { margin-bottom: 0; }

/* callout boxes: Simplified model & Important nuance */
.article blockquote.callout-simple {
  border-left-color: var(--accent-dim);
  background: rgba(217, 160, 91, 0.07);
  font-style: normal;
}
.article blockquote.callout-simple::before {
  content: "Simplified model";
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-dim);
  margin-bottom: 0.5rem;
  font-family: var(--mono);
}
.article blockquote.callout-nuance {
  border-left-color: var(--accent);
  background: rgba(217, 160, 91, 0.05);
  font-style: normal;
}
.article blockquote.callout-nuance::before {
  content: "Important nuance";
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-family: var(--mono);
}

.article hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem auto;
  width: 60%;
}

/* code */
.article code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--bg-inline);
  padding: 0.12em 0.4em;
  border-radius: 3px;
  color: #e6c089;
}

.article pre {
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 0 0 1.3rem;
  line-height: 1.5;
}

.article pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.82rem;
}

/* make highlight.js sit on our background */
.article pre code.hljs { background: transparent; padding: 0; }

/* tables */
.article table {
  border-collapse: collapse;
  margin: 0 0 1.3rem;
  width: 100%;
  font-size: 0.92rem;
}
.article th, .article td {
  border: 1px solid var(--rule);
  padding: 0.45rem 0.8rem;
  text-align: left;
}
.article th {
  background: var(--bg-sidebar);
  color: var(--accent);
  font-weight: 700;
}
.article tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }

/* ---------------- Pager ---------------- */

.pager {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 2.5rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--rule);
}

.pager a {
  display: block;
  max-width: 46%;
  color: var(--text);
  text-decoration: none;
  padding: 0.8rem 0;
  font-size: 0.92rem;
}

.pager a:hover .pager-title { color: var(--accent); }

.pager .pager-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-family: var(--mono);
}

.pager .pager-title { color: var(--accent-dim); }
.pager .next { text-align: right; margin-left: auto; }

.page-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 2.5rem 3rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-style: italic;
}

/* ---------------- Images ---------------- */

.article img { max-width: 100%; height: auto; }

/* ---------------- Responsive: Tablet & below (< 900px) ---------------- */

@media (max-width: 900px) {
  .layout { flex-direction: column; }

  #sidebar-toggle {
    display: block;
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    text-align: left;
    background: var(--bg-sidebar);
    color: var(--accent);
    border: none;
    border-bottom: 1px solid var(--rule);
    padding: 1rem 1.2rem;
    font-family: var(--serif);
    font-size: 1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  #sidebar-toggle:active { background: rgba(217, 160, 91, 0.1); }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 0;
    visibility: hidden;
    overflow: hidden;
    position: static;
    border-right: none;
    border-bottom: 1px solid transparent;
    padding: 0 1.5rem;
    transition: max-height 0.35s ease, visibility 0s 0.35s, padding 0.3s ease, border-color 0.3s ease;
  }

  .sidebar.open {
    max-height: 5000px;
    visibility: visible;
    padding: 1.5rem 1.5rem 2rem 1.8rem;
    border-bottom-color: var(--rule);
    transition: max-height 0.35s ease, visibility 0s 0s, padding 0.3s ease, border-color 0.3s ease;
  }

  .toc-list a {
    padding: 0.55rem 0.6rem;
  }

  .article {
    padding: 2rem 1.5rem 1.5rem;
  }

  .pager, .page-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  body { font-size: 16px; }

  .article h1 { font-size: 1.85rem; }
  .article h2 { font-size: 1.35rem; margin-top: 2rem; }
  .article h3 { font-size: 1.1rem; }
}

/* ---------------- Responsive: Phone (< 600px) ---------------- */

@media (max-width: 600px) {
  body { font-size: 15px; }

  .article {
    padding: 1.5rem 1rem 1rem;
  }

  .article h1 {
    font-size: 1.55rem;
  }

  .article h1::after {
    content: "· · ──────── · ·";
    font-size: 0.75rem;
    margin-top: 0.7rem;
  }

  .article h2 {
    font-size: 1.2rem;
    margin-top: 1.8rem;
  }

  .article h3 { font-size: 1rem; }

  .article pre {
    padding: 0.8rem 0.9rem;
    font-size: 0.78rem;
    -webkit-overflow-scrolling: touch;
  }

  .article pre code { font-size: 0.75rem; }

  .article blockquote {
    padding: 0.6rem 1rem;
    margin: 1rem 0;
  }

  .article table {
    font-size: 0.78rem;
  }

  .article th, .article td {
    padding: 0.35rem 0.5rem;
  }

  .pager {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.8rem 1rem 0;
  }

  .pager a { max-width: 100%; padding: 0.5rem 0; }

  .pager .next { text-align: right; }

  .page-footer { padding: 1rem 1rem 2rem; }

  .sidebar.open { padding: 1rem 1rem 1.5rem 1.3rem; }

  #sidebar-toggle { padding: 0.9rem 1rem; font-size: 0.95rem; }

  .toc-part { font-size: 0.68rem; }
  .toc-list a { font-size: 0.9rem; }
}

/* ---------------- Responsive: Small phone (< 420px) ---------------- */

@media (max-width: 420px) {
  body { font-size: 14px; }

  .article h1 { font-size: 1.4rem; }
  .article h1::after { font-size: 0.7rem; }

  .article h2 { font-size: 1.1rem; }
  .article h3 { font-size: 0.95rem; }

  .article pre code { font-size: 0.7rem; }

  .article th, .article td {
    padding: 0.3rem 0.4rem;
  }
}
