/* ============================================================
   howToClaude — reset, layout, typography
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }
[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: content-box; }

/* ============================================================
   App frame
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar .spacer { flex: 1; }

.brandmark {
  display: flex; align-items: center; gap: 9px;
  font-weight: 680; letter-spacing: -0.015em;
  color: var(--ink); font-size: var(--fs-md);
}
.brandmark:hover { text-decoration: none; }
.brandmark .glyph {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 800; letter-spacing: -0.04em;
  box-shadow: var(--shadow-sm);
}
.brandmark small {
  display: block; font-size: 10px; font-weight: 500;
  color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase;
  line-height: 1;
}

/* ---------- sidebar ---------- */
.sidebar {
  grid-row: 1 / -1;
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  padding: 0 0 40px;
  z-index: 45;
}
.sidebar-head {
  position: sticky; top: 0; z-index: 2;
  padding: 14px 16px 12px;
  background: var(--bg-rail);
  border-bottom: 1px solid var(--line);
}
.sidebar nav { padding: 12px 10px 0; }

.nav-group { margin-bottom: 16px; }
.nav-group > .nav-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 6px 10px 5px;
}
.nav-group > .nav-label .num {
  font-variant-numeric: tabular-nums;
  color: var(--accent); opacity: .8;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; margin: 1px 0;
  border-radius: var(--r-sm);
  color: var(--ink-2); font-size: var(--fs-sm);
  line-height: 1.35;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--ink); text-decoration: none; }
.nav-item.active {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent-ink); font-weight: 600;
  border-left-color: var(--accent);
}
.nav-item .ico { width: 15px; text-align: center; opacity: .8; flex: none; font-size: 12px; }
.nav-item .lab-tag {
  margin-left: auto; font-size: 9px; font-weight: 700; letter-spacing: .06em;
  padding: 1px 5px; border-radius: 4px;
  background: var(--accent-2-soft); color: var(--accent-2);
  text-transform: uppercase;
}

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.page-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w);
  gap: 40px;
  padding: 30px 34px 100px;
  max-width: 1280px;
  width: 100%;
}
.page { min-width: 0; max-width: var(--content-max); }
.page.wide { max-width: none; }
.page-wrap.no-rail { grid-template-columns: minmax(0,1fr); }

/* ---------- right rail ---------- */
.rail {
  position: sticky; top: calc(var(--header-h) + 22px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 44px);
  overflow-y: auto;
  font-size: var(--fs-sm);
}
.rail h4 {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 8px;
}
.rail + .rail { margin-top: 22px; }
.toc a {
  display: block; padding: 3px 0 3px 11px;
  border-left: 2px solid var(--line);
  color: var(--ink-3); line-height: 1.4;
}
.toc a:hover { color: var(--ink); border-left-color: var(--line-strong); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc a.lvl3 { padding-left: 22px; font-size: var(--fs-xs); }

/* ============================================================
   Typography inside a page
   ============================================================ */

.page h1 {
  font-family: var(--font-display);
  font-size: var(--fs-3xl); line-height: 1.12;
  letter-spacing: -0.032em; font-weight: 720;
  margin: 0 0 10px;
}
.page h2 {
  font-size: var(--fs-xl); line-height: 1.25;
  letter-spacing: -0.02em; font-weight: 680;
  margin: 46px 0 12px; padding-top: 6px;
  scroll-margin-top: calc(var(--header-h) + 18px);
}
.page h2:first-of-type { margin-top: 34px; }
.page h3 {
  font-size: var(--fs-md); font-weight: 660;
  letter-spacing: -0.01em;
  margin: 30px 0 8px;
  scroll-margin-top: calc(var(--header-h) + 18px);
}
.page h4 {
  font-size: var(--fs-base); font-weight: 660;
  margin: 22px 0 6px; color: var(--ink-2);
}
.page p { margin: 0 0 14px; }
.page ul, .page ol { margin: 0 0 16px; padding-left: 20px; }
.page li { margin: 0 0 6px; }
.page li > ul, .page li > ol { margin-top: 6px; }
.page strong { font-weight: 650; color: var(--ink); }
.page hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

.lede {
  font-size: var(--fs-lg); line-height: 1.55;
  color: var(--ink-2); font-weight: 400;
  margin: 0 0 22px;
  letter-spacing: -0.011em;
}

.page-eyebrow {
  display: flex; align-items: center; gap: 9px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 12px;
}
.page-eyebrow::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

/* ---------- inline code ---------- */
code {
  font-family: var(--font-mono);
  font-size: 0.855em;
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.08em 0.34em;
  word-break: break-word;
}
pre code { border: 0; background: none; padding: 0; font-size: inherit; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1180px) {
  .page-wrap { grid-template-columns: minmax(0,1fr); }
  .rail-col { display: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(300px, 84vw);
    transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 44;
    background: rgba(0,0,0,.42);
  }
  .page-wrap { padding: 22px 18px 80px; }
  .page h1 { font-size: 2rem; }
  .menu-btn { display: grid !important; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brandmark small { display: none; }
}

@media print {
  .sidebar, .topbar, .rail-col, .no-print { display: none !important; }
  .app, .page-wrap { display: block; }
  .page { max-width: none; }
}
