/* ========================================================= */
/* Commands — the Delta rulebook (Read surface)              */
/* ========================================================= */

.book {
  max-width: 1120px;
  margin: 0 auto;
  padding: 7.5rem clamp(1.1rem, 4vw, 2.5rem) 5rem;
}

.book-hero { display: grid; gap: 1.1rem; margin-bottom: 2.2rem; }
.book-hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 6.4vw, 5.2rem);
  line-height: 1;
  color: var(--stock);
}
.book-lede { font-size: clamp(1rem, 1.4vw, 1.15rem); line-height: 1.65; color: var(--on-surface-variant); max-width: 40rem; }
.book-lede strong { color: var(--stock); font-family: var(--font-num); }
.book-registry { min-height: 1.5em; font-size: 0.92rem; color: var(--on-surface-variant); }
.book-registry .font-num { color: var(--stock); font-weight: 700; }

/* Sticky search + divider tabs */
.book-bar {
  position: sticky;
  top: 62px;
  z-index: 20;
  display: grid;
  gap: 0.8rem;
  margin: 0 calc(clamp(1.1rem, 4vw, 2.5rem) * -1) 2rem;
  padding: 0.9rem clamp(1.1rem, 4vw, 2.5rem) 0.8rem;
  background: color-mix(in oklab, var(--ink-850) 90%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--outline-variant);
}
.book-search {
  position: relative;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0 0.9rem;
  border-radius: 14px;
  background: var(--ink-900);
  box-shadow: inset 0 0 0 1px var(--outline-variant);
  transition: box-shadow var(--dur-ui) var(--ease-out);
}
.book-search:focus-within { box-shadow: inset 0 0 0 1px var(--holo-cyan), 0 0 0 4px color-mix(in oklab, var(--holo-cyan) 16%, transparent); }
.book-search .icon { color: var(--on-surface-variant); width: 1.25rem; height: 1.25rem; }
.book-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--stock);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.95rem 0;
}
.book-search input::placeholder { color: var(--outline); font-weight: 500; }
.book-search input::-webkit-search-cancel-button { filter: invert(0.7); }
.book-shortcut { font-size: 0.8rem; opacity: 0.8; }
@media (hover: none) { .book-shortcut { display: none; } }

.book-tabs {
  display: flex; gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 calc(clamp(1.1rem, 4vw, 2.5rem) * -1);
  padding: 0 clamp(1.1rem, 4vw, 2.5rem);
}
.book-tabs::-webkit-scrollbar { display: none; }
.book-tab {
  flex-shrink: 0;
  border: 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.86rem;
  padding: 0.5rem 0.9rem;
  border-radius: 10px 10px 4px 4px;
  color: var(--on-surface-variant);
  background: var(--ink-750);
  box-shadow: inset 0 -2px 0 var(--ink-900);
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) var(--ease-out), color var(--dur-ui) var(--ease-out);
}
.book-tab[aria-selected="true"] { background: var(--stock); color: var(--ink-900); box-shadow: none; }
.book-tab:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .book-tab:hover:not([aria-selected="true"]) { color: var(--stock); background: var(--ink-700); }
}

.book-empty {
  padding: 3rem 0;
  font-size: 1.05rem;
  color: var(--on-surface-variant);
}
.book-empty strong { color: var(--stock); font-family: var(--font-num); }

/* Sections */
.book-sections { display: grid; gap: clamp(3rem, 7vh, 4.5rem); }
.book-section { scroll-margin-top: 190px; }
.book-section[hidden] { display: none; }
.book-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1.2rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--outline-variant);
}
.book-head h2 {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.1;
  color: var(--stock);
}
.book-head h2::before {
  content: '';
  width: 0.7em; height: 0.62em;
  background: var(--tone);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  flex-shrink: 0;
}
.book-meta { font-size: 0.82rem; color: var(--on-surface-variant); }

/* Rules */
.rules { list-style: none; }
.rule {
  display: grid;
  grid-template-columns: minmax(13rem, 17rem) minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.4rem 1.4rem;
  padding: 0.75rem 0.75rem;
  margin: 0 -0.75rem;
  border-radius: 12px;
  border-bottom: 1px solid color-mix(in oklab, var(--outline-variant) 60%, transparent);
  transition: background-color var(--dur-ui) var(--ease-out);
}
.rule:last-child { border-bottom: 0; }
.rule[hidden] { display: none; }
.rule.is-active { background: var(--ink-750); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tone) 55%, transparent); }
@media (hover: hover) and (pointer: fine) {
  .rule:hover { background: var(--ink-800); }
}
.rule-cmd {
  justify-self: start;
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 0.5rem;
  border: 0;
  background: none;
  cursor: copy;
  text-align: left;
  padding: 0;
  border-radius: 8px;
}
.rule-cmd kbd {
  font-size: 0.95rem;
  color: var(--stock);
  box-shadow: inset 0 -2px 0 var(--ink-900), 0 0 0 1px color-mix(in oklab, var(--tone) 45%, var(--ink-600));
  transition: transform var(--dur-press) var(--ease-out), background-color var(--dur-ui) var(--ease-out);
}
.rule-cmd:active kbd { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) {
  .rule-cmd:hover kbd { background: color-mix(in oklab, var(--tone) 22%, var(--ink-700)); }
}
.rule-cmd mark { background: color-mix(in oklab, var(--vermilion) 45%, transparent); color: inherit; border-radius: 3px; }
.rule-args { font-family: var(--font-num); font-size: 0.78rem; color: var(--on-surface-variant); }
.rule-desc { font-size: 0.93rem; line-height: 1.6; color: var(--on-surface-variant); max-width: 62ch; }
.rule-desc code, .rule-desc b, .rule-desc strong { color: var(--stock); }
.rule-badges { display: inline-flex; gap: 0.3rem; }
.rule-badge {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--ink-750);
  color: var(--on-surface);
  box-shadow: inset 0 0 0 1px var(--outline-variant);
}
.rule-badge.badge-admin    { color: #ff9aa6; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--error) 45%, transparent); }
.rule-badge.badge-cooldown { color: var(--gold-hot); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--gold) 45%, transparent); }
.rule-badge.badge-mention  { color: var(--holo-cyan); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--holo-cyan) 40%, transparent); }

/* Copy feedback */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.4rem + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 16px);
  opacity: 0;
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  background: var(--stock);
  color: var(--ink-900);
  font-weight: 800;
  box-shadow: var(--shadow-3);
  pointer-events: none;
  transition: transform 260ms var(--ease-out), opacity 200ms var(--ease-out);
}
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.toast kbd { background: var(--ink-900); }

@media (max-width: 760px) {
  .book { padding-top: 6.5rem; }
  .rule { grid-template-columns: 1fr auto; }
  .rule-desc { grid-column: 1 / -1; }
  .rule-badges { grid-row: 1; grid-column: 2; }
  .book-bar { top: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition-duration: 1ms; }
}
