/* gitbook.tw secondary pages — layout `page`. Loaded after home.css and chapter.css;
   body typography comes from chapter.css (.page__content), tokens from home.css. */

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

.page-main { padding: 56px var(--pad-x) 96px; display: flex; flex-direction: column; align-items: center; }
.page-column { width: 100%; display: flex; flex-direction: column; }

/* ---------- head image, page head, back link ---------- */

.page-figure { margin: 0 0 40px; display: flex; flex-direction: column; gap: 8px; }
.page-figure img { width: 100%; border-radius: 4px; }
.page-figure figcaption { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.page-figure figcaption a { color: var(--muted); }
.page-figure figcaption a:hover { color: var(--orange2); }
.page-head { display: flex; flex-direction: column; gap: 18px; padding-bottom: 40px; margin-bottom: 48px; border-bottom: 1px solid var(--line); }
.page-eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.08em; color: var(--green);
}
.page-eyebrow__part { display: inline-flex; align-items: center; gap: 10px; }
.page-eyebrow__part::before { content: ""; width: 24px; height: 1px; background: var(--green); flex-shrink: 0; }
.page-eyebrow__link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.page-title { font-family: var(--font-serif); font-size: 44px; line-height: 58px; font-weight: 900; letter-spacing: -0.01em; text-wrap: pretty; }
.page-lede { font-size: 18px; line-height: 32px; color: var(--ink2); text-wrap: pretty; }
.page-lede a { font-weight: 700; box-shadow: inset 0 -1px 0 var(--orange); }
.page-back { margin-top: 40px; padding-top: 24px; border-top: 2px solid var(--ink); }
.page-back a { display: inline-flex; flex-direction: column; gap: 8px; min-height: 44px; color: var(--ink); }
.page-back a:hover { color: var(--orange2); }
.page-back__label { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.page-back__title { font-family: var(--font-serif); font-size: 18px; line-height: 28px; font-weight: 700; }

/* ---------- errata ---------- */

.page__content.errata h2 {
  font-family: var(--font-mono); font-size: 13px; line-height: 20px; letter-spacing: 0.08em; font-weight: 500; color: var(--orange2);
  margin: 0; padding: 28px 0 12px; border-top: 1px solid var(--line);
}
.page__content.errata h2:first-child { border-top: 2px solid var(--ink); }
.page__content.errata h3 { font-family: var(--font-mono); font-size: 12px; line-height: 20px; letter-spacing: 0.08em; font-weight: 500; color: var(--muted); margin: 12px 0 6px; }
.page__content.errata h3 + p { font-size: 16px; line-height: 28px; margin-bottom: 8px; }
.page__content.errata p { font-size: 14px; line-height: 22px; color: var(--muted); margin-bottom: 16px; }
.page__content.errata pre { margin: 4px 0 16px; padding: 16px 20px; }
.typo_wrong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--orange2); }
.typo_correct { color: var(--green); font-weight: 700; box-shadow: inset 0 -2px 0 var(--sage); }

/* ---------- ebook ---------- */

.ebook { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 32px; align-items: start; padding-top: 16px; }
/* the ebook grid spans the full page column like the home hero */
.ebook__cover { grid-column: 2 / span 3; display: flex; justify-content: center; padding-top: 8px; }
.page__content .ebook__cover img { width: 280px; border: 0; border-radius: 0; margin: 0; filter: drop-shadow(0 24px 32px rgba(23, 19, 15, 0.22)); }
.ebook__copy { grid-column: 6 / span 6; display: flex; flex-direction: column; gap: 24px; }
.page__content .ebook__copy p { margin: 0; }
.page__content .ebook__copy a { box-shadow: none; }
.ebook__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 4px; }
.ebook__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 .ebook__primary:hover { color: var(--ink); background: var(--orange2); }
.ebook__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; }
.ebook__secondary:hover { border-color: var(--orange2); }
.page__content .ebook h2 { font-size: 22px; line-height: 32px; margin: 8px 0 0; }
.page__content .ebook ol { margin: 0; }
.page__content .ebook ol a { box-shadow: inset 0 -1px 0 var(--orange); }

/* ---------- videos ---------- */

.page__content .video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: -8px; }
.page__content .video-card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px;
  color: var(--ink); box-shadow: none;
}
.page__content .video-card:hover { color: var(--ink); border-color: var(--orange2); }
.video-card__thumb { display: block; aspect-ratio: 16 / 9; background: var(--dark); border-radius: 2px; overflow: hidden; }
.page__content .video-card__thumb img { width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; margin: 0; }
.video-card__meta { display: flex; flex-direction: column; gap: 6px; padding: 0 4px 4px; }
.video-card__label { font-size: 11px; display: inline-flex; align-items: center; gap: 6px; }
.video-card__label .icon { color: var(--orange2); }
.video-card__title { font-size: 16px; line-height: 24px; font-weight: 500; }
.video-card__desc { font-size: 14px; line-height: 22px; color: var(--muted); }

/* ---------- interview ---------- */

.page__content.interview { counter-reset: question; }
.page__content.interview h2 { padding-bottom: 12px; border-bottom: 2px solid var(--ink); margin: 48px 0 0; }
.page__content.interview h3 { display: flex; gap: 16px; align-items: baseline; margin: 0; padding: 32px 0 16px; }
.page__content.interview h3::before {
  counter-increment: question; content: "Q" counter(question, decimal-leading-zero);
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--orange2); flex-shrink: 0;
}
.page__content.interview h4 { margin: 8px 0 12px; }
.page__content .interview-answer { display: flex; flex-direction: column; gap: 12px; padding: 20px 24px 24px; margin-bottom: 8px; background: var(--sage2); border-radius: 2px; }
.page__content .interview-answer::before { content: "答"; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--green); }
.page__content .interview-answer p { font-size: 16px; line-height: 28px; margin: 0; }
.page__content .interview-answer code { background: var(--surface); }
.page__content .interview-answer pre code { background: none; }
.page__content .interview-answer pre { margin: 4px 0; }
.page__content .interview-answer ul, .page__content .interview-answer ol { margin: 0; }
.page__content .interview-answer li { font-size: 16px; line-height: 28px; }
.page__content .interview-answer img { margin: 4px 0; }
.page__content .interview-ref { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); margin-right: 8px; }
.page__content .interview-answer p:has(> .interview-ref) { margin-top: 4px; font-size: 14px; }
.page__content .interview-answer p:has(> .interview-ref) a { font-weight: 500; }

/* ---------- articles ---------- */

.page__content .post-list { display: flex; flex-direction: column; margin-top: -20px; }
.page__content .post-row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); column-gap: 28px; align-items: start;
  padding: 28px 0; border-bottom: 1px solid var(--line); color: var(--ink); box-shadow: none;
}
.page__content .post-row:hover { color: var(--orange2); }
.post-row__thumb { display: block; aspect-ratio: 4 / 3; border-radius: 2px; overflow: hidden; border: 1px solid var(--line); }
.page__content .post-row__thumb img { width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; margin: 0; }
.post-row__body { display: flex; flex-direction: column; gap: 8px; }
.post-row__title { font-family: var(--font-serif); font-size: 22px; line-height: 32px; font-weight: 700; }
.post-row__excerpt { font-size: 15px; line-height: 26px; color: var(--ink2); }

/* ---------- about ---------- */

.about-head { display: grid; grid-template-columns: 120px minmax(0, 1fr); column-gap: 32px; align-items: center; padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--line); }
.page__content .about-head img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 0; margin: 0; }
.about-head__copy { display: flex; flex-direction: column; gap: 12px; }
.page__content .about-head h1 { font-family: var(--font-serif); font-size: 40px; line-height: 52px; font-weight: 900; letter-spacing: -0.01em; margin: 0; padding: 0; border: 0; }
.page__content .about-head p { margin: 0; }
.page__content .about-head .page-lede { text-wrap: balance; }
.page__content .about-head__role { font-size: 15px; line-height: 24px; color: var(--muted); }
.page__content .about-head__role a { color: var(--ink); font-weight: 700; }
.page__content .about-social { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 40px; padding: 0; list-style: none; }
.page__content .about-social li { padding: 0; line-height: 1; }
.page__content .about-social a {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border: 1px solid var(--ink); border-radius: 2px; font-size: 14px; font-weight: 500; box-shadow: none;
}
.page__content .about-social a:hover { border-color: var(--orange2); }

/* ---------- tablet: 768–1199 ---------- */

@media (min-width: 768px) and (max-width: 1199px) {
  .page__content .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- phone: below 768 ---------- */

@media (max-width: 767px) {
  .page-main { padding: 32px var(--pad-x) 40px; }
  .page-figure { margin: -8px calc(-1 * var(--pad-x)) 28px; gap: 6px; }
  .page-figure img { border-radius: 0; }
  .page-figure figcaption { padding: 0 var(--pad-x); }
  .page-head { gap: 14px; padding-bottom: 24px; margin-bottom: 28px; }
  .page-eyebrow { font-size: 12px; }
  .page-eyebrow__part::before { width: 20px; }
  .page-title { font-size: 30px; line-height: 42px; }
  .page-lede { font-size: 16px; line-height: 28px; }
  .page-back { margin-top: 32px; padding-top: 20px; }
  .page-back a { padding: 8px 0; gap: 4px; }
  .page-back__title { font-size: 17px; line-height: 26px; }

  .page__content .post-list { margin-top: 0; border-top: 2px solid var(--ink); }
  .page__content .post-row { grid-template-columns: 112px minmax(0, 1fr); column-gap: 16px; padding: 20px 0; min-height: 44px; }
  .post-row__body { gap: 6px; }
  .post-row__title { font-size: 17px; line-height: 26px; }
  .post-row__excerpt { display: none; }

  .page__content .video-grid { display: flex; flex-direction: column; gap: 12px; }
  .page__content .video-card { flex-direction: row; align-items: flex-start; }
  .video-card__thumb { width: 128px; flex-shrink: 0; }
  .video-card__meta { padding: 0; }
  .video-card__desc { display: none; }

  .ebook { display: flex; flex-direction: column; gap: 28px; padding-top: 0; }
  .ebook__cover { padding: 8px 0 0; }
  .page__content .ebook__cover img { width: 200px; filter: drop-shadow(0 16px 24px rgba(23, 19, 15, 0.22)); }
  .ebook__copy { gap: 20px; }
  .page__content .ebook__copy .page-title { font-size: 30px; line-height: 42px; }
  .ebook__actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .ebook__primary { justify-content: center; }
  .ebook__secondary { justify-content: center; height: 48px; }

  .page__content.interview h3 { flex-direction: column; gap: 6px; padding: 28px 0 12px; }
  .page__content .interview-answer { padding: 16px 20px 20px; }

  .about-head { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; padding-bottom: 28px; margin-bottom: 28px; }
  .page__content .about-head img { width: 88px; height: 88px; }
  .page__content .about-head h1 { font-size: 32px; line-height: 42px; }
  .page__content .about-head .page-lede { text-wrap: pretty; }
  .page__content .about-social { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 32px; }
  .page__content .about-social a { width: 100%; justify-content: center; height: 44px; }
}

/* ---------- 404 ---------- */

.page__content .not-found { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 32px; align-items: center; padding-top: 16px; }
.not-found__copy { grid-column: 2 / span 5; display: flex; flex-direction: column; gap: 24px; }
.page__content .not-found__copy p { margin: 0; }
.not-found__art { grid-column: 7 / span 6; display: flex; justify-content: center; }
.page__content .not-found__art img { width: 520px; border: 0; border-radius: 0; margin: 0; }
.not-found__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 4px; }
.page__content .not-found__actions a { box-shadow: none; }
.not-found__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 .not-found__primary:hover { color: var(--ink); background: var(--orange2); }
.not-found__secondary { display: inline-flex; align-items: center; height: 52px; padding: 0 20px; border: 1px solid var(--ink); border-radius: 2px; font-size: 15px; font-weight: 500; }
.not-found__secondary:hover { border-color: var(--orange2); }

/* ---------- playground ---------- */

.page__content.playground { display: flex; flex-direction: column; gap: 32px; }
.page__content.playground a { box-shadow: none; }
.playground-groups { display: flex; flex-direction: column; gap: 10px; }
.playground-groups > .home-label { margin-bottom: 4px; }
.playground-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.playground-group__label { width: 64px; flex-shrink: 0; }
.playground-pill {
  display: inline-flex; align-items: center; height: 40px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 2px;
  font-size: 14px; font-weight: 500; color: var(--ink2);
}
.playground-pill:hover { color: var(--ink); border-color: var(--ink); }
.playground-pill.is-selected { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.playground-pill.is-selected:hover { color: var(--paper); }

.playground-sandbox { display: flex; gap: 20px; align-items: stretch; height: 520px; }
.playground-terminal {
  width: 360px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--dark); color: var(--paper); border-radius: 4px;
  font-family: var(--font-mono); font-size: 13px; line-height: 22px;
}
.playground-terminal__bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--ink2); font-size: 11px; letter-spacing: 0.08em; color: var(--footer-dim); }
.playground-terminal__log { flex-grow: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.playground-terminal__line { display: flex; gap: 8px; align-items: flex-start; white-space: pre-wrap; word-break: break-word; }
.playground-terminal__line--info { color: #8FB89F; padding-left: 16px; }
.playground-terminal__line--error { color: var(--orange); padding-left: 16px; }
.playground-terminal__prompt { color: var(--orange); flex-shrink: 0; }
.playground-terminal__input { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 8px 16px; border-top: 1px solid var(--ink2); cursor: text; }
.playground-terminal__input input {
  flex-grow: 1; min-width: 0; background: none; border: 0; outline: none; padding: 0;
  font: inherit; color: var(--paper); caret-color: var(--orange);
}
.playground-terminal__input input::placeholder { color: var(--footer-dim); }

.playground-graph { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.playground-graph[hidden] { display: none; }
.playground-graph__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.page__content .playground-reset { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.page__content .playground-reset:hover { color: var(--orange2); }
.playground-graph__canvas { flex-grow: 1; overflow: auto; }
.playground-svg { display: block; }

.playground-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.page__content .playground-legend { display: flex; flex-wrap: wrap; gap: 20px; margin: 0; padding: 0; list-style: none; }
.page__content .playground-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 20px; color: var(--muted); padding: 0; }
.playground-legend__commit { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); }
.playground-legend__commit--head { border-color: var(--green); background: var(--sage); }
.playground-legend__commit--merge { border-color: var(--orange); background: var(--surface); }
.playground-legend__commit--unreachable { border-color: var(--line); background: var(--paper); }
.playground-legend__chip { width: 28px; height: 16px; border-radius: 2px; }
.playground-legend__chip--branch { background: var(--orange); }
.playground-legend__chip--head { background: var(--green); }
.playground-legend__chip--remote { background: var(--line); }
.playground-legend__chip--tag { background: var(--sage); }
.page__content .playground-credit { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.page__content .playground-credit:hover { color: var(--orange2); }

/* SVG */
.playground-svg .edge { stroke: var(--ink); stroke-width: 2; }
.playground-svg .edge--merge { stroke: var(--orange); }
.playground-svg .edge--unreachable { stroke: var(--line); }
.playground-svg .edge__head { fill: var(--ink); }
.playground-svg .edge__head--merge { fill: var(--orange); }
.playground-svg .commit { transition: transform 0.2s ease; }
.playground-svg .commit__circle { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.playground-svg .commit--head .commit__circle { fill: var(--sage); stroke: var(--green); }
.playground-svg .commit--merge .commit__circle { fill: var(--surface); stroke: var(--orange); }
.playground-svg .commit--head.commit--merge .commit__circle { fill: var(--sage); stroke: var(--green); }
.playground-svg .commit--unreachable .commit__circle { fill: var(--paper); stroke: var(--line); }
.playground-svg .commit__id { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.playground-svg .commit--unreachable .commit__id { fill: var(--line); }
.playground-svg .chip text { font-family: var(--font-mono); font-size: 11px; font-weight: 500; fill: var(--ink); }
.playground-svg .chip--branch rect { fill: var(--orange); }
.playground-svg .chip--head rect { fill: var(--green); }
.playground-svg .chip--head text { fill: var(--paper); }
.playground-svg .chip--remote rect { fill: var(--line); }
.playground-svg .chip--tag rect { fill: var(--sage); }

/* ---------- tablet ---------- */

@media (min-width: 768px) and (max-width: 1199px) {
  .playground-terminal { width: 300px; }
}

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

@media (max-width: 767px) {
  .page__content .not-found { display: flex; flex-direction: column-reverse; gap: 28px; padding-top: 0; }
  .page__content .not-found__art img { width: 240px; }
  .not-found__actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .not-found__primary { justify-content: center; }
  .not-found__secondary { justify-content: center; height: 48px; }

  .page__content.playground { gap: 24px; }
  .playground-groups { margin: 0 calc(-1 * var(--pad-x)); padding: 0 var(--pad-x); overflow-x: auto; }
  .playground-groups > .home-label { margin-bottom: 0; }
  .playground-group { flex-wrap: nowrap; width: max-content; }
  .playground-group__label { width: auto; padding-right: 4px; }
  .playground-sandbox { flex-direction: column; height: auto; gap: 12px; }
  .playground-terminal { width: 100%; height: 240px; font-size: 12px; line-height: 20px; }
  .playground-graph { flex-grow: 0; }
  .playground-graph__bar { padding: 10px 14px; }
  .playground-graph__canvas { height: 300px; overflow-x: auto; }
  .playground-foot { flex-direction: column; align-items: flex-start; }
}
