/* =========================================================================
   ClashManual — shared design system
   Used by every non-homepage page (tutorial / advanced / docs / glossary /
   faq / blog). The homepage (index.html) keeps its own self-contained
   styles; this file mirrors its color tokens and component patterns so the
   whole site feels like one product.
   ========================================================================= */

:root {
  --ink: #1d1d1f;
  --gray: #6e6e73;
  --gray-light: #86868b;
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --blue: #0066cc;
  --amber: #ffb340;
  --amber-deep: #f59e0b;
  --line: #e5e5e7;
  --radius-tile: 22px;
  --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }
button { font-family: inherit; }
::selection { background: rgba(255, 179, 64, .35); }

.container { width: min(1024px, 90%); margin: 0 auto; }
.container-wide { width: min(1280px, 94%); margin: 0 auto; }

/* ===================== Global nav ===================== */
.globalnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 48px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.globalnav-inner {
  max-width: 1120px; height: 100%; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.gn-logo { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 15px; letter-spacing: -.02em; min-width: 0; flex-shrink: 1; }
.gn-logo-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gn-logo img { width: 24px; height: 24px; border-radius: 6px; display: block; flex: none; }
.gn-logo .gn-logo-tag {
  flex: none;
  font-size: 10px; font-weight: 700; color: var(--gray-light); letter-spacing: .04em;
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; margin-left: 2px;
}
.gn-links { display: flex; gap: 24px; }
.gn-links a {
  font-size: 12.5px; color: rgba(29, 29, 31, .8); font-weight: 400;
  transition: color .2s; white-space: nowrap;
}
.gn-links a:hover, .gn-links a.on { color: var(--ink); font-weight: 600; }
.gn-right { display: flex; align-items: center; gap: 14px; flex: none; }

/* "Tutorials & Manual" dropdown index in the global nav */
.gn-dropdown { position: relative; display: flex; align-items: center; }
.gn-dropdown-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 0; font-family: inherit;
  font-size: 12.5px; color: rgba(29, 29, 31, .8); transition: color .2s;
  /* Plain .gn-links a's get their box height from the inherited body
     line-height (1.6 * 12.5px = 20px); this button is a flex container, so
     it sizes to its content's tighter flex-line height instead and ends up
     a few px shorter -- varying with each locale's font metrics. Pin it to
     the same 20px so the label never floats relative to its siblings. */
  height: 20px; line-height: 20px;
}
.gn-dropdown-btn svg { opacity: .6; transition: transform .2s; }
.gn-dropdown-btn:hover, .gn-dropdown-btn.on { color: var(--ink); font-weight: 600; }
.gn-dropdown.open .gn-dropdown-btn svg { transform: rotate(180deg); }
.gn-dropdown-menu {
  position: absolute; top: calc(100% + 16px); left: 50%; z-index: 10;
  width: 300px; transform: translate(-50%, -6px);
  background: rgba(255,255,255,.98); backdrop-filter: blur(20px);
  border: 1px solid rgba(0,0,0,.08); border-radius: 16px;
  padding: 8px; box-shadow: 0 20px 40px rgba(0,0,0,.14);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transition: all .2s ease;
}
.gn-dropdown.open .gn-dropdown-menu { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.gn-dropdown-menu a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 12px; border-radius: 10px; transition: background .15s;
}
.gn-dropdown-menu a:hover, .gn-dropdown-menu a.on { background: var(--bg-alt); }
.gn-dropdown-menu a .t { font-size: 13px; font-weight: 600; color: var(--ink); }
.gn-dropdown-menu a.on .t { color: var(--amber-deep); }
.gn-dropdown-menu a .d { font-size: 11.5px; color: var(--gray-light); }

/* Search shortcut: opens the site search modal (see search.js), also
   reachable via Ctrl/⌘+K from anywhere. */
.gn-search-btn {
  flex: none; height: 30px; border-radius: 8px; padding: 0 8px 0 9px;
  display: flex; align-items: center; gap: 6px; font-family: inherit;
  background: var(--bg-alt); border: 1px solid var(--line); color: var(--gray-light);
  cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.gn-search-btn:hover { color: var(--ink); border-color: #c2c2c7; background: #ececf0; }
.gn-search-label { font-size: 12.5px; white-space: nowrap; }
.gn-search-kbd {
  font-size: 10.5px; font-family: var(--mono); color: var(--gray-light);
  background: #fff; border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; white-space: nowrap;
}
@media (max-width: 1080px) { .gn-search-label { display: none; } .gn-search-btn { padding: 0 8px; } }
@media (max-width: 960px) { .gn-search-btn { display: none; } }
.gn-lang { position: relative; }
.gn-lang-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 0; font-family: inherit;
  font-size: 12.5px; color: rgba(29, 29, 31, .8); transition: color .2s;
}
.gn-lang-btn svg { opacity: .6; transition: transform .2s; }
.gn-lang-short { display: none; }
.gn-lang-btn:hover, .gn-lang.open .gn-lang-btn { color: var(--ink); }
.gn-lang.open .gn-lang-btn svg { transform: rotate(180deg); }
.gn-lang-menu {
  position: absolute; top: calc(100% + 14px); right: -10px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(20px);
  border: 1px solid rgba(0,0,0,.08); border-radius: 14px;
  padding: 8px; min-width: 132px;
  box-shadow: 0 20px 40px rgba(0,0,0,.12);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: all .25s ease;
}
.gn-lang.open .gn-lang-menu { opacity: 1; visibility: visible; transform: none; }
.gn-lang-menu li + li { margin-top: 2px; }
.gn-lang-menu a, .gn-lang-menu span {
  display: block; padding: 7px 12px; font-size: 12.5px; border-radius: 8px;
}
.gn-lang-menu a { color: var(--gray); text-decoration: none; }
.gn-lang-menu a:hover { background: rgba(0,0,0,.05); color: var(--ink); }
.gn-lang-menu span.on { color: var(--ink); font-weight: 600; cursor: default; }
.gn-download {
  font-size: 12px; font-weight: 500;
  background: var(--ink); color: #fff;
  padding: 6px 14px; border-radius: 980px;
  transition: opacity .2s; white-space: nowrap;
}
.gn-download:hover { opacity: .82; }
.gn-download.on { background: var(--amber-deep); }
.gn-burger { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.gn-burger span { display: block; width: 18px; height: 1.5px; background: var(--ink); margin: 4.5px 0; border-radius: 2px; }
.gn-mobile {
  display: none; position: fixed; top: 48px; left: 0; right: 0; z-index: 99;
  max-height: calc(100vh - 48px); overflow-y: auto; overscroll-behavior: contain;
  background: rgba(255,255,255,.98); backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
  padding: 14px 22px 24px; flex-direction: column; gap: 2px;
}
.gn-mobile.show { display: flex; }
body.mobile-nav-open { overflow: hidden; }
.gn-mobile a { padding: 13px 4px; font-size: 16px; font-weight: 500; border-bottom: 1px solid rgba(0,0,0,.05); }
.gn-mobile a.on { color: var(--amber-deep); font-weight: 700; }
.gn-mobile-search {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font-family: inherit; font-size: 14px; font-weight: 500; color: var(--gray-light);
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 14px; margin-bottom: 12px; cursor: pointer;
}
.gn-mobile-search svg { flex: none; opacity: .8; }

@media (max-width: 960px) {
  .gn-links { display: none; }
  .gn-burger { display: block; }
}

/* Keep the download CTA visible at every width -- it's the single most
   important action on the site, so it should never hide behind the burger
   menu. Everything else in .gn-right shrinks around it instead. */
@media (max-width: 640px) {
  .gn-right { gap: 8px; }
  .gn-lang-label { display: none; }
  .gn-lang-short { display: block; }
  .gn-lang-btn { padding: 4px; }
  .gn-download { padding: 6px 12px; font-size: 11.5px; }
}

@media (max-width: 480px) {
  .globalnav-inner { padding: 0 14px; }
  .gn-logo .gn-logo-tag { display: none; }
  .gn-right { gap: 6px; }
  .gn-download { padding: 6px 10px; }
  .gn-burger { padding: 6px 2px 6px 6px; }
}

/* ===================== Search modal (search.js) ===================== */
body.search-modal-open { overflow: hidden; }
.search-modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, .4);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 20px 40px;
  opacity: 0; visibility: hidden; transition: opacity .15s ease;
}
.search-modal-overlay.show { opacity: 1; visibility: visible; }
.search-modal {
  width: 100%; max-width: 620px; max-height: 70vh;
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  transform: translateY(-8px); transition: transform .15s ease;
}
.search-modal-overlay.show .search-modal { transform: none; }
.search-modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--gray-light);
  flex: none;
}
.search-modal-input {
  flex: 1; border: none; outline: none; font-family: inherit;
  font-size: 15px; color: var(--ink); background: none;
}
.search-modal-close {
  flex: none; font-family: var(--mono); font-size: 11px; color: var(--gray-light);
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: 5px;
  padding: 2px 7px; cursor: pointer;
}
.search-modal-results { overflow-y: auto; flex: 1; padding: 8px; }
.search-result {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
}
.search-result.active, .search-result:hover { background: var(--bg-alt); }
.sr-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.sr-title mark, .sr-excerpt mark {
  background: rgba(255, 179, 64, .35); color: var(--ink); border-radius: 3px;
}
.sr-excerpt {
  font-size: 12.5px; color: var(--gray); line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sr-page { font-size: 11px; color: var(--gray-light); }
.search-modal-empty {
  padding: 40px 20px; text-align: center; font-size: 13px; color: var(--gray-light);
}
.search-modal-foot {
  display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--gray-light); flex: none;
}
.search-modal-foot kbd {
  font-family: var(--mono); background: var(--bg-alt); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; margin-right: 3px;
}
@media (max-width: 600px) {
  .search-modal-overlay { padding: 8vh 12px 24px; }
  .search-modal-foot span:first-child { display: none; }
}

/* ===================== Buttons & links ===================== */
.btn-fill {
  background: var(--ink); color: #fff;
  font-size: 16px; font-weight: 500;
  padding: 12px 28px; border-radius: 980px;
  transition: transform .25s, opacity .2s; display: inline-block;
}
.btn-fill:hover { opacity: .85; transform: scale(1.02); }
.btn-outline {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line);
  font-size: 15px; font-weight: 500; padding: 11px 26px; border-radius: 980px;
  display: inline-block; transition: border-color .2s, transform .2s;
}
.btn-outline:hover { border-color: var(--ink); transform: scale(1.02); }
.link-arrow {
  font-size: 15px; color: var(--blue); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
}
.link-arrow::after { content: "\203A"; font-size: 17px; transition: transform .2s; }
.link-arrow:hover::after { transform: translateX(3px); }

/* ===================== Section helpers ===================== */
.sec-label {
  display: block; font-size: 13px; font-weight: 700; color: var(--amber-deep);
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 12px;
}
.tag {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--amber-deep);
  background: rgba(255,179,64,.14); padding: 4px 11px; border-radius: 980px;
}
.tag.blue { color: #1f6d99; background: rgba(41,151,255,.12); }
.tag.green { color: #1c7a52; background: rgba(48,209,88,.14); }
.tag.gray { color: var(--gray); background: var(--bg-alt); }

/* ===================== Reveal-on-scroll ===================== */
.fx { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.2,.7,.3,1), transform .7s cubic-bezier(.2,.7,.3,1); }
.fx.on { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .fx { opacity: 1; transform: none; }
}

/* ===================== Footer ===================== */
.footer { background: var(--bg-alt); padding: 40px 0 32px; font-size: 12px; color: var(--gray); margin-top: 60px; }
.footer-brand {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.footer-logo {
  flex: none; display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em;
}
.footer-logo img { border-radius: 6px; display: block; }
.footer-logo-tag {
  font-size: 10px; font-weight: 700; color: var(--gray-light); letter-spacing: .04em;
  border: 1px solid #d2d2d7; border-radius: 5px; padding: 1px 6px; margin-left: 2px;
}
.footer-brand p { color: var(--gray-light); font-size: 12.5px; margin: 0; }
.footer-note {
  padding-bottom: 20px; border-bottom: 1px solid #d2d2d7;
  max-width: 62em; line-height: 1.7; color: var(--gray-light);
}
.footer-note b { color: var(--gray); font-weight: 600; }
.footer-cols {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 26px; padding: 26px 0;
  border-bottom: 1px solid #d2d2d7;
}
.footer-cols h5 { font-size: 12px; color: var(--ink); margin-bottom: 10px; font-weight: 600; }
.footer-cols li { margin-bottom: 8px; }
.footer-cols a { color: var(--gray); }
.footer-cols a:hover { text-decoration: underline; color: var(--ink); }
.footer-langs { display: flex; flex-wrap: wrap; gap: 7px; }
.footer-langs a, .footer-langs span {
  padding: 4px 12px; border: 1px solid #d2d2d7; border-radius: 980px;
  font-size: 11.5px; color: var(--gray);
}
.footer-langs a { cursor: pointer; text-decoration: none; transition: border-color .2s, color .2s; }
.footer-langs a:hover { border-color: var(--ink); color: var(--ink); }
.footer-langs span.on { background: var(--ink); border-color: var(--ink); color: #fff; cursor: default; }
.footer-base {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap; padding-top: 20px;
}
.footer-base a { color: var(--blue); }
.footer-base a:hover { text-decoration: underline; }
.footer-gh { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 900px) {
  .footer-cols { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 600px) {
  .footer-brand { flex-direction: column; align-items: flex-start; gap: 6px; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
}
