/* kanso book — chapter chrome shared across docs/book/ pages */

.book-layout {
  display: grid;
  gap: 4rem;
  grid-template-columns: 12rem minmax(0, 1fr);
  margin: 0 auto;
  max-width: 72rem;
  padding: 0 1.5rem;
}

.book-layout .essay {
  margin: 0;
  padding-left: 0;
  padding-right: 0;
}

.book-side {
  align-self: start;
  margin-top: 4.3rem;
  position: sticky;
  top: 2rem;
}

.book-side-home {
  color: var(--accent);
  display: block;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.42em;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.book-side-home:hover {
  color: var(--accent-hover);
}

.book-side ol {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
}

.bs-part {
  color: var(--muted);
  display: block;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  margin: 0 0 0.45rem;
  text-transform: uppercase;
}

.book-side li {
  margin: 0;
}

.book-side ol a {
  align-items: baseline;
  border-left: 2px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 0.82rem;
  gap: 0.6rem;
  line-height: 1.4;
  padding: 0.38rem 0 0.38rem 0.9rem;
}

.book-side .bs-num {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.book-side ol a:hover {
  border-left-color: var(--accent);
  color: var(--ink);
}

.book-side ol a[aria-current="page"] {
  border-left-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 60rem) {
  .book-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .book-layout .essay {
    margin: 0 auto;
    padding: 3rem 1.5rem 6rem;
  }

  .book-side {
    align-items: baseline;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 1.4rem;
    margin: 0;
    overflow-x: auto;
    padding: 0.9rem 1.5rem;
    position: static;
  }

  .book-side-home {
    margin-bottom: 0;
    white-space: nowrap;
  }

  .book-side ol {
    display: flex;
    gap: 1.25rem;
    margin: 0;
  }

  .bs-part {
    display: none;
  }

  .book-side .bs-title {
    display: none;
  }

  .book-side ol a {
    border-left: none;
    padding: 0.1rem 0;
  }

  .book-side ol a[aria-current="page"] {
    border-bottom: 2px solid var(--accent);
  }
}

.tip {
  align-items: flex-start;
  display: flex;
  gap: 1.1rem;
  margin: 2.75rem 0;
}

.tip .sprite {
  flex-shrink: 0;
  height: auto;
  margin-top: 0.35rem;
  width: 48px;
}

.tip-bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1.15rem 0.9rem;
  position: relative;
}

.tip-bubble::before {
  border-bottom: 8px solid transparent;
  border-right: 9px solid var(--line);
  border-top: 8px solid transparent;
  content: "";
  left: -9px;
  position: absolute;
  top: 1.1rem;
}

.tip-bubble::after {
  border-bottom: 7px solid transparent;
  border-right: 8px solid var(--surface);
  border-top: 7px solid transparent;
  content: "";
  left: -8px;
  position: absolute;
  top: calc(1.1rem + 1px);
}

.tip-who {
  color: var(--accent);
  display: block;
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.tip-bubble p {
  font-size: 0.94rem;
  margin: 0;
}

.chapter-nav {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 4.5rem;
  padding-top: 1.75rem;
}

.chapter-nav a {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.chapter-nav .nav-spacer {
  flex: 1;
}

.book-toc {
  list-style: none;
  margin: 3rem 0 0;
  padding: 0;
}

.book-toc li {
  margin: 0;
}

.book-toc a {
  align-items: baseline;
  border-top: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  gap: 1.5rem;
  padding: 1.35rem 0.25rem;
}

.book-toc .toc-part {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.36em;
  margin: 2.4rem 0 0.7rem;
  text-transform: uppercase;
}

.book-toc li:first-child .toc-part {
  margin-top: 0;
}

.book-toc a:hover {
  background: var(--accent-soft);
}

.book-toc .ch-num {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  min-width: 3.5rem;
}

.book-toc li:last-child a {
  border-bottom: 1px solid var(--line);
}

.book-toc .ch-title {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.book-toc .ch-blurb {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: auto;
  max-width: 24rem;
  text-align: right;
}

@media (max-width: 40rem) {
  .book-toc .ch-blurb {
    display: none;
  }
}

.book-start {
  font-family: var(--font-display);
  font-weight: 700;
  margin-top: 2.5rem;
}
.book-start a { color: var(--accent); }

.bench-table {
  border-collapse: collapse;
  margin: 2.5rem 0 1rem;
  width: 100%;
}

.bench-table caption {
  caption-side: bottom;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 1rem;
  text-align: left;
}

.bench-table thead th {
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  padding: 0 0.4rem 0.75rem;
  text-align: left;
  text-transform: uppercase;
}

.bench-table thead th:last-child {
  text-align: right;
}

.bench-table tbody td {
  border-bottom: 1px solid var(--line);
  font-size: 1.4rem;
  padding: 0.9rem 0.4rem;
}

.bench-table tbody td:last-child {
  font-family: var(--font-display);
  font-feature-settings: "tnum" 1;
  font-weight: 700;
  text-align: right;
}

.bench-table .bench-us td {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* ---------- a sample you can run ---------- */

/* A book panel becomes an editor the same way the landing page's does: a
   transparent textarea over a highlighted mirror, sharing the panel's own
   type and padding so it reads as the object it replaced. */
.book-edit {
  position: relative;
}

.book-edit textarea,
.book-edit pre {
  bottom: 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  left: 0;
  line-height: 1.7;
  margin: 0;
  overflow: auto;
  padding: 1.1rem 1.25rem;
  position: absolute;
  right: 0;
  top: 0;
  white-space: pre;
}

.book-edit pre {
  pointer-events: none;
}

/* the mirror must share the textarea's exact metrics or the highlight drifts
   from the caret; the UA `code { font-family: monospace }` rule would win */
.book-edit pre code {
  color: var(--code-ink);
  font: inherit;
}

.book-edit textarea {
  background: transparent;
  border: none;
  caret-color: var(--accent);
  color: transparent;
  outline: none;
  resize: none;
}

.book-edit textarea::selection {
  background: rgba(240, 58, 0, 0.25);
}

.book-run {
  background: var(--accent);
  border: none;
  border-radius: 0.2rem;
  color: #fff;
  cursor: pointer;
  float: right;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.6rem;
  text-transform: lowercase;
}

.book-run:disabled {
  opacity: 0.55;
}

/* what the reader's own run answered, marked so it is not mistaken for the
   output the book recorded */
.book-ran .code-output .code-panel-title::after {
  color: var(--accent);
  content: " — your run";
}
