/* Augmencia manual theme.
 *
 * Brand look shared with the rest of the product:
 *  - light mode follows apps/dashboard's light palette (cream #F9F7F2 canvas,
 *    white paper cards, deep blue #1A3247 text — see apps/dashboard/src/data/
 *    light-palette.ts),
 *  - dark mode follows augmencia.com (navy #0A1628 canvas, #0D1E35 cards,
 *    #E8F0FF text),
 * and both share the brand accents: coral (#FF9B82 → #E67E66) and mint
 * (#96C9A8 → #74A584) from the logo gradients (apps/dashboard/src/assets/
 * logo.svg), Inter for text, Plus Jakarta Sans for headings, Space Mono for
 * the small mono voice (augmencia.com's caption font).
 *
 * This file is loaded after docsify's `vue` theme and overrides it; every
 * color below goes through the custom properties defined at the top so the
 * two modes stay in sync.
 *
 * Mode: the tiny bootstrap script in index.html resolves the theme before
 * first paint — 'light'/'dark' from localStorage ('colorMode'), otherwise the
 * system preference — and sets `data-theme` on <html>. Everything here keys
 * off that attribute; the navbar toggle just flips it and stores it.
 */

:root {
  color-scheme: light;

  /* Brand accents — identical in both modes (logo gradients + shared
     dashboard palette entries). */
  --brand-coral: #FF9B82;
  --brand-coral-deep: #E67E66;
  --brand-mint: #96C9A8;
  --brand-mint-deep: #74A584;
  --brand-blue: #1A3247;

  /* Brand type (Inter / Plus Jakarta Sans / Space Mono — the Latin webfonts
     loaded in index.html). The CJK fallbacks carry the Asian languages. */
  --font-text: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans SC', 'Noto Sans JP', 'Noto Sans KR', 'Microsoft YaHei', 'Malgun Gothic', Helvetica, Arial, sans-serif;
  --font-heading: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans SC', 'Noto Sans JP', 'Noto Sans KR', 'Microsoft YaHei', 'Malgun Gothic', Helvetica, Arial, sans-serif;
  --font-mono: 'Space Mono', Monaco, Consolas, 'Hiragino Sans', 'Noto Sans SC', 'Noto Sans JP', 'Noto Sans KR', 'Microsoft YaHei', 'Malgun Gothic', monospace;

  /* Light theme (dashboard light palette). */
  --bg: #F9F7F2;
  --surface: #FFFFFF;
  --surface-sunken: #F3EFE7;
  --text: #1A3247;
  --text-muted: #5D6D7E;
  --border: rgba(26, 50, 71, 0.12);
  --link: #2A5C8A;
  --link-hover: #1A3247;
  --code-text: #A34B2F;
  --focus: #2A5C8A;
  --selection: rgba(255, 155, 130, 0.35);
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235D6D7E' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(26, 50, 71, 0.05), 0 12px 32px rgba(26, 50, 71, 0.07);
  --logo-filter: none;
}

html[data-theme='dark'] {
  color-scheme: dark;

  /* Dark theme (augmencia.com palette). */
  --bg: #0A1628;
  --surface: #0D1E35;
  --surface-sunken: #16294A;
  --text: #E8F0FF;
  --text-muted: #8BA3C0;
  --border: rgba(232, 240, 255, 0.12);
  --link: #8BA3C0;
  --link-hover: #3B9EFF;
  --code-text: #FFC9B4;
  --focus: #3B9EFF;
  --selection: rgba(59, 158, 255, 0.35);
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238BA3C0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  /* The wordmark is deep blue; the dashboard and augmencia.com both flip
     the lockup to white on dark backgrounds. */
  --logo-filter: brightness(0) invert(1);
}

/* ---------- Base ---------- */

body,
.sidebar {
  background-color: var(--bg);
}

body {
  color: var(--text);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.7;
}

::selection {
  background: var(--selection);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* The "Please wait…" placeholder shown before docsify boots. */
div#app {
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

kbd {
  background-color: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  box-shadow: none;
}

/* ---------- Sidebar ---------- */

.sidebar {
  border-right: 1px solid var(--border);
  color: var(--text);
  padding: 28px 0 0;
}

.sidebar > h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0 0 1.5rem;
  padding: 0 24px;
  text-align: left;
}

.sidebar > h1 a {
  color: var(--text);
}

/* Brand lockup: mark + wordmark, same pair as the dashboard AppBar and
   augmencia.com's header. */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  height: 32px;
  width: 32px;
}

.brand-wordmark {
  height: 24px;
  width: auto;
}

.brand-mark,
.brand-wordmark {
  display: inline-block;
  filter: var(--logo-filter);
  opacity: 0.9;
  vertical-align: middle;
}

.sidebar .sidebar-nav {
  line-height: 2em;
  padding-bottom: 40px;
}

.sidebar ul li a {
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-text);
  font-size: 0.9375rem;
  font-weight: 500;
  overflow: hidden;
  padding: 4px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar ul li a:hover {
  background-color: var(--surface);
  color: var(--text);
  text-decoration: none;
}

/* Current page: coral indicator bar + interaction color. */
.sidebar ul li.active > a {
  background-color: var(--surface);
  border-right: 0;
  box-shadow: inset 3px 0 0 0 var(--brand-coral);
  color: var(--link-hover);
  font-weight: 600;
}

/* Auto-generated "on this page" sub-navigation. */
.sidebar .app-sub-sidebar a {
  font-size: 0.875rem;
  font-weight: 400;
}

.sidebar .app-sub-sidebar li.active > a {
  box-shadow: none;
  color: var(--brand-coral-deep);
}

.sidebar .app-sub-sidebar li:before {
  color: var(--brand-mint-deep);
  content: '—';
  padding-right: 6px;
}

html[data-theme='dark'] .sidebar .app-sub-sidebar li.active > a {
  color: var(--brand-coral);
}

html[data-theme='dark'] .sidebar .app-sub-sidebar li:before {
  color: var(--brand-mint);
}

/* Scrollbar (webkit) — subtle, like the dashboard. */
.sidebar::-webkit-scrollbar-thumb,
.markdown-section pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-track,
.markdown-section pre::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Navbar (language switcher + theme toggle) ----------
 *
 * docsify renders the navbar as <nav class="app-nav"> beside the content, but
 * with mergeNavbar it becomes a plain <nav> inside the sidebar on narrow
 * screens — every rule below covers both containers.
 */

.app-nav {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 24px 32px 0 0;
}

.sidebar nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 24px 16px;
}

/* Language menu: the <select> in _navbar.md (native names + folder codes) is
   upgraded by the plugin into a flag dropdown — native <option>s can't show
   flags. The trigger keeps the chip language of the theme toggle; the popup
   is position: fixed (the sidebar clips absolutely-positioned children). */
select.lang-switch {
  display: none;
}

.lang-menu-trigger {
  align-items: center;
  background-color: transparent;
  background-image: var(--caret);
  background-position: right 12px center;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  gap: 8px;
  letter-spacing: 0.06em;
  line-height: 1.6;
  margin: 0;
  max-width: 220px;
  padding: 4px 32px 4px 12px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  transition: color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.lang-menu-trigger:hover {
  border-color: var(--link);
  color: var(--text);
}

.lang-flag {
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--border);
  flex-shrink: 0;
  height: 15px;
  object-fit: cover;
  width: 20px;
}

.lang-menu-list {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: 0;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 6px;
  position: fixed;
  z-index: 1200;
}

.lang-menu-list[hidden] {
  display: none;
}

.lang-menu-list li {
  align-items: center;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  gap: 10px;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.lang-menu-list li:hover,
.lang-menu-list li:focus {
  background-color: var(--surface-sunken);
  color: var(--text);
  outline: none;
}

/* Current language: coral indicator + the brand's emphasis color. */
.lang-menu-list li[aria-selected='true'] {
  box-shadow: inset 3px 0 0 0 var(--brand-coral);
  color: var(--text);
}

/* Theme switch — injected next to the language menu by the plugin in
   index.html (icon shows the active theme, label shows its name). */
.app-nav .theme-toggle,
.sidebar nav .theme-toggle {
  align-items: center;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  gap: 6px;
  letter-spacing: 0.06em;
  line-height: 1.6;
  margin: 0;
  padding: 4px 14px;
  text-transform: uppercase;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.app-nav .theme-toggle:hover,
.sidebar nav .theme-toggle:hover {
  border-color: var(--link);
  color: var(--text);
}

.theme-toggle-icon {
  display: none;
  flex-shrink: 0;
  height: 14px;
  width: 14px;
}

html[data-theme='light'] .theme-toggle .icon-sun,
html[data-theme='dark'] .theme-toggle .icon-moon {
  display: inline-block;
}

/* ---------- Content ---------- */

.content {
  padding-top: 60px;
}

.markdown-section {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin: 28px auto;
  max-width: 880px;
  padding: 48px 56px 56px;
  width: calc(100% - 64px);
}

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4,
.markdown-section h5,
.markdown-section h6,
.markdown-section strong {
  color: var(--text);
  font-family: var(--font-heading);
  font-weight: 700;
}

.markdown-section h1 {
  font-size: 2em;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

/* Section headings get the coral → mint bar from the logo gradients. */
.markdown-section h2 {
  background: linear-gradient(to right, var(--brand-coral), var(--brand-mint));
  background-position: left bottom;
  background-repeat: no-repeat;
  background-size: 48px 3px;
  font-size: 1.75em;
  line-height: 1.25;
  margin: 56px 0 1rem;
  padding-bottom: 0.6rem;
}

.markdown-section h3 {
  font-size: 1.35em;
  margin: 40px 0 0.6rem;
}

.markdown-section h4 {
  font-size: 1.15em;
}

.markdown-section h5 {
  font-size: 1em;
}

.markdown-section h6 {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.markdown-section h2:first-child,
.markdown-section h3:first-child {
  margin-top: 0;
}

.markdown-section a {
  color: var(--link);
  font-weight: 600;
  text-decoration-color: transparent;
  transition: color 0.2s ease;
}

.markdown-section a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

/* docsify wraps heading text in a .anchor link; the vue theme (and the link
   rule above) would paint it with the link color — let headings keep their
   own color. */
.markdown-section .anchor,
.markdown-section .anchor:hover,
.markdown-section .anchor span {
  color: inherit;
}

.markdown-section hr {
  border: none;
  border-bottom: 1px solid var(--border);
  margin: 2.5em 0;
}

.markdown-section em {
  color: inherit;
}

.markdown-section blockquote {
  background-color: var(--surface-sunken);
  border-left: 4px solid var(--brand-coral);
  border-radius: 0 12px 12px 0;
  color: var(--text);
  margin: 2em 0;
  padding: 12px 24px;
}

.markdown-section blockquote p {
  font-weight: 400;
  margin-left: 0;
}

/* ---------- Lists ---------- */

.markdown-section ol,
.markdown-section ul {
  padding-left: 1.5rem;
}

.markdown-section li::marker {
  color: var(--brand-coral-deep);
}

/* ---------- Inline code & code blocks ---------- */

.markdown-section code,
.markdown-section output:after,
.markdown-section pre {
  font-family: var(--font-mono);
}

.markdown-section code {
  background-color: var(--surface-sunken);
  border-radius: 6px;
  color: var(--code-text);
  font-size: 0.85em;
  margin: 0;
  padding: 2px 6px;
  white-space: pre-wrap;
}

.markdown-section code:after,
.markdown-section code:before,
.markdown-section output:after,
.markdown-section output:before {
  content: none;
}

.markdown-section pre {
  background-color: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 12px;
  line-height: 1.6;
  margin: 1.2em 0;
  overflow: auto;
  padding: 2em 1.25em 1.25em;
}

.markdown-section pre > code {
  background-color: transparent;
  border-radius: 0;
  color: var(--text);
  display: block;
  font-size: 0.85em;
  margin: 0;
  max-width: inherit;
  overflow: inherit;
  padding: 0;
  white-space: inherit;
}

.markdown-section output:after,
.markdown-section pre:after {
  color: var(--text-muted);
  content: attr(data-lang);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 8px 12px 0 0;
  text-transform: uppercase;
}

/* Syntax tokens (only used for fenced blocks with a language). */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--text-muted);
}

.token.punctuation,
.token.property {
  color: var(--text);
}

.token.string,
.token.attr-value {
  color: var(--brand-mint-deep);
}

.token.number,
.token.boolean,
.token.keyword,
.token.function {
  color: var(--code-text);
}

.token.tag,
.token.attr-name,
.token.selector {
  color: var(--link);
}

html[data-theme='dark'] .token.string,
html[data-theme='dark'] .token.attr-value {
  color: var(--brand-mint);
}

html[data-theme='dark'] .token.number,
html[data-theme='dark'] .token.boolean,
html[data-theme='dark'] .token.keyword,
html[data-theme='dark'] .token.function {
  color: var(--code-text);
}

html[data-theme='dark'] .token.tag,
html[data-theme='dark'] .token.attr-name,
html[data-theme='dark'] .token.selector {
  color: var(--link-hover);
}

/* ---------- Tables ---------- */

.markdown-section table {
  border: 1px solid var(--border);
  border-collapse: separate;
  border-radius: 12px;
  border-spacing: 0;
  display: table;
  margin: 1.5em 0;
  width: 100%;
}

.markdown-section th {
  background-color: var(--surface-sunken);
  color: var(--text);
  font-family: var(--font-heading);
  font-weight: 700;
}

.markdown-section td,
.markdown-section th {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  text-align: left;
}

.markdown-section tr {
  border-top: none;
}

.markdown-section tr:last-child td {
  border-bottom: none;
}

/* Zebra rows (vue.css paints them #f8f8f8). */
.markdown-section tr:nth-child(2n) {
  background-color: var(--surface-sunken);
}

/* ---------- Tips & warnings ---------- */

/* docsify's `!>` becomes p.tip, `?>` becomes p.warn — styled here as the
   brand's mint "note" and coral "attention" callouts. */
.markdown-section p.tip {
  background-color: rgba(150, 201, 168, 0.14);
  border-left: 4px solid var(--brand-mint-deep);
  border-radius: 0 12px 12px 0;
  color: var(--text);
  margin: 2em 0;
  padding: 14px 24px 14px 30px;
}

.markdown-section p.tip:before {
  background-color: var(--brand-coral);
  border-radius: 100%;
  color: var(--brand-blue);
  content: '!';
  font-family: var(--font-heading);
}

.markdown-section p.tip code {
  background-color: rgba(255, 255, 255, 0.5);
}

.markdown-section p.tip em {
  color: var(--text);
}

.markdown-section p.warn {
  background-color: rgba(255, 155, 130, 0.14);
  border-left: 4px solid var(--brand-coral-deep);
  border-radius: 0 12px 12px 0;
  color: var(--text);
  margin: 2em 0;
  padding: 14px 24px;
}

html[data-theme='dark'] .markdown-section p.tip {
  background-color: rgba(150, 201, 168, 0.1);
  border-left-color: var(--brand-mint);
}

html[data-theme='dark'] .markdown-section p.tip:before {
  color: var(--brand-blue);
}

html[data-theme='dark'] .markdown-section p.tip code {
  background-color: rgba(255, 255, 255, 0.08);
}

html[data-theme='dark'] .markdown-section p.warn {
  background-color: rgba(255, 155, 130, 0.1);
  border-left-color: var(--brand-coral);
}

/* ---------- Loading progress & sidebar toggle ---------- */

.progress {
  background-color: var(--brand-coral);
}

.sidebar-toggle {
  background-color: transparent;
}

.sidebar-toggle span {
  background-color: var(--brand-coral-deep);
}

.sidebar-toggle:hover .sidebar-toggle-button {
  opacity: 0.6;
}

html[data-theme='dark'] .sidebar-toggle span {
  background-color: var(--brand-coral);
}

@media screen and (max-width: 768px) {
  /* Wide tables scroll inside their frame instead of breaking the card. */
  .markdown-section table {
    display: block;
    overflow: auto;
  }

  .markdown-section {
    margin: 16px auto;
    max-width: calc(100vw - 32px);
    padding: 32px 24px 40px;
  }

  .app-nav {
    margin: 16px 16px 0 0;
  }

  body.close .sidebar-toggle {
    background-color: var(--bg);
    transition: none;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
