/* Blockasaurus Handbook — Chonky Design System */

@font-face {
  font-family: 'Inconsolata';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/inconsolata/v32/QldgNThLqRwH-OJ1UHjlKENVzkWGVkL3GZQmAwLYxYWI2qfdm7Lpp4U8WR32lw.woff2') format('woff2');
}

/* ── Tokens ── */
:root {
  --color-bg: #fff;
  --color-surface: #f8f8f8;
  --color-surface-raised: #f0f0f0;
  --color-border: #ddd;
  --color-border-subtle: #eee;
  --color-text: #111;
  --color-text-muted: #666;
  --color-text-dim: #999;
  --color-text-inverse: #fff;
  --color-primary: #d48f00;
  --color-primary-hover: #b87c00;
  --color-primary-muted: rgba(212, 143, 0, 0.1);
  --color-accent: #215e21;
  --color-danger: #c41010;
  --color-info: #1a6f96;
  --color-blocked: #9333ea;
  --color-btn-bg: #f0f0f0;
  --color-btn-bg-hover: #e4e4e4;
  --color-btn-border: #ccc;
  --radius: 2px;
  --transition: 150ms ease;
  --transition-slow: 200ms ease;
  --font-mono: 'Inconsolata', 'Courier New', monospace;
  --text-xs: 0.72rem;
  --text-sm: 0.8rem;
  --text-base: 0.9rem;
  --text-lg: 1rem;
  --text-xl: 1.1rem;
  --text-2xl: 1.4rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --max-width: 52rem;
}

[data-theme="dark"] {
  --color-bg: #0a0a0a;
  --color-surface: #111;
  --color-surface-raised: #1a1a1a;
  --color-border: #222;
  --color-border-subtle: #1a1a1a;
  --color-text: #c8c8c8;
  --color-text-muted: #888;
  --color-text-dim: #555;
  --color-text-inverse: #0a0a0a;
  --color-primary: #ffaa00;
  --color-primary-hover: #ffbb33;
  --color-primary-muted: rgba(255, 170, 0, 0.12);
  --color-accent: #2a8a2a;
  --color-danger: #d60202;
  --color-info: #2386b0;
  --color-blocked: #a855f7;
  --color-btn-bg: #1a1a1a;
  --color-btn-bg-hover: #252525;
  --color-btn-border: #333;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0a0a0a;
    --color-surface: #111;
    --color-surface-raised: #1a1a1a;
    --color-border: #222;
    --color-border-subtle: #1a1a1a;
    --color-text: #c8c8c8;
    --color-text-muted: #888;
    --color-text-dim: #555;
    --color-text-inverse: #0a0a0a;
    --color-primary: #ffaa00;
    --color-primary-hover: #ffbb33;
    --color-primary-muted: rgba(255, 170, 0, 0.12);
    --color-accent: #2a8a2a;
    --color-danger: #d60202;
    --color-info: #2386b0;
    --color-blocked: #a855f7;
    --color-btn-bg: #1a1a1a;
    --color-btn-bg-hover: #252525;
    --color-btn-border: #333;
  }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;
}

body {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Site Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--color-text);
}

.site-logo img {
  width: 28px;
  height: 28px;
}

.site-logo span {
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

.site-logo .handbook-label {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-left: 0.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  font-family: inherit;
  font-size: var(--text-sm);
  transition: background var(--transition), color var(--transition);
}

.theme-toggle:hover {
  background: var(--color-primary-muted);
  color: var(--color-primary);
}

/* ── Layout ── */
.layout {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: var(--space-8);
  padding: var(--space-6) 1.5rem var(--space-8);
  min-height: calc(100vh - 3rem);
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 4rem;
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding-right: var(--space-4);
  border-right: 1px dotted var(--color-border-subtle);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-section {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  padding: var(--space-3) var(--space-2) var(--space-1);
  margin-top: var(--space-2);
}

.sidebar-section:first-child {
  margin-top: 0;
  padding-top: var(--space-1);
}

.sidebar a {
  display: block;
  padding: 0.3rem var(--space-2);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}

.sidebar a:hover {
  background: var(--color-primary-muted);
  color: var(--color-text);
}

.sidebar a.active {
  background: var(--color-primary-muted);
  color: var(--color-primary);
  font-weight: 600;
  border-left: 2px solid var(--color-primary);
}

/* ── Main Content ── */
.content {
  min-width: 0;
  padding-bottom: var(--space-8);
}

/* ── Typography ── */
h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

h1 + .subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

h2 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  border-bottom: 1px dotted var(--color-border-subtle);
  padding-bottom: var(--space-2);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

h4 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
}

p {
  margin-bottom: var(--space-3);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* ── Box (Chonky panel) ── */
.box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  margin-bottom: var(--space-4);
  transition: background var(--transition), border-color var(--transition);
}

.box-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px dotted var(--color-border);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  font-weight: 600;
}

.box-body {
  padding: 1rem;
}

/* ── Callout boxes ── */
.callout {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.callout-icon {
  flex-shrink: 0;
  font-size: var(--text-base);
  line-height: 1.5;
}

.callout-body {
  flex: 1;
  min-width: 0;
}

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

.callout.info {
  border-left: 3px solid var(--color-info);
  background: rgba(26, 111, 150, 0.06);
}

.callout.warn {
  border-left: 3px solid var(--color-primary);
  background: var(--color-primary-muted);
}

.callout.danger {
  border-left: 3px solid var(--color-danger);
  background: rgba(196, 16, 16, 0.06);
}

.callout.tip {
  border-left: 3px solid var(--color-accent);
  background: rgba(33, 94, 33, 0.06);
}

/* ── Code blocks ── */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface-raised);
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
  border: 1px solid var(--color-border-subtle);
}

pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: var(--space-4);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* ── File label on code blocks ── */
.code-file {
  display: inline-block;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.25rem 0.75rem;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}

.code-file + pre {
  border-top-left-radius: 0;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: top;
}

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

/* ── Lists ── */
ul, ol {
  margin-bottom: var(--space-3);
  padding-left: 1.5rem;
}

li {
  margin-bottom: var(--space-1);
}

li > ul, li > ol {
  margin-top: var(--space-1);
  margin-bottom: var(--space-1);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.15em 0.45em;
  font-size: var(--text-xs);
  border-radius: var(--radius);
  font-weight: 600;
  vertical-align: middle;
}

.badge.primary { background: var(--color-primary-muted); color: var(--color-primary); }
.badge.accent  { background: rgba(33, 94, 33, 0.1); color: var(--color-accent); }
.badge.danger  { background: rgba(196, 16, 16, 0.08); color: var(--color-danger); }
.badge.info    { background: rgba(26, 111, 150, 0.08); color: var(--color-info); }

/* ── Screenshot placeholder ── */
.screenshot {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: var(--space-6) var(--space-4);
  margin-bottom: var(--space-4);
  text-align: center;
  color: var(--color-text-dim);
  font-size: var(--text-sm);
}

.screenshot img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  cursor: zoom-in;
  transition: opacity var(--transition);
}

.screenshot img:hover {
  opacity: 0.85;
}

.screenshot .caption {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-dim);
  font-style: italic;
}

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #999;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color var(--transition);
}

.lightbox-close:hover {
  color: #fff;
}

/* ── Steps ── */
.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.steps > li {
  counter-increment: step;
  padding-left: 2.5rem;
  position: relative;
  margin-bottom: var(--space-4);
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius);
  background: var(--color-primary-muted);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Tab-like switcher ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}

.tab {
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Footer ── */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-4) 1.5rem;
  border-top: 1px dotted var(--color-border);
  color: var(--color-text-dim);
  font-size: var(--text-xs);
  text-align: center;
}

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

  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px dotted var(--color-border-subtle);
    padding-right: 0;
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-4);
  }

  .sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .sidebar-section {
    width: 100%;
    padding: var(--space-2) 0 var(--space-1);
    margin-top: var(--space-1);
  }
}

/* ── Prev/Next nav ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px dotted var(--color-border-subtle);
}

.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: background var(--transition), border-color var(--transition);
  min-width: 0;
}

.page-nav a:hover {
  background: var(--color-primary-muted);
  border-color: var(--color-primary);
  text-decoration: none;
}

.page-nav .label {
  font-size: var(--text-xs);
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-nav .next {
  margin-left: auto;
  text-align: right;
}

/* ── On-page TOC (right rail) ── */
.toc {
  font-size: var(--text-xs);
  color: var(--color-text-dim);
}

.toc ul {
  list-style: none;
  padding-left: 0;
}

.toc li {
  margin-bottom: 0.2rem;
}

.toc a {
  color: var(--color-text-dim);
  text-decoration: none;
}

.toc a:hover {
  color: var(--color-primary);
}
