/*
 * Borkshire litepaper — shared stylesheet for every page under /litepaper/.
 *
 * The :root token block below mirrors apps/landing/index.html (the splash page keeps its own
 * inline copy because it ships as a single self-contained file). If a token changes there,
 * change it here in the same edit.
 *
 * Deliberate differences from the splash page: this is a document, so scrolling and text
 * selection stay enabled, the shared paw-print field sits in a fixed backdrop behind a scrolling
 * column, and it respects reduced-motion preferences.
 */

:root {
  --paper: #f5f2ea;
  --paper-lift: #fbf9f3;
  --paper-edge: #ece6d9;
  --card: #fffdf8;

  --ink: #20222a;
  --ink-dim: #5b5f6c;

  --rim: rgba(32, 34, 42, 0.15);
  --rim-strong: rgba(32, 34, 42, 0.22);
  --shadow-soft: 0 1px 2px rgba(48, 42, 28, 0.05);
  --shadow-lift: 0 4px 11px rgba(48, 42, 28, 0.1);
  --focus: #2563eb;
  --radius-panel: 20px;
  --radius-control: 10px;

  --font-slab: 'Roboto Slab', Georgia, 'Times New Roman', serif;
  --font-body:
    'Cairo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;

  --gutter: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ------------------------------------------------------------------ backdrop
   The shared paw field is pinned to the viewport while the document scrolls over it. */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.backdrop .wash {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    124% 96% at 50% 42%,
    var(--paper-lift) 0%,
    var(--paper) 52%,
    var(--paper-edge) 100%
  );
}

.backdrop .grid {
  position: absolute;
  inset: 0;
}

.backdrop .vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 84% 84% at 50% 46%,
    rgba(116, 100, 70, 0) 0%,
    rgba(116, 100, 70, 0.015) 48%,
    rgba(116, 100, 70, 0.045) 70%,
    rgba(116, 100, 70, 0.085) 88%,
    rgba(116, 100, 70, 0.125) 100%
  );
}

.backdrop .grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* ------------------------------------------------------------------- layout */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px var(--gutter) 72px;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}

/* ------------------------------------------------------------------ sidebar
   The section picker sits on its own raised sheet, matching the document. */

.side {
  position: sticky;
  top: 28px;
  background: var(--card);
  border: 1px solid rgba(32, 34, 42, 0.1);
  border-radius: var(--radius-panel);
  box-shadow:
    0 10px 28px rgba(20, 22, 30, 0.08),
    0 2px 6px rgba(48, 42, 28, 0.06);
  padding: 20px 16px;
}

.side .crest {
  display: inline-block;
  border-radius: var(--radius-control);
  margin: 0 0 10px;
}

.side .crest img {
  display: block;
  width: 132px;
  height: auto;
}

.toc summary {
  display: none;
}

.toc-title {
  font-family: var(--font-slab);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.toc nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc nav a {
  display: block;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--ink-dim);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.toc nav a:hover {
  color: var(--ink);
  background: #f3efe4;
  border-color: var(--rim);
}

.toc nav a[aria-current='page'] {
  color: var(--ink);
  background: var(--sheet-recess);
  border-color: var(--rim-strong);
  font-weight: 700;
}

.side .back {
  margin-top: 18px;
}

/* Pill control — same geometry as the splash page's .social. */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--rim);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
}

.pill:hover {
  background: #f3efe4;
  border-color: var(--rim-strong);
  box-shadow: var(--shadow-lift);
}

.pill svg {
  flex: none;
}

/* ---------------------------------------------------------------- document
   The content column is a raised paper sheet on the paw-print desk: card
   fill, hairline rim, panel radius, and a lift that is softer than the splash
   modal's — this is a resting page, not a floating dialog. Controls that sit
   on the sheet (callouts, pager, table headers) use a slightly recessed fill
   so they read as pressed-in panels rather than stacked white cards. */

:root {
  --sheet-recess: #f6f2e8;
}

.doc {
  min-width: 0;
  max-width: 764px;
  background: var(--card);
  border: 1px solid rgba(32, 34, 42, 0.1);
  border-radius: var(--radius-panel);
  box-shadow:
    0 10px 28px rgba(20, 22, 30, 0.08),
    0 2px 6px rgba(48, 42, 28, 0.06);
  padding: 36px 42px 40px;
}

.kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 6px 0 10px;
}

.doc h1 {
  font-family: var(--font-slab);
  font-size: clamp(1.75rem, 4.5vw, 2.25rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}

.doc h2 {
  font-family: var(--font-slab);
  font-size: 1.375rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 44px 0 12px;
  padding-top: 26px;
  border-top: 1px solid var(--rim);
}

.doc h3 {
  font-family: var(--font-slab);
  font-size: 1.0625rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 28px 0 8px;
}

.doc p,
.doc li {
  color: #383b45;
  font-size: 0.9688rem;
}

.doc p {
  margin: 0 0 14px;
}

.doc ul,
.doc ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.doc li {
  margin-bottom: 6px;
}

.doc strong {
  color: var(--ink);
  font-weight: 600;
}

.doc a {
  color: var(--focus);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.doc .lede {
  font-size: 1.0938rem;
  color: var(--ink);
}

/* Info callout — the site's info-tooltip primitive: a recessed box with a
   small icon + INFO header row. Icon: Lucide "info" (lucide.dev, ISC license),
   inlined per page. */

.note {
  border: 1px solid var(--rim);
  border-radius: var(--radius-control);
  background: var(--sheet-recess);
  padding: 14px 16px;
  margin: 0 0 16px;
}

.note-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.note-head svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.note p {
  margin: 0 0 8px;
}

.note p:last-child {
  margin-bottom: 0;
}

.note .note-title {
  font-family: var(--font-slab);
  font-weight: 700;
  color: var(--ink);
  font-size: 0.9688rem;
  margin-bottom: 4px;
}

/* Tables. */

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 0.875rem;
  border: 1px solid var(--rim);
  border-radius: var(--radius-control);
  overflow: hidden;
}

.doc th,
.doc td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rim);
  vertical-align: top;
  color: #383b45;
}

.doc th {
  font-weight: 700;
  color: var(--ink);
  background: #f3efe4;
}

.doc tr:last-child td {
  border-bottom: none;
}

.table-scroll {
  overflow-x: auto;
  margin: 0 0 16px;
}

.table-scroll table {
  margin: 0;
  min-width: 480px;
}

/* Figures / diagrams. */

.doc figure {
  margin: 22px 0 24px;
}

.doc figure svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Wide flow diagrams scale with the column down to ~640px; below that their
   labels get too small, so each ships a vertically stacked phone variant and
   the two swap here — no clipping, no hidden horizontal scrolling. */

.doc figure svg.fig-phone {
  display: none;
}

@media (max-width: 640px) {
  .doc figure svg.fig-desktop {
    display: none;
  }

  .doc figure svg.fig-phone {
    display: block;
    max-width: 380px;
    margin: 0 auto;
  }
}

.doc figcaption {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--ink-dim);
}

/* Prev / next pager. */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 52px;
}

.pager a {
  flex: 1;
  max-width: 48%;
  border: 1px solid var(--rim);
  border-radius: var(--radius-control);
  background: var(--sheet-recess);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--ink);
}

.pager a:hover {
  border-color: var(--rim-strong);
  background: #f3efe4;
  box-shadow: var(--shadow-soft);
}

.pager a.next {
  margin-left: auto;
  text-align: right;
}

.pager .dir {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 2px;
}

.pager .dest {
  font-family: var(--font-slab);
  font-weight: 700;
  font-size: 0.9688rem;
}

/* Standing fine print at the bottom of every page. */

.fine {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--rim);
  font-size: 0.8125rem;
  color: var(--ink-dim);
}

.fine p {
  color: var(--ink-dim);
  font-size: 0.8125rem;
  margin: 0 0 8px;
}

/* Focus + reduced motion, matching the splash conventions. */

a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition-duration: 1ms !important;
  }
}

/* ------------------------------------------------------------------- phone */

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding-top: 18px;
  }

  .side {
    position: static;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .side .crest img {
    width: 96px;
  }

  .toc {
    border: 1px solid rgba(32, 34, 42, 0.1);
    border-radius: 14px;
    background: var(--card);
    box-shadow:
      0 10px 28px rgba(20, 22, 30, 0.08),
      0 2px 6px rgba(48, 42, 28, 0.06);
    padding: 4px 12px;
  }

  .toc summary {
    display: list-item;
    cursor: pointer;
    padding: 8px 2px;
    font-family: var(--font-slab);
    font-weight: 700;
    font-size: 0.9688rem;
  }

  .toc-title {
    display: none;
  }

  .toc nav {
    padding: 4px 0 10px;
  }

  .side .back {
    display: none;
  }

  .doc {
    max-width: none;
    border-radius: 14px;
    padding: 22px 16px 26px;
  }

  .pager {
    flex-direction: column;
  }

  .pager a,
  .pager a.next {
    max-width: none;
    margin-left: 0;
    text-align: left;
  }
}
