/* Design tokens mirrored from aPCS-frontend src/utils/tokens.ts and
   src/styles.css — keep in sync when the platform theme changes.
   Same font stack as the platform (MUI default, no webfont loaded there). */

/* Theme switching mirrors the platform: a data-theme attribute on <html>,
   set by the inline script in base.html (localStorage, falls back to the
   OS preference) and toggled by the header button (js/assemblean_wiki.js). */
:root,
:root[data-theme='light'] {
  --primary: #16a9e4;
  --primary-light: #46bfef;
  --primary-dark: #1287b6;
  --secondary: #eb9928;
  --neutral: #7f7f7f;
  --neutral-dark: #595959;
  --surface: #ffffff;
  --surface-alt: #fafafa;
  --border-color: #e0e0e0;
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.6);
  --link: var(--primary-dark);
  --radius: 8px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --surface: #2e2e2e;
  --surface-alt: #242424;
  --border-color: rgba(255, 255, 255, 0.12);
  --text-primary: rgba(255, 255, 255, 0.87);
  --text-secondary: rgba(255, 255, 255, 0.6);
  --link: var(--primary-light);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Roboto, Helvetica, Arial, sans-serif;
  background: var(--surface-alt);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Header — mirrors the platform AppBar (primary bar, white logo). */
.site-header {
  background: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .inner {
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 72px;
}

.site-header img {
  height: 52px;
  display: block;
}

.site-header a {
  color: whitesmoke;
  text-decoration: none;
  font-size: 1.15rem;
}

/* Header search — translucent white on the primary bar. */
.site-search {
  margin-left: auto;
}

.site-search input {
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  width: 220px;
  font-size: 0.95rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.22);
  color: white;
  transition: background 0.15s, width 0.2s;
}

.site-search input::placeholder {
  color: rgba(255, 255, 255, 0.8);
}

.site-search input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--neutral-dark);
  width: 280px;
}

.site-search input:focus::placeholder {
  color: var(--neutral);
}

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}

#theme-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

#theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: white;
  display: none;
}

:root[data-theme='dark'] #theme-toggle .icon-sun {
  display: block;
}

:root[data-theme='light'] #theme-toggle .icon-moon {
  display: block;
}

main {
  max-width: 760px;
  margin: 32px auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 500; /* MUI headline weight */
}

h1 {
  font-size: 1.9rem;
  margin-top: 0;
}

a {
  color: var(--link);
  transition: color 0.15s;
}

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

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

main img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Breadcrumbs. */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.breadcrumbs a {
  text-decoration: none;
}

/* Rich-text content (what editors produce in the StreamField). */
main h2 {
  font-size: 1.4rem;
  margin-top: 36px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

main h3 {
  font-size: 1.15rem;
  margin-top: 28px;
}

main code {
  background: var(--surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.9em;
}

main pre {
  background: var(--surface-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
}

main pre code {
  border: none;
  background: none;
  padding: 0;
}

main blockquote {
  margin: 16px 0;
  padding: 4px 16px;
  border-left: 4px solid var(--neutral);
  color: var(--text-secondary);
}

main table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

main th,
main td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

main th {
  background: var(--surface-alt);
}

main hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 28px 0;
}

/* "callout" StreamField block — accent box in the secondary (orange) tone. */
.callout {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--secondary);
  background: color-mix(in srgb, var(--secondary) 12%, var(--surface));
  border-radius: 0 var(--radius) var(--radius) 0;
}

.callout p:first-child {
  margin-top: 0;
}

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

/* Child-page listings (home + docs index). */
.home main ul,
.docs-index main ul {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.home main li,
.docs-index main li {
  border-bottom: 1px solid var(--border-color);
}

.home main li a,
.docs-index main li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 12px;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.15s, padding-left 0.15s;
}

.home main li a::after {
  content: "›";
  color: var(--neutral);
}

.docs-index main li a::after {
  content: "›";
  color: var(--neutral);
}

.home main li a:hover,
.docs-index main li a:hover {
  background: var(--surface-alt);
  padding-left: 18px;
}

/* Search page + footer. */
.search-page-form {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.search-page-form input {
  flex: 1;
  padding: 9px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text-primary);
}

.search-page-form button {
  padding: 9px 20px;
  font-size: 0.95rem;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: background 0.15s;
}

.search-page-form button:hover {
  background: var(--primary-dark);
}

.result-list {
  list-style: none;
  padding: 0;
}

.result-list li {
  border-bottom: 1px solid var(--border-color);
  padding: 12px 4px;
}

.result-list li p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.no-results {
  color: var(--text-secondary);
}

.pagination {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.site-footer {
  max-width: 760px;
  margin: 0 auto 32px;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--text-secondary);
}
