/* ============================================================
   Map file manual — editorial documentation
   ============================================================ */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 30px;
}

body {
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -4%, rgba(237, 246, 13, 0.3), transparent 36rem),
    radial-gradient(circle at 20% 50%, rgba(171, 176, 166, 0.16), transparent 34rem),
    linear-gradient(to right, var(--line-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px),
    var(--paper);
  background-attachment: fixed;
  background-size: auto, auto, 120px 120px, 120px 120px, auto;
}

a {
  color: inherit;
}

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 0;
  height: 3px;
  background: var(--acid);
  box-shadow: 0 0 16px rgba(237, 246, 13, 0.9);
}

/* ---------------- Shell ---------------- */

.doc-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.doc-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 20px 24px;
  overflow-y: auto;
  background: rgba(245, 246, 240, 0.68);
  border-right: 1px solid var(--line);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 17, 16, 0.24) transparent;
}

.doc-back {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.doc-back:hover strong {
  color: var(--ink);
}

.doc-mark {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: var(--ink);
  border: 0;
  border-radius: 50%;
  transform: rotate(-12deg);
}

.doc-mark i {
  background: var(--acid);
}

.doc-mark i:nth-child(2) {
  margin-top: 3px;
  margin-bottom: 3px;
}

.doc-mark i:nth-child(3) {
  margin-top: 7px;
}

.doc-back strong {
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.16em;
  line-height: 1;
  transition: color 0.18s ease;
}

.doc-back small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1;
}

.toc-heading {
  margin: 40px 0 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.toc-nav {
  display: grid;
  gap: 2px;
}

.toc-link {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  padding: 8px 9px;
  color: var(--muted);
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  text-decoration: none;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.toc-link span {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  line-height: 1.7;
}

.toc-link strong {
  color: inherit;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
}

.toc-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
}

.toc-link.active {
  color: var(--ink);
  background: var(--acid);
  border-left-color: var(--ink);
}

.toc-link.active span {
  color: rgba(17, 17, 16, 0.55);
}

.toc-level-3 {
  padding-left: 16px;
}

.toc-level-3 strong {
  font-size: 10.5px;
}

.toc-meta {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.9;
}

.toc-mobile {
  display: none;
}

.doc-main {
  min-width: 0;
}

/* ---------------- Hero ---------------- */

.doc-hero {
  position: relative;
  padding: clamp(64px, 8vw, 118px) clamp(28px, 8vw, 120px) clamp(46px, 5vw, 70px);
  border-bottom: 1px solid var(--ink);
  background:
    radial-gradient(circle at 82% 10%, rgba(237, 246, 13, 0.34), transparent 24rem),
    linear-gradient(90deg, transparent 0 99px, rgba(17, 17, 16, 0.035) 99px 100px);
  background-size: auto, 100px 100%;
}

.doc-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.doc-kicker::before {
  width: 40px;
  height: 1px;
  background: var(--ink);
  content: "";
}

.doc-hero h1 {
  max-width: 12em;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(44px, 6.4vw, 96px);
  font-weight: 650;
  font-variation-settings: "wght" 650;
  letter-spacing: -0.06em;
  line-height: 0.94;
}

.doc-hero h1::after {
  display: inline-block;
  width: 0.07em;
  height: 0.72em;
  margin-left: 0.05em;
  background: var(--acid);
  content: "";
}

.doc-hero p:last-of-type {
  max-width: 740px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.doc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 24px;
  margin-top: 30px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.doc-stats span::before {
  display: inline-block;
  width: 14px;
  height: 2px;
  margin: 0 7px 2px 0;
  background: var(--acid);
  content: "";
}

/* ---------------- Prose ---------------- */

.doc-prose {
  width: min(920px, calc(100% - 64px));
  margin: 0 auto;
  padding: 58px 0 110px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.95;
}

.doc-prose h2,
.doc-prose h3 {
  position: relative;
  color: var(--ink);
  scroll-margin-top: 30px;
}

.doc-prose h2 {
  margin: 84px 0 26px;
  padding: 22px 0 0 22px;
  border-top: 1px solid var(--line-strong);
  font-family: var(--font-display);
  font-size: clamp(27px, 3.2vw, 40px);
  font-weight: 620;
  font-variation-settings: "wght" 620;
  letter-spacing: -0.04em;
  line-height: 1.18;
}

.doc-prose h2:first-of-type {
  margin-top: 18px;
}

.doc-prose h2::before {
  position: absolute;
  top: 30px;
  left: 0;
  width: 7px;
  height: 18px;
  background: var(--acid);
  border: 1px solid rgba(17, 17, 16, 0.16);
  content: "";
}

.doc-prose h3 {
  margin: 46px 0 16px;
  padding-left: 15px;
  border-left: 3px solid var(--acid);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.35;
}

.doc-prose p {
  margin: 0 0 19px;
  color: var(--ink-soft);
}

.doc-prose strong {
  color: var(--ink);
  font-weight: 650;
}

.doc-prose del {
  color: var(--faint);
}

.doc-prose a {
  color: var(--ink);
  text-decoration-color: var(--acid);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.doc-prose a:hover {
  background: var(--acid);
}

.doc-prose code {
  padding: 0.14em 0.38em;
  color: var(--ink);
  background: var(--acid-ghost);
  border: 1px solid rgba(17, 17, 16, 0.14);
  border-radius: 4px;
  font: 0.88em/1.4 var(--font-mono);
}

.doc-prose pre {
  position: relative;
  margin: 25px 0 30px;
  padding: 44px 22px 22px;
  overflow: auto;
  color: #e8e9e2;
  background: #151613;
  border: 1px solid rgba(17, 17, 16, 0.9);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(17, 17, 16, 0.16);
  line-height: 1.65;
  tab-size: 2;
}

.doc-prose pre::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  padding: 10px 16px;
  color: var(--acid);
  background: #1e1f1a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px 16px 0 0;
  content: attr(data-language);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.doc-prose pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 12px;
}

.doc-prose .table-scroll {
  max-width: 100%;
  margin: 25px 0 30px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.doc-prose table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.doc-prose th,
.doc-prose td {
  padding: 11px 14px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.doc-prose th:last-child,
.doc-prose td:last-child {
  border-right: 0;
}

.doc-prose tbody tr:last-child td {
  border-bottom: 0;
}

.doc-prose th {
  color: var(--ink);
  background: var(--paper-3);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-prose tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.28);
}

.doc-prose tbody tr:hover {
  background: var(--acid-ghost);
}

.doc-prose .align-left { text-align: left; }
.doc-prose .align-center { text-align: center; }
.doc-prose .align-right { text-align: right; }

.doc-prose blockquote {
  margin: 0 0 32px;
  padding: 20px 22px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-left: 4px solid var(--acid);
  border-radius: 0 18px 18px 0;
}

.doc-prose blockquote p {
  margin: 0 0 14px;
  color: inherit;
}

.doc-prose blockquote > :last-child {
  margin-bottom: 0;
}

.doc-prose blockquote pre,
.doc-prose blockquote .table-scroll {
  margin: 18px 0;
}

.doc-prose blockquote.warning-block {
  color: #6d2c20;
  background: #fff1ec;
  border-color: #f0c5b7;
  border-left-color: var(--danger);
}

.warning-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.warning-heading img {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.doc-prose .warning-heading strong {
  color: var(--danger);
}

.doc-prose hr {
  height: 1px;
  margin: 46px 0;
  border: 0;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

.doc-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 74px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------------- Mobile ---------------- */

@media (max-width: 960px) {
  html {
    scroll-padding-top: 88px;
  }

  .doc-shell {
    display: block;
  }

  .doc-sidebar {
    display: none;
  }

  .toc-mobile {
    position: sticky;
    top: 0;
    z-index: 30;
    display: block;
    background: rgba(245, 246, 240, 0.76);
    border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    backdrop-filter: blur(22px) saturate(160%);
  }

  .toc-mobile summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 0 18px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    list-style: none;
    cursor: pointer;
  }

  .toc-mobile summary::-webkit-details-marker {
    display: none;
  }

  .toc-mobile summary::after {
    color: var(--ink);
    content: "目录 ＋";
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.12em;
  }

  .toc-mobile[open] summary::after {
    content: "收起 －";
  }

  .toc-mobile .toc-nav {
    max-height: min(65vh, 520px);
    padding: 0 12px 16px;
    overflow-y: auto;
  }

  .doc-hero {
    padding: 54px 24px 44px;
  }

  .doc-prose {
    width: min(100% - 38px, 820px);
    padding-top: 40px;
  }
}

@media (max-width: 560px) {
  .doc-hero h1 {
    font-size: 38px;
  }

  .doc-hero p:last-of-type {
    font-size: 13px;
  }

  .doc-prose {
    width: calc(100% - 28px);
    font-size: 14px;
  }

  .doc-prose h2 {
    margin-top: 62px;
    font-size: 27px;
  }

  .doc-prose h3 {
    font-size: 19px;
  }

  .doc-prose pre {
    margin-right: -2px;
    margin-left: -2px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .doc-footer {
    flex-direction: column;
  }
}

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