/* Structural layer shared by every theme (docs/spec/02 §4). No colors of its own.
 *
 * THEME CONTRACT: every theme (the hub's hub.css and each section/group theme.css) must define these
 * custom properties on :root. Omitting one is meant to look wrong so it gets noticed.
 *   --bg --bg-alt --text --text-muted --accent --accent-contrast --border --card-bg --link
 *   --font-body --font-head --font-mono --radius --max-width
 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg, magenta);
  color: var(--text, lime);
  font-family: var(--font-body, monospace);
  line-height: 1.55;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--link, red); }
h1, h2, h3, h4 { font-family: var(--font-head, monospace); line-height: 1.2; }
code, pre { font-family: var(--font-mono, monospace); }
[hidden] { display: none !important; }
.muted { color: var(--text-muted, red); }

/* --- site navigation -------------------------------------------------------------------- */
.site-nav { border-bottom: 1px solid var(--border, red); background: var(--bg-alt, magenta); }
.site-nav__inner {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  max-width: var(--max-width, 70rem); margin: 0 auto; padding: .6rem 1rem;
}
.site-nav__brand { font-family: var(--font-head, monospace); font-weight: 700; text-decoration: none; color: var(--text, lime); }
.site-nav__crumbs, .site-nav__links { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .9rem; }
.site-nav__crumbs span { color: var(--text-muted, red); }
.site-nav__crumbs a, .site-nav__links a { text-decoration: none; color: var(--link, red); }
.site-nav__links a[aria-current="page"] { font-weight: 700; text-decoration: underline; }
.site-nav__tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; min-width: 0; font-size: .9rem; }
.theme-toggle {
  font: inherit; cursor: pointer; padding: .2rem .6rem; color: var(--text, lime);
  background: transparent; border: 1px solid var(--border, red); border-radius: var(--radius, 0);
}
.site-nav__search { min-width: min(11rem, 100%); }

/* --- page frames ------------------------------------------------------------------------ */
main { max-width: var(--max-width, 70rem); margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page--toc { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 2rem; align-items: start; }
.toc { position: sticky; top: 1rem; font-size: .9rem; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc__l3 { padding-left: .9rem; } .toc__l4 { padding-left: 1.8rem; }
.toc__title { margin: 0 0 .4rem; font-weight: 700; }
@media (max-width: 760px) { .page--toc { grid-template-columns: 1fr; } .toc { position: static; } }
.prose { min-width: 0; }
.prose table { border-collapse: collapse; max-width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border, red); padding: .3rem .6rem; text-align: left; }
.prose blockquote { margin: 1rem 0; padding: .1rem 1rem; border-left: 3px solid var(--accent, red); }
.prose pre { overflow-x: auto; padding: .75rem; border: 1px solid var(--border, red); border-radius: var(--radius, 0); }
.fig-right { float: right; margin: 0 0 1rem 1.25rem; max-width: 40%; }
.task-list-item { list-style: none; }
.task-list-item input { margin-right: .4rem; }

/* --- cards and chips (layout primitives) ------------------------------------------------ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.card {
  display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: inherit;
  background: var(--card-bg, magenta); border: 1px solid var(--border, red); border-radius: var(--radius, 0);
}
.card__img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.card__body { display: flex; flex-direction: column; gap: .25rem; padding: .9rem 1rem 1.1rem; }
.card__kind { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted, red); }
.card__title { font-family: var(--font-head, monospace); font-size: 1.15rem; font-weight: 700; }
.card__tagline { font-size: .92rem; color: var(--text-muted, red); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.chip {
  font: inherit; font-size: .8rem; padding: .15rem .6rem; cursor: pointer; text-decoration: none;
  color: var(--text, lime); background: transparent; border: 1px solid var(--border, red); border-radius: 999px;
}
.chip[aria-pressed="true"], .chip--on { background: var(--accent, red); color: var(--accent-contrast, lime); }

/* --- hub pages -------------------------------------------------------------------------- */
.hero { padding: 1.5rem 0 1rem; }
.hero h1 { margin: 0 0 .4rem; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.hero__tagline { font-size: 1.15rem; margin: 0 0 .5rem; }
.hero__intro { margin: 0; color: var(--text-muted, red); max-width: 44rem; }
.section-title { margin: 2rem 0 .8rem; font-size: 1.1rem; }
.page-list { padding-left: 1.2rem; }
.empty { color: var(--text-muted, red); }
.button {
  display: inline-block; padding: .45rem 1rem; text-decoration: none; font-weight: 600;
  color: var(--accent-contrast, lime); background: var(--accent, red); border-radius: var(--radius, 0);
}
.button--ghost { background: transparent; color: var(--link, red); border: 1px solid var(--border, red); }
.site-footer { max-width: var(--max-width, 70rem); margin: 0 auto; padding: 1rem; font-size: .85rem; color: var(--text-muted, red); border-top: 1px solid var(--border, red); }
.admin-links ul { padding-left: 1.2rem; }
/* the admin's grouped list of a section's hidden pages (shared/js/session.js) */
.admin-links .hidden-count { margin: .1rem 0 .6rem; font-size: .88rem; color: var(--text-muted, red); }
.admin-links .hidden-filter { display: block; width: 100%; max-width: 22rem; margin: 0 0 .5rem; padding: .35rem .6rem; font: inherit; color: #202020; background: rgba(255, 255, 255, .75); border: 1px solid var(--border, red); border-radius: var(--radius, 0); }   /* light in every theme: a theme's panel colour can be dark */
.admin-links .hidden-group { margin: 0 0 1rem; }
.admin-links .hidden-group h3 { display: flex; align-items: baseline; gap: .5rem; margin: .8rem 0 .2rem; padding-bottom: .15rem; font-size: 1rem; border-bottom: 1px solid var(--border, red); }
.admin-links .hidden-group h3 .count { font-size: .75rem; font-weight: 400; color: var(--text-muted, red); }
.admin-links .hidden-group .summary { display: block; font-size: .85rem; line-height: 1.35; color: var(--text-muted, red); }
.admin-links .hidden-group > p.summary { margin: 0 0 .25rem; }
.admin-links .hidden-group ul { margin: .25rem 0 0; }
.admin-links .hidden-group li { margin: .25rem 0; }

/* --- directives (frames come from the section theme) ------------------------------------ */
.callout { margin: 1rem 0; padding: .6rem 1rem; border: 1px solid var(--border, red); border-left-width: 4px; border-radius: var(--radius, 0); }
.callout__title { margin: 0 0 .3rem; font-weight: 700; }
.callout__body > :first-child { margin-top: 0; } .callout__body > :last-child { margin-bottom: 0; }
.statblock { margin: 1.25rem 0; padding: .9rem 1.1rem; border: 1px solid var(--border, red); background: var(--card-bg, magenta); break-inside: avoid; }
.statblock p { margin: .2rem 0; }
.sb-name { margin: 0; } .sb-meta { margin: 0 0 .5rem; }
.sb-abilities { width: 100%; border-collapse: collapse; margin: .5rem 0; text-align: center; font-size: .9rem; }
.sb-abilities th, .sb-abilities td { padding: .15rem .35rem; }
.sb-section h4 { margin: .9rem 0 .3rem; border-bottom: 1px solid var(--border, red); }
.sb-gap { display: inline-block; width: 1.25rem; }

/* --- search ------------------------------------------------------------------------------ */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.search-input {
  font: inherit; width: 100%; padding: .35rem .7rem; color: var(--text, lime); background: var(--bg, magenta);
  border: 1px solid var(--border, red); border-radius: var(--radius, 0);
}
.site-nav__search { position: relative; }
.search-drop {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20; width: min(34rem, 92vw); max-height: 70vh; overflow: auto;
  padding: .5rem .75rem; background: var(--card-bg, magenta); color: var(--text, lime);
  border: 1px solid var(--border, red); border-radius: var(--radius, 0); box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.search-drop__list, .search-results { list-style: none; margin: 0; padding: 0; }
.search-drop__all { display: block; margin-top: .4rem; font-size: .9rem; }
.search-drop__empty { margin: .25rem 0; color: var(--text-muted, red); }
.search-result { padding: .6rem 0; border-bottom: 1px solid var(--border, red); }
.search-result:last-child { border-bottom: 0; }
.search-result__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; }
.search-result__title { font-weight: 700; }
.search-result__badge { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted, red); border: 1px solid var(--border, red); border-radius: 999px; padding: 0 .5rem; }
.search-result__excerpt { margin: .2rem 0; font-size: .92rem; color: var(--text-muted, red); }
.search-result__excerpt mark { background: transparent; color: var(--accent, red); font-weight: 700; }
.search-result__tags { margin-top: .2rem; }
.search-page__form { margin: 0 0 1rem; max-width: 40rem; }
.search-page__filters { display: grid; gap: .5rem; margin-bottom: .75rem; }
.search-filter { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .75rem; }
.search-filter__label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted, red); min-width: 4.5rem; }
@media (max-width: 640px) { .site-nav__tools { margin-left: 0; width: 100%; } .site-nav__search { flex: 1 1 100%; order: 5; } .search-drop { left: 0; right: auto; } }
