/* gitbook.tw shared styles for the `home` and `chapter` layouts (tokens, base, header, footer)
   plus the home page sections. Hand-written; tokens from the design canvas. */

:root {
  --paper: #FAF8F2;
  --surface: #FFFFFF;
  --ink: #17130F;
  --ink2: #3D3730;
  --muted: #6F685E;
  --line: #E5DFD2;
  --sage: #DFE5DA;
  --sage2: #EEF2EA;
  --green: #31875A;
  --orange: #F49D13;
  --orange2: #D98708;
  --dark: #1B1713;
  --footer-text: #B9B1A5;
  --footer-dim: #8E877C;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", Georgia, serif;
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --pad-x: 96px;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--orange2); }
:focus-visible { outline: 2px solid var(--orange2); outline-offset: 2px; }
ul { margin: 0; padding: 0; list-style: none; }
p, h1, h2, h3 { margin: 0; }
img { max-width: 100%; height: auto; display: block; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.icon { flex-shrink: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.home-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.home-num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.home-mark { display: inline-flex; align-items: center; }
.home-mark--video { color: var(--green); }
.home-mark--paid { color: var(--muted); }

/* ---------- header ---------- */

.home-header {
  height: 72px;
  padding: 0 var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.home-brand { display: flex; align-items: baseline; gap: 12px; }
.home-brand:hover { color: var(--ink); }
.home-brand__name { font-family: var(--font-serif); font-size: 20px; font-weight: 700; }
.home-brand__domain { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.home-nav__toggle {
  width: 44px; height: 44px; margin-right: -12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink);
}
.home-nav__menu ul { display: flex; gap: 28px; font-size: 15px; font-weight: 500; }
.home-nav__menu a { display: inline-flex; align-items: center; height: 72px; color: var(--ink2); }
.home-nav__menu a.is-active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--orange); }
/* Desktop: the list is always visible and the toggle disappears. Browsers without
   ::details-content keep the toggle, so the menu still opens there. */
@supports selector(::details-content) {
  .home-nav::details-content { content-visibility: visible; }
  .home-nav__toggle { display: none; }
}

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

.home-hero {
  padding: 80px var(--pad-x) 88px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 32px;
  align-items: center;
}
.home-hero__copy { grid-column: span 7; display: flex; flex-direction: column; gap: 28px; }
.home-eyebrow {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.08em; color: var(--green);
  display: flex; align-items: center; gap: 10px;
}
.home-eyebrow::before { content: ""; width: 24px; height: 1px; background: var(--green); flex-shrink: 0; }
.home-hero__title { font-family: var(--font-serif); font-size: 68px; line-height: 80px; font-weight: 900; letter-spacing: -0.01em; }
.home-hero__subtitle { font-size: 20px; line-height: 34px; color: var(--ink2); max-width: 620px; text-wrap: pretty; }
.home-highlights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 24px; max-width: 640px; }
.home-highlights li { display: flex; align-items: flex-start; gap: 10px; font-size: 16px; line-height: 26px; color: var(--ink2); }
.home-highlights .icon { color: var(--green); margin-top: 4px; }
.home-actions { display: flex; align-items: center; gap: 20px; padding-top: 8px; }
.home-button {
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 28px;
  background: var(--orange); color: var(--ink);
  border-radius: 2px; font-size: 17px; font-weight: 700;
}
.home-button:hover { color: var(--ink); background: var(--orange2); }
.home-toc-link { display: inline-flex; align-items: center; gap: 8px; height: 56px; font-size: 16px; font-weight: 500; color: var(--ink2); }
.home-purchase { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.home-purchase__list { display: flex; flex-wrap: wrap; gap: 10px; }
.home-purchase__list 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;
}
.home-purchase__list a:hover { border-color: var(--orange2); }
.home-hero__cover { grid-column: span 5; display: flex; justify-content: center; padding: 24px 0; }
.home-hero__cover img { width: 380px; filter: drop-shadow(0 24px 32px rgba(23, 19, 15, 0.22)); }

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

.home-classroom {
  background: var(--sage2);
  padding: 64px var(--pad-x);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.home-classroom__intro { grid-column: span 4; display: flex; flex-direction: column; gap: 16px; }
.home-classroom__intro h2 { font-family: var(--font-serif); font-size: 30px; line-height: 40px; font-weight: 700; }
.home-classroom__intro p { font-size: 16px; line-height: 28px; color: var(--ink2); text-wrap: pretty; }
.home-classroom__intro a { font-weight: 700; box-shadow: inset 0 -1px 0 var(--orange); }
.home-videos { grid-column: span 8; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.home-video {
  display: flex; flex-direction: column; gap: 12px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 12px; color: var(--ink);
}
.home-video:hover { color: var(--ink); border-color: var(--orange2); }
.home-video__thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--dark); border-radius: 2px; overflow: hidden; }
.home-video__thumb img { width: 100%; height: 100%; object-fit: cover; }
.home-video__meta { display: flex; flex-direction: column; gap: 4px; }
.home-video__meta .home-label { font-size: 11px; display: inline-flex; align-items: center; gap: 6px; }
.home-video__meta .home-label .icon { color: var(--orange2); }
.home-video__title { font-size: 15px; line-height: 22px; font-weight: 500; }

/* ---------- table of contents ---------- */

.home-toc {
  padding: 80px var(--pad-x) 96px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 32px;
  align-items: start;
}
.home-toc__aside { grid-column: span 3; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 32px; }
.home-toc__heading { display: flex; flex-direction: column; gap: 8px; }
.home-toc__heading h2 { font-family: var(--font-serif); font-size: 40px; line-height: 48px; font-weight: 700; }
.home-toc__count { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.home-toc__index { border-top: 1px solid var(--line); }
.home-toc__index a { display: flex; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink2); }
.home-toc__index .home-num { color: var(--orange2); width: 20px; flex-shrink: 0; }
.home-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted); }
.home-legend li { display: flex; align-items: center; gap: 6px; }
.home-toc__parts { grid-column: span 9; display: flex; flex-direction: column; gap: 20px; }
.toc-part { padding-top: 28px; }
.toc-part__summary { pointer-events: none; }
.toc-part__title {
  display: flex; align-items: baseline; gap: 14px;
  padding-bottom: 10px; border-bottom: 2px solid var(--ink);
  font-family: var(--font-serif); font-size: 22px; line-height: 30px; font-weight: 700;
}
.toc-part__title .home-num { color: var(--orange2); font-size: 13px; font-weight: 500; }
.toc-part__count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.toc-part__chevron { display: none; }
.toc-part__chapters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; padding-top: 8px; }
.toc-chapter { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.toc-chapter__num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); line-height: 24px; width: 20px; flex-shrink: 0; }
.toc-chapter a { flex-grow: 1; font-size: 16px; line-height: 24px; }
.toc-chapter code { font-family: var(--font-mono); font-size: 0.9em; }
.toc-chapter__marks { display: flex; gap: 6px; align-items: center; height: 24px; }
.toc-chapter.is-paid a { color: var(--muted); }
.toc-chapter.is-paid a:hover { color: var(--orange2); }

/* ---------- footer ---------- */

.home-footer {
  background: var(--dark); color: var(--paper);
  padding: 56px var(--pad-x);
  display: flex; gap: 80px; align-items: flex-start;
}
.home-footer__brand { display: flex; flex-direction: column; gap: 10px; flex-grow: 1; }
.home-footer__name { font-family: var(--font-serif); font-size: 22px; font-weight: 700; }
.home-footer__brand p { font-size: 14px; line-height: 22px; color: var(--footer-text); max-width: 420px; }
.home-footer__links { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.home-footer a { color: var(--paper); }
.home-footer a:hover { color: var(--orange); }
.home-footer__copyright { font-size: 12px; line-height: 20px; color: var(--footer-dim); max-width: 260px; align-self: flex-end; }

/* ---------- tablet: 768–1199, desktop structure with tighter padding ---------- */

@media (min-width: 768px) and (max-width: 1199px) {
  :root { --pad-x: 48px; }
  .home-brand__domain { display: none; }
  .home-nav__menu ul { gap: 16px; font-size: 14px; }
  .home-hero__cover img { width: 100%; max-width: 380px; }
  .home-videos { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .home-video { flex-direction: row; align-items: flex-start; height: auto; }
  .home-video__thumb { width: 160px; flex-shrink: 0; }
  .toc-part__chapters { grid-template-columns: repeat(1, minmax(0, 1fr)); }
}

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

@media (max-width: 767px) {
  :root { --pad-x: 20px; }

  /* header: the menu lives behind the disclosure toggle */
  .home-header { height: 60px; }
  .home-brand__name { font-size: 18px; }
  .home-brand__domain { display: none; }
  .home-nav { position: relative; }
  .home-nav__toggle { display: flex; }
  .home-nav:not([open])::details-content { content-visibility: hidden; }
  .home-nav__menu {
    position: absolute; top: 52px; right: -12px; z-index: 10;
    width: calc(100vw - 40px);
    background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
    box-shadow: 0 12px 32px rgba(23, 19, 15, 0.12); padding: 8px 0;
  }
  .home-nav__menu ul { flex-direction: column; gap: 0; }
  .home-nav__menu a { height: 48px; width: 100%; padding: 0 20px; }
  .home-nav__menu a.is-active { box-shadow: inset 3px 0 0 var(--orange); }

  /* hero: cover first, then copy; highlights and purchase after the actions */
  .home-hero { display: flex; flex-direction: column-reverse; gap: 24px; padding: 32px var(--pad-x) 40px; }
  .home-hero__copy { gap: 24px; }
  .home-hero__cover { padding: 28px 0 12px; }
  .home-hero__cover img { width: 200px; filter: drop-shadow(0 16px 24px rgba(23, 19, 15, 0.22)); }
  .home-eyebrow { font-size: 12px; }
  .home-hero__title { font-size: 42px; line-height: 52px; }
  .home-hero__subtitle { font-size: 17px; line-height: 28px; }
  .home-actions { flex-direction: column; align-items: stretch; gap: 0; padding-top: 0; }
  .home-button { justify-content: center; }
  .home-toc-link { justify-content: center; height: 44px; }
  .home-highlights { grid-template-columns: repeat(1, minmax(0, 1fr)); order: 1; padding-top: 8px; border-top: 1px solid var(--line); }
  .home-purchase { order: 2; }
  .home-purchase__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-purchase__list a { justify-content: center; height: 44px; }

  /* classroom videos: stacked, cards in a row with a fixed thumbnail */
  .home-classroom { display: flex; flex-direction: column; gap: 20px; padding: 40px var(--pad-x); }
  .home-classroom__intro h2 { font-size: 26px; line-height: 34px; }
  .home-classroom__intro p { font-size: 15px; line-height: 26px; }
  .home-videos { display: flex; flex-direction: column; gap: 12px; }
  .home-video { flex-direction: row; align-items: flex-start; height: auto; }
  .home-video__thumb { width: 128px; flex-shrink: 0; }

  /* table of contents: collapsible parts, no side index */
  .home-toc { display: flex; flex-direction: column; gap: 20px; padding: 48px var(--pad-x) 56px; }
  .home-toc__aside { position: static; gap: 16px; }
  .home-toc__heading h2 { font-size: 32px; line-height: 40px; }
  .home-toc__index { display: none; }
  .home-toc__parts { gap: 0; border-top: 2px solid var(--ink); }
  .toc-part { padding-top: 0; border-bottom: 1px solid var(--line); }
  .toc-part__summary { pointer-events: auto; cursor: pointer; }
  .toc-part__title {
    min-height: 60px; padding: 12px 0; border-bottom: 0;
    align-items: center; gap: 12px; font-size: 18px; line-height: 26px;
  }
  .toc-part__title .home-num { width: 22px; }
  .toc-part__name { flex-grow: 1; }
  .toc-part__count { margin-left: 0; }
  .toc-part__chevron { display: flex; color: var(--muted); transition: transform 0.2s ease; }
  .toc-part[open] .toc-part__chevron { transform: rotate(180deg); }
  .toc-part__chapters { display: flex; flex-direction: column; padding: 0 0 12px 34px; }
  .toc-chapter { padding: 11px 0; }
  .toc-chapter a { font-size: 15px; line-height: 22px; }
  .toc-chapter__num, .toc-chapter__marks { line-height: 22px; height: 22px; }

  /* footer: stacked */
  .home-footer { flex-direction: column; gap: 28px; padding: 40px 24px; }
  .home-footer__links { flex-direction: row; flex-wrap: wrap; gap: 0 18px; }
  .home-footer__links a { display: inline-flex; align-items: center; min-height: 44px; }
  .home-footer__copyright { align-self: flex-start; max-width: none; }
}
