/* RawBlock docs — polished, responsive */
:root {
  --black: #000000;
  --white: #ffffff;
  --blue: #0000ff;
  --surface: #ffffff;
  --sunken: #f4f4f4;
  --muted: #555555;
  --line: #000000;
  --warning: #ffa500;
  --error: #ff0000;
  --success: #008000;
  --border: 2px;
  --border-strong: 3px;
  --sidebar-w: 260px;
  --content-max: 48rem;
  --pad-x: clamp(1rem, 3vw, 2.5rem);
  --pad-y: clamp(1.25rem, 3vw, 2.5rem);
  --font-h: "Archivo Black", system-ui, sans-serif;
  --font-b: "Work Sans", system-ui, sans-serif;
  --font-m: "Space Mono", ui-monospace, monospace;
  --topbar-h: 56px;
  --ease: 0.18s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

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

body {
  margin: 0;
  font-family: var(--font-b);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--black);
  background: var(--surface);
  min-height: 100vh;
}

body.nav-open {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--blue);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--black);
}

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

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

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem 1rem 2.5rem;
  border-right: var(--border-strong) solid var(--line);
  background: var(--white);
  z-index: 40;
}

.brand {
  padding-bottom: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: var(--border-strong) solid var(--line);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-h);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand p {
  margin: 0.4rem 0 0;
  font-family: var(--font-m);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
}

.brand-links {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.brand-links a {
  display: block;
  font-family: var(--font-m);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--black);
  border: var(--border) solid var(--line);
  padding: 0.45rem 0.65rem;
  transition: background var(--ease), color var(--ease);
}

.brand-links a:hover {
  background: var(--black);
  color: var(--white);
}

.nav-section {
  font-family: var(--font-h);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.35rem 0 0.35rem;
  padding: 0 0.35rem;
}

.nav a {
  display: block;
  color: var(--black);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.35;
  padding: 0.55rem 0.65rem;
  border-left: 3px solid transparent;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.nav a:hover {
  background: var(--sunken);
  border-left-color: var(--black);
}

.nav a.active {
  background: var(--black);
  color: var(--white);
  border-left-color: var(--black);
}

/* ── Backdrop (mobile drawer) ── */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 35;
  opacity: 0;
  transition: opacity var(--ease);
}

.backdrop.show {
  display: block;
  opacity: 1;
}

/* ── Top bar (mobile) ── */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--white);
  border-bottom: var(--border-strong) solid var(--line);
}

.topbar .topbar-title {
  font-family: var(--font-h);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 72px;
  padding: 0.45rem 0.85rem;
  background: var(--black);
  color: var(--white);
  border: var(--border-strong) solid var(--line);
  font-family: var(--font-h);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.menu-toggle:hover {
  background: var(--white);
  color: var(--black);
}

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

.main {
  min-width: 0;
  flex: 1;
  padding: var(--pad-y) var(--pad-x) clamp(3rem, 8vw, 6rem);
}

.main-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* ── Hero ── */
.hero {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  margin-bottom: clamp(2rem, 5vw, 3rem);
  background: var(--black);
  color: var(--white);
  border: var(--border-strong) solid var(--line);
}

.hero h1,
.hero h2 {
  margin: 0 0 1rem;
  font-family: var(--font-h);
  font-size: clamp(1.5rem, 4.5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hero p {
  margin: 0.65rem 0;
  color: rgba(255, 255, 255, 0.92);
  max-width: 42rem;
}

.hero a {
  color: #ffff66;
}

.hero a:hover {
  color: var(--white);
}

.hero code {
  background: var(--white);
  color: var(--black);
  border: none;
  padding: 0.1rem 0.35rem;
  font-family: var(--font-m);
  font-size: 0.85em;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  color: var(--white);
  background: transparent;
}

.pill a {
  color: inherit;
  text-decoration: none;
}

.pill a:hover {
  text-decoration: underline;
  color: #ffff66;
}

/* ── Typography ── */
section {
  margin: clamp(2rem, 5vw, 3.25rem) 0;
  scroll-margin-top: calc(var(--topbar-h) + 0.75rem);
}

.content h1,
section > h2,
.main h1 {
  font-family: var(--font-h);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  scroll-margin-top: calc(var(--topbar-h) + 0.75rem);
}

.content h1,
.main > .main-inner > h1,
.main-inner > .content > h1 {
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  margin: 0 0 1.25rem;
}

.content h1:not(:first-child) {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.5rem;
  border-top: var(--border-strong) solid var(--line);
}

section > h2,
.content h2 {
  font-family: var(--font-h);
  font-size: clamp(1.2rem, 3vw, 1.75rem);
  font-weight: 400;
  line-height: 1.15;
  margin: 0 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: var(--border-strong) solid var(--line);
  text-transform: uppercase;
  scroll-margin-top: calc(var(--topbar-h) + 0.75rem);
}

.content h2 {
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
}

h3,
.content h3 {
  font-family: var(--font-b);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 600;
  line-height: 1.3;
  margin: 1.5rem 0 0.65rem;
  scroll-margin-top: calc(var(--topbar-h) + 0.75rem);
}

h4 {
  font-family: var(--font-b);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 0.9rem;
}

ol,
ul {
  margin: 0 0 1.15rem;
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.45rem;
}

li::marker {
  font-weight: 600;
}

hr.rule {
  border: none;
  border-top: var(--border) solid var(--line);
  margin: 1.75rem 0;
}

/* ── Cards / callouts / steps ── */
.card {
  background: var(--white);
  border: var(--border-strong) solid var(--line);
  padding: clamp(1rem, 2.5vw, 1.35rem);
  margin: 1rem 0;
}

.card.elevated {
  border-width: 3px;
}

.card h4 {
  margin-top: 0;
}

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: start;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
  border: var(--border-strong) solid var(--line);
  background: var(--sunken);
}

.callout.warn {
  border-color: var(--black);
  background: #fff8eb;
  border-left: 6px solid var(--warning);
}

.callout .icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-family: var(--font-h);
  font-size: 0.9rem;
  background: var(--black);
  color: var(--white);
}

.callout.warn .icon {
  background: var(--warning);
  color: var(--black);
}

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

.step {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 0.9rem;
  margin: 1.15rem 0;
  padding: clamp(0.9rem, 2vw, 1.2rem);
  border: var(--border-strong) solid var(--line);
  background: var(--white);
}

.step-num {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  font-family: var(--font-h);
  font-size: 1.1rem;
  background: var(--black);
  color: var(--white);
  flex-shrink: 0;
}

.step > div:last-child {
  min-width: 0;
}

/* ── Chips / file links / buttons ── */
.file-link {
  display: inline-flex;
  align-items: center;
  margin: 0.25rem 0.35rem 0.25rem 0;
  padding: 0.35rem 0.7rem;
  border: 2px solid var(--line);
  background: var(--white);
  color: var(--black);
  text-decoration: none;
  font-family: var(--font-m);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  transition: background var(--ease), color var(--ease);
}

.file-link:hover {
  background: var(--black);
  color: var(--white);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1.35rem;
  font-family: var(--font-b);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border: var(--border-strong) solid var(--line);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.btn-primary {
  background: var(--black);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--white);
  color: var(--black);
}

.btn-secondary {
  background: var(--white);
  color: var(--black);
}

.btn-secondary:hover {
  background: var(--black);
  color: var(--white);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* ── Tables ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 1.15rem;
  border: var(--border-strong) solid var(--line);
}

.table-wrap table {
  margin: 0;
  border: none;
  min-width: 420px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.15rem;
  font-size: 0.92rem;
  border: var(--border-strong) solid var(--line);
}

th,
td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #d0d0d0;
  border-right: 1px solid #e0e0e0;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: none;
}

th {
  background: var(--black);
  color: var(--white);
  font-family: var(--font-h);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

tbody tr:hover td {
  background: var(--sunken);
}

/* ── Code ── */
code {
  font-family: var(--font-m);
  font-size: 0.84em;
  background: var(--sunken);
  padding: 0.1rem 0.35rem;
  border: 1px solid #ccc;
  word-break: break-word;
}

pre {
  margin: 0 0 1.15rem;
  padding: 0.9rem 1rem;
  background: var(--black);
  color: var(--white);
  border: var(--border-strong) solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

pre[data-lang]::before {
  content: attr(data-lang);
  display: block;
  font-family: var(--font-h);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  margin: -0.15rem 0 0.65rem;
  padding-bottom: 0.4rem;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--white);
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre;
  word-break: normal;
}

/* ── Figures ── */
figure {
  margin: 1.15rem 0;
  padding: 0.75rem;
  border: var(--border-strong) solid var(--line);
  background: var(--white);
}

figure img {
  width: 100%;
  border: 1px solid #ddd;
}

figcaption {
  margin-top: 0.55rem;
  font-family: var(--font-m);
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.footer-note {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.25rem;
  border-top: var(--border-strong) solid var(--line);
  font-family: var(--font-m);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Responsive ── */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 86vw);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform var(--ease);
    border-right: var(--border-strong) solid var(--line);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding-top: 1.25rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .step {
    grid-template-columns: 2.25rem minmax(0, 1fr);
  }

  .step-num {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.95rem;
  }

  .callout {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }

  .btn-row .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 520px) {
  :root {
    --pad-x: 0.9rem;
  }

  pre code {
    font-size: 0.72rem;
  }

  th,
  td {
    padding: 0.55rem 0.6rem;
    font-size: 0.85rem;
  }

  .hero {
    padding: 1.15rem;
  }

  .file-link {
    font-size: 0.68rem;
  }
}

@media (min-width: 1400px) {
  :root {
    --sidebar-w: 280px;
    --content-max: 52rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Print */
@media print {
  .sidebar,
  .topbar,
  .menu-toggle,
  .backdrop {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .main {
    padding: 0;
  }

  pre {
    white-space: pre-wrap;
    border-color: #000;
  }
}
