/* johndegen — 浅色阅读主题 */

:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --surface: #eef3f9;
  --line: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --text-body: #334155;
  --muted: #64748b;
  --accent: #1d6fdc;
  --accent-hover: #1558b8;
  --accent-soft: rgba(29, 111, 220, 0.1);
  --max: 42rem;
  --toc-width: 14rem;
  --header-offset: 3.75rem;
  --sticky-top: var(--header-offset);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.header-inner {
  max-width: calc(var(--toc-width) + 2.5rem + var(--max));
  margin: 0 auto;
  padding: 0.85rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  color: #fff !important;
  text-decoration: none !important;
  background: var(--accent);
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(29, 111, 220, 0.25);
}

.nav-cta:hover {
  background: var(--accent-hover);
  color: #fff !important;
}

.article-shell {
  max-width: calc(var(--toc-width) + 2.5rem + var(--max));
  margin: 0 auto;
  padding: 0 1.2rem 3rem;
}

.hero {
  padding: 2.6rem 0 1.2rem;
}

.hero h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-weight: 900;
  line-height: 1.24;
  letter-spacing: -0.012em;
  color: var(--text);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lead {
  margin: 0 0 1.1rem;
  font-size: 1.05rem;
  color: var(--muted);
}

.meta {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.meta time {
  color: #475569;
}

.article-body {
  min-width: 0;
}

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

.article-body h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.35rem;
  color: var(--text);
  scroll-margin-top: var(--sticky-top);
}

.article-body h3 {
  margin: 1.6rem 0 0.75rem;
  font-size: 1.1rem;
  color: var(--text);
}

.article-body ul {
  margin: 0 0 1.1rem;
  padding-left: 1.25rem;
}

.article-body li {
  margin: 0.45rem 0;
}

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

code.inline {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.9em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.12em 0.4em;
  color: var(--text);
}

.article-body ol {
  margin: 0 0 1.1rem;
  padding-left: 1.25rem;
}

.compare-table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.25rem;
}

.compare-table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.compare-table th,
.compare-table td {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.compare-table th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.compare-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface) 40%, transparent);
}

.checklist-block {
  margin: 1rem 0 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.checklist-block h3 {
  margin-top: 0;
  font-size: 1rem;
}

.checklist-block ol {
  margin-bottom: 0;
}

/* 左侧粘性目录 */
.article-toc {
  margin: 0 0 2rem;
}

.article-toc__card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1rem 1.05rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.article-toc__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.article-toc__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.article-toc__icon svg {
  width: 1rem;
  height: 1rem;
}

.article-toc__label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.article-toc__title {
  margin: 0.15rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.article-toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.84rem;
  line-height: 1.45;
}

.article-toc__list li + li {
  margin-top: 0.15rem;
}

.article-toc__list a {
  display: block;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  border-left: 2px solid transparent;
}

.article-toc__list a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 1023px) {
  .article-shell {
    padding-bottom: 2.5rem;
  }

  .hero {
    padding-top: 2rem;
    padding-bottom: 0.75rem;
  }

  .article-toc {
    margin-bottom: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .article-shell {
    display: grid;
    grid-template-columns: var(--toc-width) minmax(0, var(--max));
    column-gap: 2.25rem;
    align-items: start;
  }

  .hero {
    grid-column: 1 / -1;
    grid-row: 1;
    padding-top: 2.5rem;
  }

  .article-toc {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    position: sticky;
    top: var(--sticky-top);
    align-self: start;
    max-height: calc(100vh - var(--sticky-top) - 1.25rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .article-body {
    grid-column: 2;
    grid-row: 2;
  }
}

.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  color: var(--accent);
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease,
    transform 0.2s ease,
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.back-to-top svg {
  width: 1.15rem;
  height: 1.15rem;
}

.tip {
  margin: 1.2rem 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 0.95rem 1rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.article-footer {
  margin-top: 2.6rem;
  padding: 1.2rem 0 0.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

/* 教程列表页 */
.tutorial-page {
  max-width: calc(var(--toc-width) + 2.5rem + var(--max));
  margin: 0 auto;
  padding: 0 1.2rem 3rem;
}

.tutorial-page > header,
.tutorial-page > .page-hero {
  padding-top: 2.5rem;
}

.tutorial-page h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 800;
  color: var(--text);
}

.breadcrumb {
  margin: 1.5rem 0 1rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--muted);
}

.breadcrumb a {
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.tutorial-intro {
  margin-bottom: 1.25rem;
}

.tutorial-intro .meta {
  margin: 0 0 0.75rem;
}

.tutorial-intro__lead {
  margin: 0 0 1rem;
  max-width: 40rem;
  color: var(--text-body);
}

.tutorial-search {
  margin: 0 0 1.35rem;
  padding: 1rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.tutorial-search__label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.tutorial-search__input {
  width: 100%;
  max-width: 28rem;
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tutorial-search__input::placeholder {
  color: var(--muted);
}

.tutorial-search__input:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.tutorial-search__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tutorial-search__status {
  margin: 0.55rem 0 0;
  min-height: 1.35em;
  font-size: 0.84rem;
  color: var(--muted);
}

.card[hidden] {
  display: none;
}

.empty-state {
  margin: 1.5rem 0 0;
  padding: 1.25rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.cards {
  display: grid;
  gap: 0.9rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.08rem;
}

.card h2 a {
  color: var(--text);
  text-decoration: none;
}

.card h2 a:hover {
  color: var(--accent);
}

.card .meta {
  margin: 0 0 0.45rem;
  font-size: 0.84rem;
}

.card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.doc-figure {
  margin: 1.2rem 0 1.45rem;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.doc-figure img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}

.doc-figure figcaption {
  margin-top: 0.65rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

/* 404 */
.error-page {
  min-height: calc(100vh - var(--header-offset) - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.2rem 3rem;
}

.error-page__card {
  width: 100%;
  max-width: 32rem;
  padding: 2.25rem 2rem;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.error-page__code {
  margin: 0 0 0.5rem;
  font-size: clamp(3rem, 12vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: color-mix(in srgb, var(--accent) 18%, var(--muted));
}

.error-page h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 800;
  color: var(--text);
}

.error-page__lead {
  margin: 0 0 1.5rem;
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--text-body);
}

.error-page__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.error-page__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 8.5rem;
  padding: 0.6rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none !important;
  border-radius: 8px;
}

.error-page__btn--primary {
  color: #fff !important;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(29, 111, 220, 0.25);
}

.error-page__btn--primary:hover {
  background: var(--accent-hover);
  color: #fff !important;
}

.error-page__btn--secondary {
  color: var(--accent) !important;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
}

.error-page__btn--secondary:hover {
  color: var(--accent-hover) !important;
}

.error-page__hint {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--muted);
}

.error-page__footer {
  padding: 0 1.2rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.error-page__footer p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .back-to-top {
    transition: none;
  }
}

.article-body > .doc-figure {
  margin-left: 0;
  margin-right: 0;
}

.article-body > section > .doc-figure:first-child {
  margin-top: 0.5rem;
}
