/* Web Creators Wiki — design system
   Typeface pairing: IBM Plex Sans (UI/body) + IBM Plex Mono (structure/code/labels) —
   an actual technology-company type family, chosen because this is an internal
   tool for a team that reads code all day. */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --ink: #14181c;
  --ink-muted: #5c6470;
  --ink-faint: #8b929b;
  --border: #e4e7ea;
  --border-strong: #d2d6da;
  --accent: #0f7a6c;
  --accent-ink: #0b5c51;
  --accent-soft: #e4f3f0;
  --accent-soft-strong: #cfeae5;
  --code-bg: #f1f3f2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 28, 0.05), 0 1px 1px rgba(20, 24, 28, 0.03);
  --shadow-md: 0 8px 20px rgba(20, 24, 28, 0.08), 0 2px 6px rgba(20, 24, 28, 0.04);

  --font-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --header-h: 60px;
  --sidebar-w: 292px;
}

@media (prefers-reduced-motion: no-preference) {
  :root {
    --transition-fast: 120ms ease;
    --transition-med: 200ms ease;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-med: 0ms;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 0.6em;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 200;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  flex-shrink: 0;
}
.menu-toggle svg {
  width: 18px;
  height: 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}
.brand__tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 0.15em 0.5em;
  border-radius: 999px;
}

.header-search {
  margin-left: auto;
  width: 100%;
  max-width: 340px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.header-user__name {
  color: var(--ink-muted);
  display: none;
}
.header-user a {
  color: var(--ink-muted);
  font-weight: 500;
}
.header-user a:hover {
  color: var(--accent-ink);
}
@media (min-width: 640px) {
  .header-user__name {
    display: inline;
  }
}

/* ---------- Search field (shared) ---------- */
.search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0 0.6rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-field svg {
  width: 16px;
  height: 16px;
  color: var(--ink-faint);
  flex-shrink: 0;
}
.search-field input {
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink);
  padding: 0.55rem 0;
  width: 100%;
}
.search-field input::placeholder {
  color: var(--ink-faint);
}
.search-field button {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.3rem;
  display: none;
}

.search-field--lg {
  padding: 0 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.search-field--lg input {
  padding: 0.9rem 0;
  font-size: 1.05rem;
}
.search-field--lg svg {
  width: 20px;
  height: 20px;
}

/* ---------- Layout shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem 3rem;
  background: var(--surface);
}

.main {
  min-width: 0;
  padding: 2.5rem 2rem 5rem;
}

/* ---------- Tree navigation ---------- */
.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree ul {
  list-style: none;
  margin: 0.15rem 0 0.5rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
}
.tree li {
  margin: 0;
}
.tree__branch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}
.tree__branch:hover {
  background: var(--code-bg);
  text-decoration: none;
}
.tree__branch--active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.tree__branch--active:hover {
  background: var(--accent-soft-strong);
}
.tree__count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink-faint);
  font-weight: 400;
}
.tree__branch--active .tree__count {
  color: var(--accent-ink);
}

.tree__link {
  display: block;
  padding: 0.32rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 0.875rem;
  line-height: 1.35;
  position: relative;
}
.tree__link::before {
  content: '';
  position: absolute;
  left: -0.9rem;
  top: 50%;
  width: 0.65rem;
  height: 1px;
  background: var(--border);
}
.tree__link:hover {
  background: var(--code-bg);
  color: var(--ink);
  text-decoration: none;
}
.tree__link--current {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-bottom: 1.25rem;
}
.breadcrumbs a {
  color: var(--ink-muted);
}
.breadcrumbs a:hover {
  color: var(--accent-ink);
}
.breadcrumbs__sep {
  color: var(--border-strong);
}
.breadcrumbs__current {
  color: var(--ink);
}

/* ---------- Page header ---------- */
.page-title {
  font-size: 2rem;
  margin-bottom: 0.4rem;
}
.page-lead {
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 62ch;
  margin: 0 0 1.75rem;
}

/* ---------- Prose (CKEditor output) ---------- */
.prose {
  max-width: 74ch;
}
.prose > *:first-child {
  margin-top: 0;
}
.prose h2 {
  font-size: 1.375rem;
  margin-top: 2.2em;
  padding-top: 0.2em;
  border-top: 1px solid var(--border);
}
.prose h2:first-child {
  border-top: 0;
  margin-top: 0;
}
.prose h3 {
  font-size: 1.125rem;
  margin-top: 1.8em;
}
.prose p {
  margin: 0 0 1.1em;
}
.prose ul,
.prose ol {
  margin: 0 0 1.1em;
  padding-left: 1.4em;
}
.prose li {
  margin-bottom: 0.35em;
}
.prose a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}
.prose a:hover {
  text-decoration-color: currentColor;
}
.prose strong {
  font-weight: 600;
}
.prose blockquote {
  margin: 1.4em 0;
  padding: 0.1rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose blockquote p {
  margin: 0.75em 0;
}
.prose code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--code-bg);
  color: var(--accent-ink);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.4em;
}
.prose pre code {
  background: none;
  color: var(--ink);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.55;
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.2em 0;
}
.prose table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.4em;
  font-size: 0.92rem;
}
.prose th,
.prose td {
  border-bottom: 1px solid var(--border);
  padding: 0.5em 0.9em 0.5em 0;
  text-align: left;
}
.prose th {
  font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
}

/* Todo lists (CKEditor task list output) */
.prose ul.todo-list {
  list-style: none;
  padding-left: 0;
  margin: 0 0 1.1em;
}
.prose .todo-list__label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: default;
  margin-bottom: 0.4em;
}
.prose .todo-list__label input[type='checkbox'] {
  appearance: none;
  width: 1.05em;
  height: 1.05em;
  margin-top: 0.2em;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  display: grid;
  place-content: center;
}
.prose .todo-list__label input[type='checkbox']::before {
  content: '';
  width: 0.62em;
  height: 0.62em;
  transform: scale(0);
  transition: transform var(--transition-fast);
  box-shadow: inset 1em 1em var(--accent);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.prose .todo-list__label input[type='checkbox']:checked::before {
  transform: scale(1);
}
.prose .todo-list__label:has(input:checked) .todo-list__label__description {
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}

/* ---------- Wiki content blocks ---------- */
.wiki-blocks > * + * {
  margin-top: 1.75rem;
}

.code-block {
  position: relative;
  max-width: 74ch;
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  overflow-x: auto;
}
.code-block code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink);
  background: none;
}
.code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* Prism.js token colors, tuned to the wiki palette */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--ink-faint);
  font-style: italic;
}
.token.punctuation {
  color: var(--ink-muted);
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #a35a1f;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--accent-ink);
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #6b6f76;
}
.token.atrule,
.token.attr-value,
.token.keyword {
  color: #7a3ba8;
}
.token.function,
.token.class-name {
  color: #1f6fb2;
}
.token.regex,
.token.important,
.token.variable {
  color: #b3441e;
}

.wiki-figure {
  max-width: 74ch;
  margin: 0;
}
.wiki-figure img {
  display: block;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.wiki-figure figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.wiki-image-text {
  max-width: 74ch;
}
.wiki-image-text .wiki-figure {
  margin-bottom: 1rem;
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.9rem;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.2rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  text-decoration: none;
}
.card__title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--ink);
  margin: 0 0 0.3rem;
}
.card__excerpt {
  font-size: 0.87rem;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
  line-height: 1.45;
}
.card__meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1rem;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section {
  margin-top: 3rem;
}
.section:first-child {
  margin-top: 0;
}

.empty-note {
  font-size: 0.92rem;
  color: var(--ink-muted);
  margin: -0.5rem 0 1.5rem;
}

/* ---------- Home hero ---------- */
.hero {
  max-width: 640px;
  margin: 1.5rem 0 3.5rem;
}
.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-ink);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.hero h1 {
  font-size: 2.4rem;
  margin-bottom: 0.6rem;
}
.hero p {
  font-size: 1.1rem;
  color: var(--ink-muted);
  margin: 0 0 1.75rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-ink);
  text-decoration: none;
}

/* ---------- Auth pages (login / password reset) ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
}
.auth-card__brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--ink);
  margin-bottom: 2.25rem;
}
.auth-card__brand:hover {
  text-decoration: none;
}
.auth-card__title {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}
.auth-card__lead {
  color: var(--ink-muted);
  margin: 0 0 1.75rem;
}
.auth-card__footer-link {
  display: inline-block;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.auth-card__footer-link:hover {
  color: var(--accent-ink);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 0.75rem;
}
.form-label:first-child {
  margin-top: 0;
}
.form-input {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  font-size: 0.875rem;
  color: var(--ink-muted);
}
.form-checkbox input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}
.auth-form__submit {
  margin-top: 1.5rem;
  width: 100%;
  padding: 0.75rem 1.1rem;
}
.form-error {
  background: #fbeae6;
  color: #a3391c;
  border: 1px solid #f0c6bb;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.875rem;
  margin: 0 0 1.25rem;
}
.form-success {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--accent-soft-strong);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  font-size: 0.875rem;
  margin: 0 0 1.25rem;
}

/* ---------- Search results ---------- */
.search-meta {
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}
.search-meta mark {
  background: none;
  color: var(--ink);
  font-weight: 600;
}

/* ---------- 404 ---------- */
.error-page {
  max-width: 520px;
  margin: 3rem 0;
}
.error-page__code {
  font-family: var(--font-mono);
  color: var(--accent-ink);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}
.error-page h1 {
  font-size: 2rem;
  margin: 0.5rem 0 0.75rem;
}
.error-page p {
  color: var(--ink-muted);
  margin-bottom: 1.75rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .header-search {
    max-width: none;
  }
  .sidebar {
    position: fixed;
    z-index: 150;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(300px, 84vw);
    padding-top: calc(var(--header-h) + 1rem);
    box-shadow: var(--shadow-md);
    transform: translateX(-100%);
    transition: transform var(--transition-med);
  }
  .shell[data-nav-open='true'] .sidebar {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 28, 0.35);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-med);
  }
  .shell[data-nav-open='true'] .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .main {
    padding: 2rem 1.25rem 4rem;
  }
  .hero h1 {
    font-size: 1.9rem;
  }
  .page-title {
    font-size: 1.6rem;
  }
}

@media (max-width: 520px) {
  .brand span:not(.brand__tag) {
    display: none;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
}
