/* Realworld theme for the internal Wiki (Zensical).
   Tokens mirror rw-website site/assets/css/style.css (:root), commit recorded
   in theme/WEBSITE_SOURCE.txt: neutral surfaces, one accent, Geist, no
   gradients. Only supported theme mechanisms are used: CSS custom
   properties, extra_css, logo and favicon. */

@font-face {
  font-family: "Geist";
  /* Latin subset, weights 300-700 (same file as rw.inc; 35 KB instead of 63 KB). */
  src: url("../assets/rw/fonts/Geist-latin-v2.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --rw-bg: #ffffff;
  --rw-bg-subtle: #eff4f9;
  --rw-ink: #070f1a;
  --rw-ink-soft: #4e5764;
  --rw-ink-muted: #5c6470;
  --rw-line: #d7dde6;
  --rw-accent: #0042c5;
  --rw-accent-strong: #0059e8;
  --rw-accent-soft: #e7edfb;
  --rw-radius: 6px;
  --rw-font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --md-text-font: "Geist";
  --md-text-font-family: var(--rw-font);
  --md-code-font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

[data-md-color-scheme="default"],
:root {
  --md-default-bg-color: var(--rw-bg);
  --md-default-fg-color: var(--rw-ink);
  --md-default-fg-color--light: var(--rw-ink-soft);
  --md-default-fg-color--lighter: var(--rw-ink-muted);
  --md-default-fg-color--lightest: var(--rw-line);

  /* Header and tabs: white bar with ink text, as on the website. */
  --md-primary-fg-color: var(--rw-bg);
  --md-primary-fg-color--light: var(--rw-bg-subtle);
  --md-primary-fg-color--dark: var(--rw-bg-subtle);
  --md-primary-bg-color: var(--rw-ink);
  --md-primary-bg-color--light: var(--rw-ink-soft);

  --md-accent-fg-color: var(--rw-accent-strong);
  --md-accent-fg-color--transparent: var(--rw-accent-soft);

  --md-typeset-color: var(--rw-ink);
  --md-typeset-a-color: var(--rw-accent);
  --md-code-bg-color: var(--rw-bg-subtle);
  --md-code-fg-color: var(--rw-ink);
  --md-typeset-table-color: var(--rw-line);
  --md-footer-bg-color: var(--rw-ink);
  --md-footer-bg-color--dark: #000000;
  --md-footer-fg-color: #ffffff;
  --md-footer-fg-color--light: #acd9ff;
}

body, input, .md-typeset { font-family: var(--rw-font); }
code, kbd, pre { font-family: var(--md-code-font-family); }

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

::selection { background: var(--rw-accent-soft); color: var(--rw-ink); }

/* Header: 64 px, hairline bottom border, no shadow. */
.md-header {
  border-bottom: 1px solid var(--rw-line);
  box-shadow: none;
}
.md-header[data-md-state="shadow"], .md-header--shadow { box-shadow: none; }
/* Logo at the website's size (site/assets/css/style.css .nav-logo img: 20px). */
.md-header__button.md-logo img, .md-header__button.md-logo svg { height: 20px; width: auto; }
/* Header shows only the logo: the site name and the scrolled page title are
   hidden, but the element keeps its flex space so search stays on the right. */
.md-header__title { visibility: hidden; }
/* Phone navigation drawer: the logo already says "Realworld", so the site name next to it is
   hidden (font-size 0 hides the bare text node) and the logo gets the header's 20px. */
.md-nav--primary > .md-nav__title[for="__drawer"] { font-size: 0; }
.md-nav--primary > .md-nav__title[for="__drawer"] .md-nav__button.md-logo { width: auto; height: auto; }
.md-nav--primary > .md-nav__title[for="__drawer"] .md-nav__button.md-logo img { width: auto; height: 20px; }

/* Headings: same weights and tracking as the website. */
.md-typeset h1 { font-weight: 600; letter-spacing: -0.03em; color: var(--rw-ink); }
.md-typeset h2 { font-weight: 600; letter-spacing: -0.022em; }
.md-typeset h3 { font-weight: 600; letter-spacing: -0.011em; }
.md-typeset h1, .md-typeset h2, .md-typeset h3 { text-wrap: balance; }
.md-typeset p, .md-typeset li { text-wrap: pretty; }

/* Links: accent, underline on hover only. */
.md-typeset a { color: var(--rw-accent); text-decoration: none; }
.md-typeset a:hover, .md-typeset a:focus { color: var(--rw-accent-strong); text-decoration: underline; }
/* Links inside running text are underlined: colour alone is only 2.4:1 against the body text (WCAG 1.4.1). */
.md-typeset :is(p, li) > a:not(.md-button):not(.headerlink) { text-decoration: underline; text-underline-offset: 2px; }

/* Navigation: active item in ink with accent marker. */
.md-nav__link--active, .md-nav__item .md-nav__link--active { color: var(--rw-accent); font-weight: 600; }
.md-nav__link:hover { color: var(--rw-accent-strong); }

/* Tables and code blocks: thin lines, small radius. */
.md-typeset table:not([class]) { border: 1px solid var(--rw-line); border-radius: var(--rw-radius); box-shadow: none; }
.md-typeset table:not([class]) th { background: var(--rw-bg-subtle); color: var(--rw-ink); font-weight: 600; }
.md-typeset pre > code, .md-typeset code { border-radius: var(--rw-radius); }

/* Admonitions: flat, hairline, website accent. */
.md-typeset .admonition, .md-typeset details {
  border-radius: var(--rw-radius);
  box-shadow: none;
  border-width: 1px;
}

/* Visible focus, as on the website. */
a:focus-visible, button:focus-visible, label:focus-visible, input:focus-visible {
  outline: 2px solid var(--rw-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Search box on a white header. */
.md-search__form { background: var(--rw-bg-subtle); border-radius: var(--rw-radius); }
.md-search__input::placeholder { color: var(--rw-ink-muted); }

/* Page changes: instant navigation swaps the content in place; fade the new
   content in so the switch reads as one smooth step, not a flash. */
@media (prefers-reduced-motion: no-preference) {
  .md-content__inner {
    animation: rw-page-in 220ms cubic-bezier(0.2, 0, 0, 1) both;
  }
  @keyframes rw-page-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
  .md-progress { background: var(--rw-accent); }
}

/* Navigation tree: nested levels hang off a hairline guide, like a file tree. */
@media screen and (min-width: 76.25em) {
  .md-nav--primary .md-nav__item > .md-nav {
    border-left: 1px solid var(--rw-line);
    margin-left: 0.6rem;
  }
}

/* Definition codes (L-BB-001) as a chip, apart from the name: navigation,
   breadcrumbs and page titles (build_site.py mark_codes). */
.rw-code {
  display: inline-block;
  font-family: var(--md-code-font-family);
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.35;
  padding: 0 0.4em;
  margin-right: 0.35em;
  border-radius: 4px;
  background: var(--rw-bg-subtle);
  color: var(--rw-ink-soft);
  white-space: nowrap;
  vertical-align: baseline;
}
/* In the navigation the code chip comes first and the name wraps in its own
   column beside it, so codes line up like a classifier. */
.md-nav .md-ellipsis:has(> .rw-code) { display: flex; align-items: baseline; gap: 0.45em; overflow: visible; }
/* A wider tree so code + name fit (theme default is 12.1rem). */
@media screen and (min-width: 76.25em) {
  .md-sidebar--primary { width: 16rem; }
  [dir] .md-sidebar--primary .md-sidebar__inner { padding-left: 0; padding-right: 0.6rem; }
}
/* The tree scrolls inside the sidebar, which stops just above the footer: fade the last line
   out instead of cutting it with a hard edge, and let the last item scroll fully into view. */
.md-sidebar__scrollwrap {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.6rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1.6rem), transparent);
}
.md-sidebar__inner { padding-bottom: 1.6rem; }
.md-nav .rw-code { flex: none; margin: 0; font-size: 0.78em; }
.md-nav__link--active .rw-code { background: var(--rw-accent-soft); color: var(--rw-accent); }
.md-typeset h1 .rw-code { font-size: 0.5em; vertical-align: middle; padding: 0.15em 0.5em; margin-right: 0.5em; }

/* Code blocks: light panel with a hairline, website palette for syntax
   colours (keywords in the accent), copy button kept. */
:root {
  --md-code-hl-keyword-color: #0042c5;
  --md-code-hl-string-color: #0b7a4f;
  --md-code-hl-number-color: #b4540a;
  --md-code-hl-constant-color: #7a3db8;
  --md-code-hl-function-color: #0059e8;
  --md-code-hl-name-color: var(--rw-ink);
  --md-code-hl-operator-color: var(--rw-ink-soft);
  --md-code-hl-punctuation-color: var(--rw-ink-soft);
  --md-code-hl-comment-color: var(--rw-ink-muted);
  --md-code-hl-generic-color: var(--rw-ink-soft);
  --md-code-hl-variable-color: var(--rw-ink);
  --md-code-hl-special-color: #c0336b;
}
.md-typeset pre {
  border: 1px solid var(--rw-line);
  border-radius: var(--rw-radius);
}
.md-typeset pre > code {
  font-size: 0.8em;
  line-height: 1.6;
  padding: 1em 1.2em;
}
.md-typeset .highlight span.filename {
  font-family: var(--md-code-font-family);
  font-size: 0.75em;
  font-weight: 500;
  color: var(--rw-ink-soft);
  background: var(--rw-bg-subtle);
  border: 1px solid var(--rw-line);
  border-bottom: none;
  border-radius: var(--rw-radius) var(--rw-radius) 0 0;
}
.md-typeset .highlight span.filename + pre { border-top-left-radius: 0; border-top-right-radius: 0; }
.md-typeset :not(pre) > code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border: 1px solid var(--rw-line);
}

/* Breadcrumbs stay on one line: long names are shortened with "..." (the current page,
   last, gives way first - its full name is the title right below), never wrapped. */
.md-path { overflow: hidden; }
.md-path__list { flex-wrap: nowrap; min-width: 0; }
.md-path__item { display: inline-flex; align-items: center; gap: 0.2rem; flex: 0 1 auto; min-width: 2.5em; white-space: nowrap; }
.md-path__item:last-child { flex-shrink: 4; }
.md-path__item::before { flex: none; }
.md-path__link { min-width: 0; }
.md-path .md-ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Diagrams (Mermaid): brand font, ink edges, accent nodes. The role classes
   (rwGroup, rwSoft, rwOutline, rwSolid, rwMuted) live in assets/js/diagrams.js; rules
   in docs/editor/DIAGRAMS.md. */
:root {
  --md-mermaid-font-family: var(--rw-font);
  --md-mermaid-edge-color: var(--rw-ink-soft);
  --md-mermaid-node-bg-color: var(--rw-accent-soft);
  --md-mermaid-node-fg-color: var(--rw-accent);
  --md-mermaid-label-bg-color: var(--rw-bg);
  --md-mermaid-label-fg-color: var(--rw-ink);
}
.md-typeset .mermaid { margin: 1.6em 0; text-align: center; }

/* YouTube embed (the editor's video block): full text width, 16:9 */
.md-typeset .rw-video { margin: 1.6em 0; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--rw-ink); }
.md-typeset .rw-video iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Account link, top right of the header (portal/build_site.py ACCOUNT_LINK): "Log in" for guests,
   "Log out" for signed-in readers. Same shape as the website's small outline button. */
.md-header__source { width: auto; max-width: none; margin-left: 0.6rem; display: flex; align-items: center; }
.rw-account {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border: 1px solid var(--rw-line); border-radius: 999px;
  font-size: 0.7rem; font-weight: 500; line-height: 1; white-space: nowrap;
  color: var(--rw-ink); background: var(--rw-bg);
}
.rw-account:hover, .rw-account:focus-visible { color: var(--rw-accent); border-color: var(--rw-accent); }
.rw-account[data-rw-login] { background: var(--rw-ink); border-color: var(--rw-ink); color: var(--rw-bg); }
.rw-account[data-rw-login]:hover, .rw-account[data-rw-login]:focus-visible { background: var(--rw-accent); border-color: var(--rw-accent); color: var(--rw-bg); }

/* Signed-in menu: a small lock before pages a guest cannot see (content/wiki/access.toml).
   Left of the title, so it never collides with the section chevron on the right. Editors get
   clickable lock buttons instead (.rw-nav-lock, added by the editor loader). */
.md-nav__link.rw-locked::before,
.rw-nav-lock {
  content: ""; flex: 0 0 auto; width: 0.6rem; height: 0.6rem; margin-right: 0.4rem; align-self: center;
  background-color: currentColor; opacity: 0.45;
  -webkit-mask: var(--rw-lock-closed) center / contain no-repeat;
          mask: var(--rw-lock-closed) center / contain no-repeat;
}
:root {
  --rw-lock-closed: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
  --rw-lock-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 7.75-1.4'/%3E%3C/svg%3E");
}
.rw-lock-edit .md-nav__link.rw-locked::before { content: none; }
/* Editor: one button per menu row. Closed = signed-in only; faint open lock = everyone;
   accent = changed and not yet published (or a section with some pages open). */
.rw-nav-lock {
  display: inline-block; width: 0.95rem; height: 0.95rem; padding: 0.15rem; margin: 0 0.25rem 0 -0.15rem; box-sizing: border-box;
  -webkit-mask-origin: content-box; mask-origin: content-box; cursor: pointer; border-radius: 3px; opacity: 0.6;
}
.rw-nav-lock:hover, .rw-nav-lock:focus-visible { opacity: 1; color: var(--rw-accent); outline: none; }
.rw-nav-lock[data-state="open"], .rw-nav-lock[data-state="mixed"] {
  -webkit-mask-image: var(--rw-lock-open); mask-image: var(--rw-lock-open); opacity: 0.3;
}
.rw-nav-lock[data-draft], .rw-nav-lock[data-state="mixed"] { color: var(--rw-accent); opacity: 1; }
/* Editor: an eye right of the lock on section rows. Open eye = the section starts expanded in the
   menu for every reader; crossed out = it starts collapsed. Page rows keep the same gap. */
:root {
  --rw-eye-on: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  --rw-eye-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M3 3l18 18'/%3E%3C/svg%3E");
}
.rw-nav-eye, .rw-nav-eye-space {
  display: inline-block; flex: 0 0 auto; align-self: center; width: 0.95rem; height: 0.95rem; padding: 0.15rem;
  margin: 0 0.3rem 0 -0.1rem; box-sizing: border-box;
}
.rw-nav-eye {
  background-color: currentColor; cursor: pointer; border-radius: 3px; opacity: 0.6;
  -webkit-mask: var(--rw-eye-on) center / contain no-repeat; mask: var(--rw-eye-on) center / contain no-repeat;
  -webkit-mask-origin: content-box; mask-origin: content-box;
}
.rw-nav-eye[data-state="collapsed"] { -webkit-mask-image: var(--rw-eye-off); mask-image: var(--rw-eye-off); opacity: 0.3; }
.rw-nav-eye:hover, .rw-nav-eye:focus-visible { opacity: 1; color: var(--rw-accent); outline: none; }
.rw-nav-eye[data-draft] { color: var(--rw-accent); opacity: 1; }

/* Footer copyright links to rw.inc (portal/seo.py); same look as the text. */
.md-copyright__highlight a { color: inherit; text-decoration: none; }
.md-copyright__highlight a:hover, .md-copyright__highlight a:focus-visible { color: var(--rw-accent); text-decoration: underline; }

/* Cookie notice, as on rw.inc (theme/assets/js/cookie-notice.js). Sizes are in px, not rem:
   the theme's root font size grows on wide screens (up to 20px), rw.inc's stays at 16px. */
.rw-cookie-notice { position: fixed; left: 16px; bottom: 16px; z-index: 50; max-width: 340px; padding: 12px 14px;
  background: rgba(255, 255, 255, 0.8); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  color: var(--rw-ink-soft); border: 1px solid #bbc3ce; border-radius: 10px;
  box-shadow: 0 8px 28px rgba(7, 15, 26, 0.14); font-family: var(--rw-font); font-size: 13px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; transform-origin: bottom left; animation: rw-cookie-in 240ms cubic-bezier(0.23, 1, 0.32, 1) both; }
.rw-cookie-notice.is-leaving { animation: rw-cookie-out 160ms cubic-bezier(0.23, 1, 0.32, 1) both; pointer-events: none; }
.rw-cookie-notice p { margin: 0 0 10px; font-size: 13px; line-height: 1.45; text-wrap: pretty; }
.rw-cookie-notice a { color: var(--rw-accent); text-decoration: underline; text-underline-offset: 2px; }
.rw-cookie-notice__actions { display: flex; gap: 8px; }
.rw-cookie-notice__btn { flex: 1; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 500; line-height: 1.45;
  color: var(--rw-ink); background: var(--rw-bg); border: 1px solid var(--rw-ink); border-radius: var(--rw-radius); cursor: pointer;
  transition: background 160ms ease-out, transform 160ms ease-out; }
.rw-cookie-notice__btn:hover { background: var(--rw-bg-subtle); }
.rw-cookie-notice__btn:active { transform: scale(0.97); }
.rw-cookie-notice__btn:focus-visible, .rw-cookie-notice a:focus-visible { outline: 2px solid var(--rw-accent); outline-offset: 2px; }
@keyframes rw-cookie-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
@keyframes rw-cookie-out { to { opacity: 0; transform: translateY(8px) scale(0.96); } }
@media (max-width: 520px) { .rw-cookie-notice { left: 12px; right: 12px; bottom: 12px; max-width: none; } }
@media (prefers-reduced-motion: reduce) {
  @keyframes rw-cookie-in { from { opacity: 0; } }
  @keyframes rw-cookie-out { to { opacity: 0; } }
}
.md-copyright__highlight .rw-cookies-link { margin-left: 0.6em; }
