/* ---------- Filter UI ---------- */
#filter-bar {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem 0.85rem;
  margin: 0 0 2rem 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: padding 0.15s ease;
}
#filter-bar.collapsed {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  margin: 0;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}
#filter-bar.collapsed > :not(.filter-header) { display: none !important; }
#filter-bar.collapsed .filter-header > .filter-title { display: none; }
#filter-bar.collapsed .filter-header {
  margin: 0;
  pointer-events: auto;
  position: sticky;
  top: 0.5rem;
}
.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
#filter-toggle {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
#filter-toggle:hover { color: var(--text); border-color: var(--accent); }
#filter-bar.collapsed #filter-toggle {
  background: var(--bg-secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.filter-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.filter-top {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
#filter-search {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
  outline: none;
}
#filter-search:focus { border-color: var(--accent); }
#filter-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#filter-clear {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
}
#filter-clear:hover { color: var(--text); border-color: var(--accent); }
.filter-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  align-items: start;
  gap: 0.5rem 0.75rem;
  margin: 0.5rem 0;
}
.filter-row > .filter-chip {
  /* chips live in the second column — wrap them in an inline group */
}
.filter-row .filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.filter-label {
  font-size: 0.7rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding-top: 0.25rem;
  line-height: 1.4;
}
.filter-chip {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.filter-chip:hover {
  color: var(--text);
  border-color: var(--accent);
}
.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.filter-more {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}
.filter-more[open] { padding-bottom: 0.25rem; }
.filter-more summary {
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.2rem 0;
  list-style: none;
}
.filter-more summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s;
}
.filter-more[open] summary::before { transform: rotate(90deg); }
.filter-more summary:hover { color: var(--text); }

/* ---------- Collapsible ToC ---------- */
main > details {
  margin: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}
main > details:last-of-type { border-bottom: none; }
main > details > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
main > details > summary::-webkit-details-marker { display: none; }
main > details > summary::before {
  content: '▸';
  display: inline-block;
  width: 1em;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
main > details[open] > summary::before { transform: rotate(90deg); }
main > details > summary:hover { background: var(--bg-secondary); border-radius: 4px; }
main > details > summary > a {
  color: var(--link);
  text-decoration: none;
}
main > details > summary > a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}
main > details > ul {
  margin: 0.2rem 0 0.6rem 2rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--border);
}
main > details > ul > li {
  padding: 0.15rem 0;
  list-style: disc;
}

/* ---------- Warning callout ---------- */
.callout-warning {
  background: #3a2f0a;
  border-left: 4px solid #d4a017;
  color: #f5e6a8;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin: 1rem 0;
}
.callout-warning p { margin: 0; }
.callout-warning a { color: #ffd866; text-decoration: underline; }
.callout-warning a:hover { color: #fff2b3; }

/* Dark mode theme for 3D Resources */
:root {
  --bg: #000000;
  --bg-secondary: #0a0d12;
  --bg-tertiary: #161b22;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-subtle: #6e7681;
  --link: #58a6ff;
  --link-hover: #79c0ff;
  --border: #30363d;
  --accent: #388bfd;
  --code-bg: #161b22;
  --table-row-alt: #161b22;
  --bold: #f0f6fc;
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'PT Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Noto Sans, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

header .view a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
}

header .view a:hover { color: var(--link); }
header .view a svg { vertical-align: middle; }

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--bold);
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; margin-top: 0; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }

p { margin: 0.75rem 0; }

strong, b { color: var(--bold); }

blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-radius: 0 6px 6px 0;
}

blockquote p { margin: 0.25rem 0; }

/* Links */
a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s;
}

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

/* Horizontal rules */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Lists */
ul, ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

li { margin: 0.25rem 0; }
li > ul, li > ol { margin: 0; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

thead {
  background: var(--bg-tertiary);
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--bold);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

tr:nth-child(even) { background: var(--table-row-alt); }
tr:hover { background: var(--bg-tertiary); }

/* Code */
code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  background: var(--bg-tertiary);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--text);
}

pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* Footer */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 0.8rem;
}

footer a { color: var(--text-muted); }
footer a:hover { color: var(--link); }

/* Collapsible section headings (H2/H3 in main content) */
.collapsible-heading {
  cursor: pointer;
  position: relative;
  padding-left: 1.2rem;
  user-select: none;
}
.collapsible-heading::before {
  content: '▾';
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.85em;
  color: var(--text-muted);
  transition: transform 0.15s;
  transform-origin: 0.4em 0.6em;
}
.collapsible-heading[data-collapsed]::before { transform: rotate(-90deg); }
.collapsible-heading:hover::before { color: var(--text); }
.collapsible-heading:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* Table of Contents (Contents section) */
h2#contents + ul {
  columns: 2;
  column-gap: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .wrapper { padding: 1rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h2#contents + ul { columns: 1; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.4rem 0.5rem; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
}
