/* ==========================================================================
   work.css — 文档阅读页 / Document reading view
   Loaded after base.css. Used by work-roulette.html / work-goat.html /
   work-tribe.html (generated by build/build_docs.py).
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reading progress
   -------------------------------------------------------------------------- */

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 80;
  background: transparent;
  pointer-events: none;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--red);
  transition: width 0.08s linear;
}

/* --------------------------------------------------------------------------
   Document hero
   -------------------------------------------------------------------------- */

.doc-hero {
  padding: 54px 0 60px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--ink);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 38px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--red);
}

.crumbs span[aria-hidden] {
  color: var(--line);
}

.doc-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 72px;
  align-items: start;
}

.doc-hero__main .kicker {
  margin-bottom: 18px;
}

.doc-hero__title {
  color: var(--ink);
  font-size: clamp(40px, 5.2vw, 66px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin-bottom: 16px;
}

.doc-hero__en {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.doc-hero__deck {
  max-width: 46em;
  color: var(--ink-2);
  font-size: 17.5px;
  line-height: 1.8;
}

.doc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin-top: 26px;
}

.doc-chips li {
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
}

/* Side facts */
.doc-hero__side {
  padding-top: 12px;
  border-top: 2px solid var(--ink);
}

.doc-side__label {
  margin-bottom: 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.doc-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.doc-fact {
  padding: 8px 0 9px;
  border-top: 1px solid var(--line);
}

.doc-fact dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.doc-fact dd {
  margin-top: 3px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13.5px;
  letter-spacing: -0.01em;
}

.doc-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.75;
}

.doc-hero__side .link-arrow {
  display: inline-flex;
  margin-top: 18px;
  font-size: 12px;
}

/* Mobile TOC trigger */
.toc-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  padding: 11px 14px;
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.toc-toggle::after {
  content: "↓";
  color: var(--red);
}

/* --------------------------------------------------------------------------
   Body layout
   -------------------------------------------------------------------------- */

.doc-body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 72px;
  align-items: start;
  padding-block: 64px 96px;
}

/* Sticky table of contents: stays put while the article scrolls */
.doc-aside {
  position: sticky;
  top: calc(var(--head-h) + 24px);
  max-height: calc(100vh - var(--head-h) - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  border-top: 1px solid var(--ink);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.doc-aside::-webkit-scrollbar {
  width: 4px;
}

.doc-aside::-webkit-scrollbar-thumb {
  background: var(--line);
}

.doc-aside__inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-top: 16px;
}

.doc-aside__top {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
}

.doc-aside__top .mono {
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.toc-close {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}

/* TOC */
.toc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc__count {
  color: var(--faint);
  letter-spacing: 0.04em;
}

.toc__list,
.toc__sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc__item {
  border-bottom: 1px solid var(--line-2);
}

.toc__item > a {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 11px 0;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.45;
  text-decoration: none;
  transition: color 0.15s ease;
}

.toc__item > a:hover {
  color: var(--red);
}

.toc__no {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.toc__item.is-active > a {
  color: var(--red);
}

.toc__item.is-active > a .toc__no {
  color: var(--red);
}

.toc__sub {
  display: none;
  padding: 0 0 8px 30px;
}

.toc__item.is-active .toc__sub {
  display: block;
}

.toc__sub li a {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 6px;
  padding: 5px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
}

.toc__sub li a:hover {
  color: var(--ink);
}

.toc__sub .toc__no {
  font-size: 9px;
  padding-top: 1px;
}

.toc__sub li.is-active a {
  color: var(--red);
}

.doc-aside__foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
}

.doc-aside__foot a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-decoration: none;
}

.doc-aside__foot a:hover {
  color: var(--red);
}

/* Scrim behind the mobile TOC drawer */
.toc-scrim {
  position: fixed;
  inset: var(--head-h) 0 0;
  z-index: 60;
  background: rgba(11, 11, 12, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body.toc-open .toc-scrim {
  opacity: 1;
  pointer-events: auto;
}

body.toc-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Article
   -------------------------------------------------------------------------- */

.prose {
  max-width: 800px;
  min-width: 0;
  color: var(--ink-2);
}

.prose p {
  margin-bottom: 20px;
  font-size: 16.5px;
  line-height: 1.94;
}

.prose .is-lead {
  margin-bottom: 24px;
  color: var(--ink);
  font-size: 18.5px;
  line-height: 1.8;
}

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

.prose a {
  color: var(--red-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Section headings */
.prose h2 {
  margin: 68px 0 22px;
  padding-top: 22px;
  border-top: 1px solid var(--ink);
  color: var(--ink);
  font-size: 29px;
  font-weight: 800;
  line-height: 1.32;
  letter-spacing: -0.02em;
  scroll-margin-top: calc(var(--head-h) + 24px);
}

.prose h2 .sec-no {
  display: block;
  margin-bottom: 9px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.prose h3 {
  margin: 38px 0 14px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  scroll-margin-top: calc(var(--head-h) + 24px);
}

.prose h3 .h3-no {
  margin-right: 8px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* Lists */
.prose .bullets,
.prose .steps {
  margin: 0 0 24px;
  list-style: none;
}

.prose .bullets li,
.prose .steps li {
  position: relative;
  margin-bottom: 11px;
  padding-left: 28px;
  font-size: 16px;
  line-height: 1.85;
}

.prose .bullets li::before {
  content: "—";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--red);
  font-weight: 700;
}

.prose .steps {
  counter-reset: step;
}

.prose .steps li {
  padding-left: 34px;
  counter-increment: step;
}

.prose .steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 4px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

/* Tables */
.table-wrap {
  margin: 26px 0 32px;
  overflow-x: auto;
  border-top: 2px solid var(--ink);
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  height: 5px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line);
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.66;
}

.tbl--wide {
  min-width: 780px;
}

.tbl th {
  padding: 9px 14px;
  border-bottom: 1px solid var(--ink);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  vertical-align: bottom;
  white-space: nowrap;
}

.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-2);
  vertical-align: top;
}

.tbl tbody tr:hover td {
  background: var(--paper-2);
}

.tbl tbody td:first-child {
  color: var(--ink);
  font-weight: 600;
}

.tbl--kv {
  border-top: 0;
}

.tbl--kv tbody td:first-child {
  width: 128px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.tbl--kv td {
  padding: 11px 12px;
}

/* Callout */
.callout {
  margin: 30px 0 34px;
  padding: 20px 24px;
  background: var(--paper-2);
  border-left: 2px solid var(--red);
}

.callout__title {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.callout__title::before {
  content: "NOTE / ";
  color: var(--red);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
  letter-spacing: 0.14em;
}

.callout__body p {
  margin-bottom: 10px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.84;
}

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

/* Figures */
.fig {
  margin: 34px 0 36px;
}

.fig__open {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
}

.fig__open img {
  width: 100%;
  height: auto;
}

.fig__hint {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 6px 9px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.fig__open:hover .fig__hint {
  opacity: 1;
}

.fig--portrait .fig__open {
  display: flex;
  justify-content: center;
  padding: 18px;
  background: var(--paper-2);
}

.fig--portrait img {
  width: auto;
  max-width: 100%;
  max-height: 720px;
}

.fig figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.fig__no {
  margin-right: 10px;
  color: var(--red);
  letter-spacing: 0.08em;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(11, 11, 12, 0.94);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox__img {
  max-width: 94vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.lightbox__cap {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 20px;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: 0.03em;
  text-align: center;
}

.lightbox__close {
  position: absolute;
  top: 18px;
  right: 22px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: transparent;
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.lightbox__close:hover {
  border-color: #fff;
}

body.lightbox-open {
  overflow: hidden;
}

/* Document archive */
.archive {
  margin: 0 0 46px;
  border: 1px solid var(--ink);
}

.archive__label {
  margin: 0;
  padding: 9px 16px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.archive__row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 18px;
  padding: 11px 16px;
  border-top: 1px solid var(--line-2);
}

.archive__row:first-child {
  border-top: 0;
}

.archive__row dt {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.9;
}

.archive__row dd {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.75;
}

/* End + prev/next */
.doc-end {
  margin: 70px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-align: center;
}

.pn {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 64px;
  background: var(--line);
  border: 1px solid var(--line);
}

.pn__card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 22px;
  background: var(--paper);
  text-decoration: none;
  transition: background 0.15s ease;
}

.pn__card:hover {
  background: var(--paper-2);
}

.pn__card--next {
  text-align: right;
  align-items: flex-end;
}

.pn__card:only-child {
  grid-column: 1 / -1;
}

.pn__label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.pn__card b {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}

.pn__card i {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.06em;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .doc-hero__grid {
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 48px;
  }

  .doc-body {
    grid-template-columns: 246px minmax(0, 1fr);
    gap: 48px;
  }

  .prose {
    max-width: none;
  }
}

@media (max-width: 980px) {
  .doc-hero {
    padding: 40px 0 44px;
  }

  .doc-hero__grid {
    grid-template-columns: 1fr;
    gap: 32px;
    align-items: start;
  }

  .doc-hero__side {
    padding-top: 16px;
  }

  .doc-facts {
    grid-template-columns: repeat(3, 1fr);
  }

  .toc-toggle {
    display: inline-flex;
  }

  .doc-body {
    grid-template-columns: 1fr;
    padding-top: 40px;
  }

  .doc-aside {
    position: fixed;
    top: var(--head-h);
    left: 0;
    bottom: 0;
    z-index: 70;
    width: min(86vw, 340px);
    max-height: none;
    padding: 0 22px 28px;
    background: var(--paper);
    border-top: 0;
    border-right: 1px solid var(--ink);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }

  .doc-aside.is-open {
    transform: translateX(0);
  }

  .doc-aside__top {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 14px 0 12px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }

  .toc-close {
    display: inline-block;
  }

  .doc-end {
    text-align: left;
  }
}

@media (max-width: 700px) {
  .crumbs {
    margin-bottom: 26px;
  }

  .doc-hero__title {
    font-size: 36px;
  }

  .doc-hero__deck {
    font-size: 16px;
  }

  .doc-facts {
    grid-template-columns: 1fr 1fr;
  }

  .doc-body {
    padding-bottom: 64px;
  }

  .prose p {
    font-size: 16px;
    line-height: 1.9;
  }

  .prose .is-lead {
    font-size: 17.5px;
  }

  .prose h2 {
    margin-top: 52px;
    font-size: 25px;
  }

  .prose h3 {
    font-size: 18px;
  }

  .archive__row {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 10px 14px;
  }

  .archive__row dt {
    line-height: 1.6;
  }

  .pn {
    grid-template-columns: 1fr;
  }

  .pn__card--next {
    text-align: left;
    align-items: flex-start;
  }

  .fig--portrait img {
    max-height: 560px;
  }
}

@media (max-width: 600px) {
  .doc-hero {
    padding: 30px 0 34px;
  }

  .doc-hero__title {
    font-size: 32px;
  }

  .doc-chips li {
    font-size: 10px;
  }

  .doc-hero__side .link-arrow {
    display: flex;
  }

  .tbl {
    font-size: 13.5px;
  }

  .tbl td {
    padding: 10px 12px;
  }

  .callout {
    padding: 16px 18px;
  }

  .fig__hint {
    opacity: 1;
  }
}

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

  .doc-aside,
  .fig__hint,
  .toc-scrim {
    transition: none;
  }
}
