/* =========================================================================
   ClashManual — manual/reference page layout
   Shared by tutorial.html / advanced.html / docs.html / glossary.html /
   faq.html: page banner, sticky table-of-contents, article typography,
   callouts, code blocks and reference tables.
   ========================================================================= */

/* ---------- Three-column docs shell (sidebar / content / on-this-page) ----------
   Vue-docs-style layout: no separate colored hero banner — the title sits
   directly at the top of the content column, level with the sidebar, right
   under the fixed global nav. */
.docs-shell {
  display: grid; grid-template-columns: 232px minmax(0, 1fr) 200px;
  gap: 48px; align-items: start;
  padding: 96px 0 100px;
}

/* Left rail: full manual navigation tree, present on every manual page */
.docs-sidebar {
  position: sticky; top: 78px; max-height: calc(100vh - 98px);
  overflow-y: auto; padding: 2px 10px 30px 0; margin-right: -10px;
  min-width: 0;
}
.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.docs-sidebar .grp { margin-bottom: 22px; }
.docs-sidebar .grp-title {
  display: block; font-size: 12px; font-weight: 700; color: var(--ink);
  letter-spacing: .01em; padding: 0 0 8px; margin-bottom: 2px;
}
.docs-sidebar .grp-title .num {
  color: var(--gray-light); font-weight: 400; margin-right: 5px;
}
.docs-sidebar .grp.current .grp-title .num { color: var(--amber-deep); }
.docs-sidebar .grp-title:hover { color: var(--amber-deep); }
.docs-sidebar .grp.current .grp-title { color: var(--amber-deep); }
.docs-sidebar .leaves { display: grid; gap: 1px; border-left: 1.5px solid var(--line); }
.docs-sidebar a.leaf {
  display: block; font-size: 13px; color: var(--gray); line-height: 1.5;
  padding: 5px 0 5px 14px; border-left: 1.5px solid transparent; margin-left: -1.5px;
  transition: color .15s, border-color .15s;
}
.docs-sidebar a.leaf:hover { color: var(--ink); }
.docs-sidebar a.leaf.on { color: var(--amber-deep); font-weight: 600; border-left-color: var(--amber-deep); }
.docs-sidebar .grp-single { border-left: 1.5px solid transparent; }
.docs-sidebar .grp-single > a.grp-title { padding-left: 0; }

/* Utility link (Download): a product/functional page, not a numbered doc
   chapter -- visually separated from the book index below it. */
.docs-sidebar .ds-util {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--ink);
  padding: 0 0 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.docs-sidebar .ds-util:hover, .docs-sidebar .ds-util.on { color: var(--amber-deep); }
.docs-sidebar .ds-util .ic { opacity: .7; }

/* ---------- Doc intro: plain title block that lives inside the content column ---------- */
.doc-crumb {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--gray-light); margin-bottom: 12px; flex-wrap: wrap;
}
.doc-crumb a { color: var(--gray-light); }
.doc-crumb a:hover { color: var(--ink); text-decoration: underline; }
.doc-crumb .sep { opacity: .6; }
.doc-crumb .now { color: var(--ink); font-weight: 600; }
.doc > h1.doc-title {
  font-size: clamp(28px, 3.6vw, 38px); font-weight: 800; letter-spacing: -0.02em;
  line-height: 1.16; margin: 0 0 14px;
}
.doc-intro { font-size: 16px; color: var(--gray); line-height: 1.72; max-width: 42em; margin-bottom: 20px; }
.doc-meta {
  display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--gray-light);
  padding-bottom: 26px; margin-bottom: 34px; border-bottom: 1px solid var(--line);
}
.doc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.doc-meta a.inline-link { color: inherit; text-decoration-color: var(--line); }

/* Right rail: in-page "On this page" table of contents */
.toc-rail { position: sticky; top: 64px; }
.toc-rail .toc-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gray-light); margin-bottom: 12px; }
.toc-rail nav { display: grid; gap: 3px; border-left: 1.5px solid var(--line); }
.toc-rail a {
  display: block; padding: 6px 14px; font-size: 12.5px; color: var(--gray);
  border-left: 1.5px solid transparent; margin-left: -1.5px; transition: color .15s, border-color .15s;
}
.toc-rail a.sub { padding-left: 26px; font-size: 11.5px; }
.toc-rail a:hover { color: var(--ink); }
.toc-rail a.active { color: var(--ink); font-weight: 600; border-left-color: var(--amber-deep); }

/* ---------- Article typography ---------- */
.doc { max-width: 720px; }
.doc > .doc-sec { margin-bottom: 56px; scroll-margin-top: 90px; }
.doc h2 { font-size: clamp(23px, 2.6vw, 29px); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 16px; scroll-margin-top: 90px; }
.doc h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 28px 0 12px; scroll-margin-top: 90px; }
.doc p { font-size: 15.5px; color: #3a3a3d; line-height: 1.8; margin-bottom: 14px; }
.doc p.lead { font-size: 17px; color: var(--ink); font-weight: 500; }
.doc ul, .doc ol { margin: 0 0 16px 0; display: grid; gap: 9px; }
.doc ul li, .doc ol li { font-size: 15px; color: #3a3a3d; line-height: 1.7; padding-left: 22px; position: relative; }
.doc ul li::before { content: ""; position: absolute; left: 4px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.doc ol { counter-reset: step; }
.doc ol li { counter-increment: step; }
.doc ol li::before { content: counter(step); left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.doc strong { color: var(--ink); font-weight: 700; }
.doc code { font-family: var(--mono); font-size: 13px; background: var(--bg-alt); padding: 2px 6px; border-radius: 5px; color: #b3480d; overflow-wrap: break-word; word-break: break-word; }
.doc a.inline-link { color: var(--blue); text-decoration: underline; text-decoration-color: rgba(0,102,204,.35); }

.doc pre {
  background: #1d1d1f; color: #f1f1f3; border-radius: 14px; padding: 20px 22px;
  overflow-x: auto; margin: 4px 0 20px; font-size: 13px; line-height: 1.7;
}
.doc pre code { background: none; color: inherit; padding: 0; font-family: var(--mono); }
.doc pre .cm { color: #8a8a90; }
.doc pre .k { color: #ffb340; }
.doc pre .s { color: #7ed8b2; }
.doc pre .n { color: #6cb6ff; }
.code-label {
  display: flex; align-items: center; justify-content: space-between;
  background: #141416; color: #a6a6ab; font-size: 11.5px; font-family: var(--mono);
  padding: 8px 16px; border-radius: 14px 14px 0 0; margin-top: 4px;
}
.code-label + pre { border-radius: 0 0 14px 14px; margin-top: 0; }

.doc table, .table-wrap table {
  width: 100%; border-collapse: collapse; margin: 6px 0 22px; font-size: 13.5px;
}
.doc table th, .doc table td, .table-wrap table th, .table-wrap table td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.doc table th, .table-wrap table th { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--gray-light); font-weight: 700; }
.doc table td code, .table-wrap table td code { white-space: nowrap; }
.doc table tr:last-child td, .table-wrap table tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; margin-bottom: 22px; }
.table-wrap table { margin-bottom: 0; }

.callout {
  display: flex; gap: 12px; padding: 16px 18px; border-radius: 14px;
  background: var(--bg-alt); border: 1px solid var(--line); margin: 4px 0 20px;
  font-size: 14px; line-height: 1.7; color: #3a3a3d;
}
.callout .ic { flex: none; font-size: 16px; line-height: 1.4; }
.callout.tip { background: rgba(126,216,178,.12); border-color: rgba(46,184,126,.28); }
.callout.warn { background: rgba(248,143,111,.12); border-color: rgba(224,102,60,.3); }
.callout.note { background: rgba(124,196,232,.12); border-color: rgba(58,151,201,.28); }
.callout p { margin: 0; color: inherit; }
.callout strong { color: inherit; }

.field-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px;
}
.field-card .field-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.field-card .field-name { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--ink); }
.field-card .field-type { font-family: var(--mono); font-size: 11.5px; color: var(--amber-deep); background: rgba(255,179,64,.14); padding: 2px 8px; border-radius: 980px; }
.field-card .field-default { font-size: 12px; color: var(--gray-light); }
.field-card p { margin-bottom: 0; }

.compare-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 4px 0 22px; }
.compare-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.compare-card h4 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.compare-card ul { gap: 6px; margin-bottom: 0; }
.compare-card li { font-size: 13.5px; }

/* ---------- Prev/next article pager ---------- */
.doc-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 54px;
  padding-top: 30px; border-top: 1px solid var(--line);
}
.doc-pager a {
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  display: block; transition: border-color .2s, transform .2s;
}
.doc-pager a:hover { border-color: var(--ink); transform: translateY(-2px); }
.doc-pager .dir { font-size: 11.5px; color: var(--gray-light); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.doc-pager .ttl { font-size: 15px; font-weight: 700; }
.doc-pager .next { text-align: right; }

/* ================================================================
   Download page (download.html) -- a standalone PRODUCT page, not a
   documentation article. Deliberately does NOT reuse .docs-shell /
   .doc / .docs-sidebar / .toc-rail, so it never reads as "another
   manual chapter". Own hero + sticky platform-tab bar + wide grid.
   ================================================================ */
.dl-hero { padding: 96px 0 0; }
.dl-crumb {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--gray-light); margin-bottom: 14px; flex-wrap: wrap;
}
.dl-crumb a { color: var(--gray-light); }
.dl-crumb a:hover { color: var(--ink); text-decoration: underline; }
.dl-crumb .sep { opacity: .6; }
.dl-crumb .now { color: var(--ink); font-weight: 600; }
.dl-hero-title {
  font-size: clamp(32px, 4.2vw, 46px); font-weight: 800; letter-spacing: -0.02em;
  line-height: 1.12; margin: 0 0 16px;
}
.dl-hero-sub { font-size: 16.5px; color: var(--gray); line-height: 1.75; max-width: 640px; margin-bottom: 18px; }
.dl-hero-meta {
  display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--gray-light);
  margin-bottom: 26px;
}
.dl-hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.dl-hero .callout { max-width: 720px; }

.dl-tabs {
  position: sticky; top: 48px; z-index: 20; margin-top: 8px;
  background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.dl-tabs-inner { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.dl-tabs-inner::-webkit-scrollbar { display: none; }
.dl-tabs-inner a {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--gray);
  padding: 8px 16px; border-radius: 980px; transition: color .15s, background .15s;
  white-space: nowrap;
}
.dl-tabs-inner a svg { opacity: .75; }
.dl-tabs-inner a:hover { color: var(--ink); background: var(--bg-alt); }
.dl-tabs-inner a.active { color: var(--ink); background: var(--bg-alt); font-weight: 700; }

.dl-shell { max-width: 1080px; padding: 44px 0 100px; }

.dl-platform { margin: 0 0 64px; padding-top: 26px; scroll-margin-top: 96px; }
.dl-platform-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.dl-platform-head .ic {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  background: var(--bg-alt); display: flex; align-items: center; justify-content: center;
}
.dl-platform-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.dl-platform-note { font-size: 14px; color: var(--gray-light); margin: 8px 0 24px; max-width: 62em; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.dl-card { border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; background: #fff; }
.dl-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.dl-card-head h3 { font-size: 16.5px; font-weight: 700; }
.dl-badge {
  font-size: 11px; font-weight: 700; color: var(--amber-deep);
  background: rgba(255,179,64,.14); padding: 3px 9px; border-radius: 980px;
}
.dl-badge.alt { color: #1c7a52; background: rgba(48,209,88,.14); }
.dl-badge.muted { color: var(--gray-light); background: var(--bg-alt); }
.dl-card p { font-size: 14px; color: #3a3a3d; line-height: 1.7; margin-bottom: 14px; }
.dl-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--gray-light); margin-bottom: 16px; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600; color: #fff; background: var(--ink);
  padding: 9px 18px; border-radius: 980px; transition: opacity .2s;
}
.dl-btn:hover { opacity: .82; }
.dl-btn.secondary { color: var(--ink); background: var(--bg-alt); }
.dl-card .dl-btn { margin: 4px 6px 0 0; }
.core-os-title { font-size: 15px; font-weight: 700; margin: 30px 0 10px; color: var(--ink); }
.dl-platform#core .table-wrap:first-of-type { margin-top: 0; }

.dl-next { padding-top: 40px; border-top: 1px solid var(--line); }
.dl-next h2 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }

@media (max-width: 640px) {
  .dl-hero { padding-top: 76px; }
  .dl-tabs { top: 0; }
}

/* ---------- Related-cards grid (used on tutorial/advanced landing intros) ---------- */
.hub-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 30px 0 10px; }
.hub-card {
  display: block; border: 1px solid var(--line); border-radius: 18px; padding: 22px 22px 20px;
  transition: transform .25s, box-shadow .25s;
}
.hub-card:hover { transform: translateY(-4px); box-shadow: 0 16px 32px rgba(0,0,0,.08); }
.hub-card .hub-ic { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; background: rgba(255,179,64,.14); }
.hub-card h4 { font-size: 15.5px; font-weight: 700; margin-bottom: 6px; }
.hub-card p { font-size: 13px; color: var(--gray); margin: 0; }

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .toc-rail { display: none; }
}

@media (max-width: 900px) {
  .docs-shell { padding-top: 60px; grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar { position: static; max-height: none; order: 2; margin-top: 44px; padding: 0; }
  .docs-sidebar .leaves { display: flex; flex-wrap: wrap; gap: 2px 16px; border-left: none; }
  .docs-sidebar a.leaf { padding: 4px 0; border-left: none; margin-left: 0; }
  .doc { order: 1; min-width: 0; }
  .compare-grid, .hub-grid { grid-template-columns: 1fr; }
  .doc-pager { grid-template-columns: 1fr; }
  .doc-pager .next { text-align: left; }
}

/* ================================================================
   Standalone static pages (about.html / terms.html / privacy.html)
   -- plain single-column text pages, no sidebar / no TOC rail, since
   they're neither documentation chapters nor the download product
   page. Reuses .doc's article typography for headings/paragraphs.
   ================================================================ */
.standalone-page { max-width: 720px; margin: 0 auto; padding: 96px 24px 100px; }
.standalone-page .doc-crumb { margin-bottom: 12px; }
.standalone-page .updated-note {
  font-size: 12.5px; color: var(--gray-light); padding-bottom: 26px;
  margin-bottom: 34px; border-bottom: 1px solid var(--line);
}
@media (max-width: 900px) { .standalone-page { padding-top: 60px; } }
