/* gitbook.tw chapter pages — layout `chapter`. Loaded after home.css; tokens come from there.
   Body typography is selected under .page__content so the markdown output needs no classes. */

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

.chapter-main {
  padding: 56px var(--pad-x) 96px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 32px;
  align-items: start;
}
.chapter-column { grid-column: 4 / span 8; width: 100%; display: flex; flex-direction: column; }

/* ---------- part navigation: sidebar on desktop, collapsed bar below 1200 ---------- */

.chapter-parts {
  grid-column: span 3;
  position: sticky; top: 32px;
  max-height: calc(100vh - 64px); overflow-y: auto;
}
.chapter-parts__summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; cursor: pointer;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.chapter-parts__position { font-family: var(--font-mono); font-size: 12px; color: var(--orange2); margin-right: -2px; }
.chapter-parts__label { font-size: 15px; font-weight: 500; flex-grow: 1; }
.chapter-parts__chevron { display: flex; color: var(--muted); transition: transform 0.2s ease; }
.chapter-parts[open] .chapter-parts__chevron { transform: rotate(180deg); }
/* Desktop: the list is always visible and the summary disappears. Browsers without
   ::details-content keep the summary, so the list still opens there. */
@supports selector(::details-content) {
  .chapter-parts::details-content { content-visibility: visible; }
  .chapter-parts__summary { display: none; }
}
.chapter-parts__body { display: flex; flex-direction: column; }
.chapter-parts__title {
  font-family: var(--font-serif); font-size: 22px; line-height: 30px; font-weight: 700;
  margin-top: 6px; padding-bottom: 10px; border-bottom: 2px solid var(--ink);
}
.chapter-parts__list { margin-top: 20px; }
.chapter-parts__item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 9px 0 9px 10px; border-bottom: 1px solid var(--line);
}
.chapter-parts__num { font-family: var(--font-mono); font-size: 12px; line-height: 22px; color: var(--muted); width: 20px; flex-shrink: 0; }
.chapter-parts__item a { flex-grow: 1; font-size: 14px; line-height: 22px; color: var(--ink2); }
.chapter-parts__item a code { font-family: var(--font-mono); font-size: 0.9em; }
.chapter-parts__item .home-mark { height: 22px; }
.chapter-parts__item.is-paid a { color: var(--muted); }
.chapter-parts__item.is-current { box-shadow: inset 2px 0 0 var(--orange); }
.chapter-parts__item.is-current .chapter-parts__num { color: var(--orange2); }
.chapter-parts__item.is-current a { color: var(--ink); font-weight: 700; }
.chapter-parts__item a:hover { color: var(--orange2); }
.chapter-parts__all {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  margin-top: 20px; padding-left: 10px;
  font-size: 14px; font-weight: 500; color: var(--ink2);
}

/* ---------- eyebrow and title ---------- */

.chapter-eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  margin-bottom: 18px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.08em; color: var(--green);
}
.chapter-eyebrow__part { display: inline-flex; align-items: center; gap: 10px; }
.chapter-eyebrow__part::before { content: ""; width: 24px; height: 1px; background: var(--green); flex-shrink: 0; }
.chapter-eyebrow__mark { display: inline-flex; align-items: center; gap: 6px; }
.page__content > h1 {
  font-family: var(--font-serif); font-size: 44px; line-height: 58px; font-weight: 900; letter-spacing: -0.01em;
  padding-bottom: 40px; margin-bottom: 48px; border-bottom: 1px solid var(--line);
  text-wrap: pretty;
}

/* ---------- chapter text ---------- */

.page__content p { font-size: 17px; line-height: 32px; color: var(--ink2); margin: 0 0 24px; text-wrap: pretty; }
.page__content h2 { font-family: var(--font-serif); font-size: 28px; line-height: 40px; font-weight: 700; color: var(--ink); margin: 48px 0 20px; }
.page__content h3 { font-family: var(--font-serif); font-size: 22px; line-height: 32px; font-weight: 700; color: var(--ink); margin: 36px 0 16px; }
.page__content h4 { font-family: var(--font-serif); font-size: 18px; line-height: 28px; font-weight: 700; color: var(--ink); margin: 28px 0 12px; }
.page__content code { font-family: var(--font-mono); font-size: 0.92em; background: var(--sage2); color: var(--ink); padding: 1px 6px; border-radius: 2px; }
.page__content pre {
  background: var(--dark); color: var(--paper);
  font-family: var(--font-mono); font-size: 14px; line-height: 24px;
  padding: 20px 24px; border-radius: 4px; margin: 4px 0 28px; overflow-x: auto;
}
.page__content pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.page__content blockquote { background: var(--sage2); padding: 16px 24px 20px; margin: 4px 0 28px; border-radius: 2px; }
.page__content blockquote::before {
  content: "補充"; display: block; margin-bottom: 6px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--green);
}
.page__content blockquote p { font-size: 16px; line-height: 28px; margin: 0; }
.page__content blockquote p + p { margin-top: 12px; }
.page__content ol, .page__content ul { margin: 0 0 24px; padding-left: 28px; }
.page__content ol { list-style: decimal; }
.page__content ul { list-style: disc; }
.page__content li { font-size: 17px; line-height: 32px; color: var(--ink2); padding-left: 4px; }
.page__content li::marker { font-family: var(--font-mono); font-size: 14px; color: var(--orange2); }
.page__content li p { margin: 0; }
.page__content img { max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: 2px; }
.page__content p:has(> img) { text-align: center; margin: 4px 0 28px; }
.page__content a { box-shadow: inset 0 -1px 0 var(--orange); }
.page__content a:hover { color: var(--orange2); }
.page__content strong { font-weight: 700; color: var(--ink); }
.page__content table { width: 100%; border-collapse: collapse; margin: 4px 0 28px; font-size: 15px; line-height: 24px; }
.page__content th {
  text-align: left; padding: 8px 12px 10px; border-bottom: 2px solid var(--ink);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; font-weight: 500; color: var(--muted);
}
.page__content td { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--ink2); vertical-align: top; }
.page__content td code { font-size: 0.9em; }
.page__content iframe { display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: 4px; margin: 4px 0 28px; }
.page__content hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

/* ---------- previous / next ---------- */

.chapter-pager {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px;
  margin-top: 40px; padding-top: 24px; border-top: 2px solid var(--ink);
}
.chapter-pager a { display: flex; flex-direction: column; gap: 8px; min-height: 44px; color: var(--ink); }
.chapter-pager a:hover { color: var(--orange2); }
.chapter-pager__next { grid-column: 2; align-items: flex-end; text-align: right; }
.chapter-pager__label { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.chapter-pager__title { font-family: var(--font-serif); font-size: 18px; line-height: 28px; font-weight: 700; }

/* ---------- paid chapter notice ---------- */

.paid-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 40px 44px 44px; display: flex; flex-direction: column; gap: 20px;
}
.paid-card__badge { width: 48px; height: 48px; border-radius: 50%; background: var(--sage2); color: var(--green); display: flex; align-items: center; justify-content: center; }
.page__content .paid-card__title { font-size: 26px; line-height: 36px; margin: 0; }
.page__content .paid-card p { font-size: 16px; line-height: 28px; max-width: 560px; margin: 0; }
.paid-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 8px; }
.page__content .paid-card__actions a { box-shadow: none; }
.paid-card__primary {
  display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 24px;
  background: var(--orange); color: var(--ink); border-radius: 2px; font-size: 16px; font-weight: 700;
}
.page__content .paid-card__primary:hover { color: var(--ink); background: var(--orange2); }
.paid-card__secondary {
  display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 20px;
  border: 1px solid var(--ink); border-radius: 2px; font-size: 15px; font-weight: 500;
}
.paid-card__secondary:hover { border-color: var(--orange2); }

/* ---------- below 1200: no sidebar, the part list is a collapsed bar ---------- */

@media (max-width: 1199px) {
  .chapter-main { display: flex; flex-direction: column; padding-top: 0; }
  .chapter-parts { position: static; max-height: none; overflow: visible; width: 100%; }
  .chapter-parts__summary { display: flex; }
  @supports selector(::details-content) {
    .chapter-parts:not([open])::details-content { content-visibility: hidden; }
  }
  .chapter-parts__body { padding: 16px 0 12px; }
  .chapter-parts__item { padding: 11px 0 11px 10px; }
  .chapter-parts__item a { font-size: 15px; line-height: 22px; }
  .chapter-parts__all { min-height: 44px; }
  .chapter-column { width: 100%; max-width: 760px; margin: 0 auto; padding-top: 32px; }
}

/* ---------- phone ---------- */

@media (max-width: 767px) {
  .chapter-eyebrow { font-size: 12px; margin-bottom: 14px; }
  .chapter-eyebrow__part::before { width: 20px; }
  .page__content > h1 { font-size: 30px; line-height: 42px; padding-bottom: 0; margin-bottom: 28px; border-bottom: 0; }
  .page__content p { font-size: 16px; line-height: 30px; margin-bottom: 20px; }
  .page__content h2 { font-size: 24px; line-height: 34px; margin: 40px 0 16px; }
  .page__content h3 { font-size: 20px; line-height: 30px; margin: 32px 0 12px; }
  .page__content pre { font-size: 13px; line-height: 22px; padding: 16px 20px; margin: 4px calc(-1 * var(--pad-x)) 24px; border-radius: 0; }
  .page__content blockquote { padding: 14px 20px 16px; margin-bottom: 24px; }
  .page__content blockquote p { font-size: 15px; line-height: 26px; }
  .page__content ol, .page__content ul { padding-left: 24px; margin-bottom: 20px; }
  .page__content li { font-size: 16px; line-height: 30px; }
  .page__content li::marker { font-size: 13px; }
  .page__content img { width: 100%; }
  .page__content p:has(> img) { margin-bottom: 24px; }
  .page__content table { font-size: 14px; line-height: 22px; }
  .chapter-pager { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; padding-top: 20px; }
  .chapter-pager a { gap: 4px; padding: 8px 0; }
  .chapter-pager__next { align-items: flex-start; text-align: left; border-top: 1px solid var(--line); }
  .chapter-pager__title { font-size: 17px; line-height: 26px; }
  .paid-card { padding: 28px 24px; gap: 16px; }
  .paid-card__badge { width: 44px; height: 44px; }
  .paid-card__badge .icon { width: 22px; height: 22px; }
  .page__content .paid-card__title { font-size: 22px; line-height: 32px; }
  .page__content .paid-card p { font-size: 15px; line-height: 26px; }
  .paid-card__actions { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 4px; }
  .paid-card__primary { justify-content: center; }
  .paid-card__secondary { justify-content: center; height: 48px; }
}
