/* ── Switzer ── */
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-Regular.otf') format('opentype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-Italic.otf') format('opentype'); font-weight: 400; font-style: italic; }
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-Medium.otf') format('opentype'); font-weight: 500; font-style: normal; }
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-MediumItalic.otf') format('opentype'); font-weight: 500; font-style: italic; }
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-Semibold.otf') format('opentype'); font-weight: 600; font-style: normal; }
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-Bold.otf') format('opentype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'Switzer'; src: url('Assets/Fonts/Switzer/Switzer-Light.otf') format('opentype'); font-weight: 300; font-style: normal; }

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

:root {
  --bg: #FAFAFA;
  --bg-subtle: #FAFAFA;
  --border: #e8e8e4;
  --text: #1a1a18;
  --text-muted: #787872;
  --text-faint: #b0b0a8;
  --accent: #1a1a18;
  --tag-bg: #f0f0ec;
  --tag-text: #5a5a54;
  --hover-bg: #f4f4f0;
  --toggle-bg: #e8e8e4;
  --link: #1a1a18;
  --code-bg: #f4f4f0;
  --toast-bg: #ffffff;
}

[data-theme="dark"] {
  --bg: #0f0f0d;
  --bg-subtle: #161614;
  --border: #262622;
  --text: #e8e8e2;
  --text-muted: #7a7a72;
  --text-faint: #3e3e38;
  --accent: #e8e8e2;
  --tag-bg: #1e1e1a;
  --tag-text: #8a8a82;
  --hover-bg: #161614;
  --toggle-bg: #262622;
  --link: #e8e8e2;
  --code-bg: #1e1e1a;
  --toast-bg: #1a1a1a;
}

html { font-size: 15px; }

body {
  font-family: 'Switzer', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s, opacity 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }

.wrapper {
  max-width: 660px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Nav ── */
.wrapper > nav {
  display: none;
}

.nav-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: color 0.12s;
}
.nav-name:hover { color: var(--text-muted); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle {
  width: 32px;
  height: 18px;
  background: #1a1a18;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3e3e3a;
  transition: transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1), background 0.3s ease;
}
[data-theme="dark"] .theme-toggle { background: #e8e8e4; }
[data-theme="dark"] .theme-toggle::after {
  transform: translateX(14px);
  background-color: #e8e8e4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 14 14'%3E%3Ccircle cx='7' cy='7' r='2.4' fill='%231a1a18'/%3E%3Cg stroke='%231a1a18' stroke-width='1.3' stroke-linecap='round'%3E%3Cline x1='7' y1='0.5' x2='7' y2='2.8'/%3E%3Cline x1='7' y1='11.2' x2='7' y2='13.5'/%3E%3Cline x1='0.5' y1='7' x2='2.8' y2='7'/%3E%3Cline x1='11.2' y1='7' x2='13.5' y2='7'/%3E%3Cline x1='2.2' y1='2.2' x2='3.9' y2='3.9'/%3E%3Cline x1='10.1' y1='10.1' x2='11.8' y2='11.8'/%3E%3Cline x1='11.8' y1='2.2' x2='10.1' y2='3.9'/%3E%3Cline x1='3.9' y1='10.1' x2='2.2' y2='11.8'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px 10px;
}

/* ── Article header ── */
.article-header {
  /* padding-top matches sidebar top: 100px so header and sidebar align vertically */
  padding: 100px 0 36px;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-family: 'Switzer', system-ui, sans-serif;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 16px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.article-date {
  font-size: 11px;
  color: var(--text-muted);
}

.article-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
}

/* ── Article body ── */
.article-body {
  padding: 40px 0 48px;
}

.article-body p {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 24px;
}

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

.article-body a {
  border-bottom: 1px solid var(--border);
  transition: border-color 0.12s, opacity 0.12s;
}
.article-body a:hover { border-color: var(--text-muted); opacity: 0.72; }

.article-body h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  margin-top: 44px;
  margin-bottom: 16px;
}

.article-body h3 {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  margin-top: 60px;
  margin-bottom: 24px;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

.article-body strong { font-weight: 500; }
.article-body em { font-style: italic; }

.article-body code {
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-muted);
}

/* ── Before / After block ── */
.ba-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 28px 0;
}

.ba-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ba-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  object-position: top;
  display: block;
}

.ba-img2 {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  object-position: top;
  display: block;
}

.ba-caption {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ba-label, .download-label {
  font-size: 11px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.12s ease;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  border: none !important;
  margin-top: 16px;
}
.ba-label:hover, .download-label:hover { color: var(--text-muted); opacity: 1 !important; }

.copy-icon-mask {
  width: 12px;
  height: 12px;
  background-color: currentColor;
  -webkit-mask: url('Assets/Icons/Copy.svg') no-repeat center;
  mask: url('Assets/Icons/Copy.svg') no-repeat center;
  -webkit-mask-size: contain;
  mask-size: contain;
  display: inline-block;
  flex-shrink: 0;
}

.download-icon-mask {
  width: 12px;
  height: 12px;
  background-color: currentColor;
  -webkit-mask: url('Assets/Icons/download.svg') no-repeat center;
  mask: url('Assets/Icons/download.svg') no-repeat center;
  -webkit-mask-size: contain;
  mask-size: contain;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Table ── */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 14px;
}
.comparison-table th {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}
.comparison-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

/* ── Numbered steps ── */
.steps {
  list-style: none;
  margin: 20px 0 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.steps li {
  display: flex;
  gap: 14px;
  align-items: baseline;
}

.step-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  flex-shrink: 0;
  width: 16px;
}

.step-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
}

/* ── Prev / Next ── */
.article-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0 56px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.article-nav-link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 240px;
  transition: color 0.15s, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.article-nav-link:hover { color: var(--text); }
.article-nav-link.prev:hover { transform: translateX(-3px); }
.article-nav-link.next:hover { transform: translateX(3px); }
.article-nav-link.next { text-align: right; }

.article-nav-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.article-nav-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
}

/* ── Left sidebar ── */
.article-aside {
  position: fixed;
  top: 100px;
  /*
   * Positioning: sidebar right edge sits 30% away from the body content left edge.
   * Content left edge = 50vw - 330px  (half viewport minus half content width)
   * Gap = 30% of that space  →  (50vw - 330px) * 0.30
   * Sidebar left = content_left - gap - sidebar_width
   *              = (50vw - 330px) * 0.70 - 148px
   *
   * 参数 you can edit:
   *   0.70  → controls gap ratio (1 - 0.30). Increase to bring sidebar closer to content.
   *   330px → half the max content width (matches wrapper max-width 660px ÷ 2)
   *   148px → sidebar width (must match the width property below)
   */
  left: max(24px, calc((50vw - 330px) * 0.40 - 148px));
  width: 148px; /* 参数: sidebar width */
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 10;
}

.aside-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  text-decoration: none;
  padding: 0;
  transition: color 0.1s ease;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
}
.aside-back:hover { color: var(--text-muted); }
.aside-back svg {
  flex-shrink: 0;
  display: block;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.aside-back:hover svg { transform: translateX(-3px); }

.aside-toc {
  margin-top: 20px;
  opacity: 1;
}

.aside-toc-label { display: none; }

.aside-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  /* Track line — edit width (参数: border-left-width) and color (参数: border-left-color) */
  border-left: 1px solid var(--border);
}

.aside-toc-item a {
  display: block;
  font-size: 12px;
  font-weight: 400; /* Default item weight — edit here (参数: font-weight) */
  color: var(--text-faint);
  text-decoration: none;
  padding: 4px 0 4px 10px;
  line-height: 1.4;
  transition: color 0.1s ease, font-weight 0s;
  border-bottom: none !important;
}
.aside-toc-item a:hover { color: var(--text-muted); opacity: 1 !important; }

/* Active section — edit weight (参数: font-weight) and indicator width (参数: border-left-width) */
.aside-toc-item.active a { color: var(--text); font-weight: 500; }
.aside-toc-item.active { border-left: 2px solid var(--text); margin-left: -2px; }

@media (max-width: 1100px) {
  .article-aside { display: none; }
}

/* ── Toast ── */
#toast {
  visibility: hidden;
  width: max-content;
  max-width: 90vw;
  background-color: var(--toast-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.2);
  border: 0.5px solid var(--border);
}

.toast-icon {
  width: 14px;
  height: 14px;
  background-color: var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#toast.show {
  visibility: visible;
  animation: slidein 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards,
             fadeout 0.4s 2.6s forwards;
}

@keyframes slidein { from { bottom: 0; opacity: 0; } to { bottom: 30px; opacity: 1; } }
@keyframes fadeout { from { bottom: 30px; opacity: 1; } to { bottom: 0; opacity: 0; } }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-name { font-size: 11px; color: var(--text-faint); }
.footer-links { display: flex; gap: 16px; }
.footer-link { font-size: 11px; color: var(--text-faint); text-decoration: none; transition: color 0.12s; }
.footer-link:hover { color: var(--text-muted); }

@media (max-width: 480px) {
  h1 { font-size: 24px; }
  .ba-grid { grid-template-columns: 1fr; }
}
