/* Shelf redesign — Apple cards: the reader picks a volume, then reads the full guidance. */
:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-soft: #ebebed;
  --ink: #1d1d1f;
  --fg: var(--ink);
  --fg-2: #3a3a3c;
  --muted: #6e6e73;
  --meta: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --accent-alt: #1d1d1f;
  --accent-alt-soft: rgba(29, 29, 31, 0.05);
  --ok: #34c759;
  --warn: #bf4800;
  --danger: #ff3b30;
  --term-bg: #1d1d1f;
  --term-fg: #f5f5f7;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 12px 32px rgba(0, 0, 0, 0.08);
  --focus: 0 0 0 4px rgba(0, 113, 227, 0.32);
}

html { background: var(--bg); }
body {
  background-color: var(--bg);
  color: var(--ink);
}

.topnav {
  background: rgba(245, 245, 247, 0.82);
  border-bottom-color: var(--border);
  backdrop-filter: saturate(180%) blur(20px);
}
.topnav-inner { min-height: 66px; }
.brand { color: var(--fg); font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.brand-mark {
  border-radius: 7px;
  width: 31px;
  height: 31px;
  color: #fff;
  background: var(--ink);
  border: 0;
  font-size: 11px;
  box-shadow: none;
}
.brand small { color: var(--muted); font-weight: 400; }
.nav-links { gap: 2px; }
.nav-links a { color: var(--muted); padding: 8px 12px; border-radius: 980px; }
.nav-links a:hover, .nav-links a.is-active { color: var(--fg); background: rgba(0, 0, 0, 0.05); }

.btn { border-radius: 980px; box-shadow: none; font-weight: 500; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: none; }
.btn-secondary { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--fg); }
.btn-secondary:hover { background: var(--fg); color: #fff; border-color: var(--fg); }
.btn:focus-visible, .shelf-book:focus-visible, .route-tab:focus-visible { outline: none; box-shadow: var(--focus); }

/* Shared reader layout */
.page-hero, .shelf-hero { padding: clamp(48px, 8vw, 108px) 0 32px; }
.page-hero { max-width: 850px; }
.page-hero h1, .shelf-hero h1 {
  max-width: 16ch;
  font-family: var(--font-display);
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}
.page-hero .lead, .shelf-hero .lead { max-width: 60ch; font-size: clamp(17px, 2vw, 20px); color: var(--fg-2); }
.eyebrow { color: var(--accent); font-weight: 500; }
.content { max-width: none; padding-bottom: 88px; }
.content h2 { font-family: var(--font-display); font-size: clamp(26px, 3.5vw, 38px); line-height: 1.2; letter-spacing: -0.02em; margin: 48px 0 14px; }
.content h3 { font-size: 18px; margin: 0 0 8px; }
.content a:not(.btn) { color: var(--accent); text-decoration: none; }
.content a:not(.btn):hover { text-decoration: underline; text-underline-offset: 3px; }
.soft-panel, .card { border-radius: var(--radius); box-shadow: var(--shadow); background: var(--bg-elevated); border: 1px solid var(--border); }

/* Homepage: Apple-style hero + card picker */
.shelf-hero { padding-bottom: 36px; }
.shelf-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr);
  gap: clamp(28px, 5vw, 74px);
  align-items: end;
}
.shelf-kicker { display: flex; align-items: center; gap: 12px; color: var(--muted); font: 12px var(--font-mono); }
.shelf-kicker::before { content: "01"; color: var(--accent); }
.outcome-note {
  padding: 24px;
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.outcome-note h2 { margin: 0 0 12px; font-size: 18px; }
.outcome-note ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; font-size: 14px; }
.outcome-note li::before { content: "✓"; color: var(--ok); margin-right: 10px; font-weight: 600; }
.outcome-note .outcome-more { margin: 12px 0 0; font-size: 13px; color: var(--muted); }

.shelf-frame {
  margin: 20px 0 0;
  padding: clamp(22px, 3vw, 42px) clamp(18px, 4vw, 48px) 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.shelf-frame > header { display: flex; justify-content: space-between; gap: 18px; align-items: baseline; margin-bottom: 18px; color: var(--fg); }
.shelf-frame > header h2 { font-size: clamp(19px, 2vw, 24px); margin: 0; }
.shelf-frame > header p { color: var(--muted); font: 11px var(--font-mono); }
.shelf-books { display: flex; min-height: 160px; align-items: stretch; overflow-x: auto; padding-top: 10px; gap: 12px; }
.shelf-book {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 130px;
  min-height: 132px;
  padding: 18px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  text-align: left;
  writing-mode: horizontal-tb;
  justify-content: space-between;
  font: 600 15px var(--font-body);
  letter-spacing: -0.01em;
  transition: border-color .24s ease, transform .24s ease, box-shadow .24s ease, background .24s ease;
}
.shelf-book span { font: 10px var(--font-mono); letter-spacing: .08em; opacity: .55; color: var(--meta); }
.shelf-book:hover { border-color: var(--border-strong); transform: translateY(-4px); box-shadow: var(--shadow); background: var(--bg-elevated); }
.shelf-book.is-selected {
  flex-basis: 150px;
  transform: translateY(-6px);
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.shelf-book::after { display: none; }
.shelf-plinth { display: none; }

.shelf-detail {
  display: none;
  margin: 16px 0 0;
  padding: clamp(26px, 4vw, 50px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.shelf-detail.is-selected { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(230px, .8fr); gap: 34px; animation: shelfIn .28s ease both; }
.shelf-detail h2 { margin: 0 0 10px; font: clamp(28px, 3.5vw, 43px)/1.12 var(--font-display); letter-spacing: -0.025em; }
.shelf-detail p { color: var(--fg-2); max-width: 55ch; }
.shelf-detail dl { margin: 0; padding: 0; border-top: 1px solid var(--border); }
.shelf-detail dl div { display: grid; grid-template-columns: 82px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.shelf-detail dt { color: var(--meta); font-family: var(--font-mono); }
.shelf-detail dd { margin: 0; color: var(--fg-2); }
.shelf-detail .btn { margin-top: 22px; }
@keyframes shelfIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.reader-checklist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 58px 0 0; overflow: hidden; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); }
.reader-checklist > div { padding: 22px; background: var(--bg-elevated); }
.reader-checklist strong { display: block; margin-bottom: 7px; font: 13px var(--font-mono); color: var(--accent); }
.reader-checklist p { font-size: 14px; color: var(--fg-2); }

/* Route and reference volumes */
.route-browser { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 0; margin: 12px 0 60px; overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elevated); box-shadow: var(--shadow); }
.route-tabs { display: grid; align-content: start; background: var(--bg-soft); border-right: 1px solid var(--border); }
.route-tab { padding: 19px 18px; border: 0; border-bottom: 1px solid var(--border); color: var(--fg-2); text-align: left; transition: background .18s ease, color .18s ease; }
.route-tab span { display: block; margin-bottom: 6px; color: var(--meta); font: 10px var(--font-mono); }
.route-tab strong { font-size: 17px; }
.route-tab:hover, .route-tab.is-selected { color: var(--accent); background: var(--accent-soft); }
.route-panel { display: none; padding: clamp(28px, 5vw, 58px); background: var(--bg-elevated); }
.route-panel.is-selected { display: block; animation: shelfIn .22s ease both; }
.route-panel .panel-label { color: var(--accent); font: 11px var(--font-mono); }
.route-panel h2 { margin: 7px 0 14px; font: clamp(30px, 4vw, 48px)/1.08 var(--font-display); letter-spacing: -0.025em; }
.route-panel > p { max-width: 62ch; color: var(--fg-2); }
.route-spec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 28px 0; border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.route-spec div { padding: 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.route-spec dt { color: var(--meta); font: 10px var(--font-mono); }
.route-spec dd { margin: 5px 0 0; font-size: 14px; color: var(--fg-2); }
.route-panel ul { margin: 0; padding-left: 19px; color: var(--fg-2); display: grid; gap: 8px; }

.chapter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 34px 0 60px; }
.chapter-card { min-height: 200px; padding: 23px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); box-shadow: none; transition: transform .2s ease, box-shadow .2s ease; }
.chapter-card .chapter-no { color: var(--accent); font: 11px var(--font-mono); }
.chapter-card h3 { margin: 28px 0 10px; font-size: 20px; }
.chapter-card p { color: var(--muted); font-size: 14px; }
.chapter-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

/* Detailed text pages */
.reading-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: clamp(32px, 6vw, 90px); padding-bottom: 82px; }
.reading-copy { max-width: 730px; }
.reading-copy h2 { margin-top: 0; }
.reading-copy h2:not(:first-child) { margin-top: 55px; }
.reading-copy p { color: var(--fg-2); margin-top: 12px; }
.reading-copy ul, .reading-copy ol { padding-left: 21px; color: var(--fg-2); }
.reading-copy li + li { margin-top: 8px; }
.margin-note { align-self: start; position: sticky; top: 92px; padding: 20px; border-top: 3px solid var(--accent); border-radius: var(--radius); background: var(--bg-elevated); box-shadow: var(--shadow); font-size: 14px; }
.margin-note h2 { margin: 0 0 10px; font-size: 16px; }
.margin-note p { color: var(--muted); }
.policy-table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 14px; }
.policy-table th, .policy-table td { padding: 12px; border: 1px solid var(--border); vertical-align: top; text-align: left; }
.policy-table th { background: var(--bg-soft); font: 11px var(--font-mono); color: var(--fg-2); }
.callout { margin: 24px 0; padding: 18px 20px; border-left: 4px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--fg-2); }
.callout strong { display: block; margin-bottom: 5px; color: var(--ink); }
.symptom-list { display: grid; gap: 12px; margin-top: 22px; }
.symptom-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); }
.symptom-card h3 { display: flex; gap: 10px; align-items: baseline; }
.symptom-card h3 span { color: var(--accent); font: 11px var(--font-mono); }
.symptom-card p { margin: 8px 0; color: var(--muted); }
.symptom-card ul { margin: 0; }

.site-footer { margin-top: 0; background: var(--bg-soft); border-top: 1px solid var(--border); color: var(--muted); }
.site-footer h4 { color: var(--fg); }
.site-footer a { color: var(--fg-2); }
.footer-note { color: var(--muted); border-top-color: var(--border); }

@media (max-width: 860px) {
  .topnav-inner { min-height: 60px; }
  .nav-links { flex-wrap: nowrap; overflow-x: auto; max-width: 70vw; }
  .nav-links a { white-space: nowrap; }
  .shelf-intro, .shelf-detail.is-selected, .reading-grid { grid-template-columns: 1fr; }
  .outcome-note { max-width: 640px; }
  .route-browser { grid-template-columns: 1fr; }
  .route-tabs { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .route-tab { min-width: 160px; border-right: 1px solid var(--border); }
  .route-spec, .chapter-grid, .reader-checklist { grid-template-columns: 1fr; }
  .margin-note { position: static; order: -1; }
}

@media (max-width: 560px) {
  .container { padding-inline: 18px; }
  .topnav-inner {
    min-height: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: .55rem;
    padding-block: .7rem;
  }
  .brand small { display: none; }
  .nav-links {
    width: 100%;
    justify-content: space-between;
    gap: 0;
    overflow: visible;
    max-width: none;
  }
  .nav-links a { padding: .34rem .24rem; font-size: .75rem; white-space: nowrap; }
  .shelf-books { min-height: 0; flex-direction: column; }
  .shelf-book { min-width: 0; min-height: 0; }
  .shelf-book.is-selected { flex-basis: auto; }
  .shelf-detail { padding: 24px 18px; }
  .page-hero, .shelf-hero { padding-top: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
