/* Tayon Help — theme
   Accent tracks the app's primary blue (#3085d6). Everything is driven by
   custom properties so dark mode is a single block of overrides. */

:root {
  --accent: #2b7fd0;
  --accent-hover: #1f66ad;
  --accent-soft: #e8f1fb;
  --accent-ring: rgba(43, 127, 208, 0.35);

  --bg: #ffffff;
  --bg-alt: #f6f8fb;
  --bg-sunken: #eef2f7;
  --surface: #ffffff;
  --border: #dfe5ec;
  --border-strong: #c6d0dc;

  --text: #16202b;
  --text-muted: #5c6b7a;
  --text-faint: #8593a2;

  --warn-bg: #fff6e6;
  --warn-border: #f0c169;
  --warn-text: #7a5312;
  --note-bg: #eef4fb;
  --note-border: #9dc2e8;
  --note-text: #1d4c78;
  --tip-bg: #ecf8f0;
  --tip-border: #8fcea8;
  --tip-text: #1e6236;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);

  --sidebar-w: 272px;
  --toc-w: 220px;
  --topbar-h: 56px;
  --content-max: 780px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --accent: #59a5f0;
  --accent-hover: #7cbaf5;
  --accent-soft: #16283c;
  --accent-ring: rgba(89, 165, 240, 0.4);

  --bg: #0f151c;
  --bg-alt: #141b24;
  --bg-sunken: #0b1017;
  --surface: #171f29;
  --border: #263241;
  --border-strong: #35455a;

  --text: #e6edf5;
  --text-muted: #9fb0c2;
  --text-faint: #74869a;

  --warn-bg: #2c2312;
  --warn-border: #7a5c1f;
  --warn-text: #f0cd8a;
  --note-bg: #14243a;
  --note-border: #2c5580;
  --note-text: #a9cdf2;
  --tip-bg: #11291c;
  --tip-border: #2c5d3c;
  --tip-text: #9adcb4;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
}

/* ------------------------------------------------------------ base */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

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

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

img, video { max-width: 100%; height: auto; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8;
      stroke-linecap: round; stroke-linejoin: round; }

kbd {
  font-family: var(--font); font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px; color: var(--text-muted); background: var(--bg-alt);
  white-space: nowrap;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

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

/* A class rule with `display` beats the UA stylesheet's [hidden] rule, so make
   the attribute win explicitly. Without this the search overlay is visible on
   load. */
[hidden] { display: none !important; }

.muted { color: var(--text-muted); }

/* ------------------------------------------------------------ topbar */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(135deg, var(--accent), #7c5cf0);
}
.brand-text { white-space: nowrap; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-alt); color: var(--text); }

.menu-btn { display: none; }

.search-wrap { flex: 1; display: flex; justify-content: center; }

.search-trigger {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 420px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-alt); color: var(--text-faint);
  font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger span { flex: 1; }
.search-trigger kbd { flex: none; }

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.lang-menu { position: relative; }
.lang-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 150px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.lang-dropdown a {
  display: block; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px;
}
.lang-dropdown a:hover { background: var(--bg-alt); text-decoration: none; }
.lang-dropdown a[aria-current] { color: var(--accent); font-weight: 600; }

[data-theme="dark"] .icon-light, .icon-dark { display: none; }
[data-theme="dark"] .icon-dark { display: inline-flex; }
.icon-light { display: inline-flex; }

/* ------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1440px; margin: 0 auto;
  align-items: start;
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 12px 48px 20px;
  border-right: 1px solid var(--border);
}

.nav-tree, .nav-articles { list-style: none; margin: 0; padding: 0; }
.nav-cat { margin-bottom: 4px; }

.nav-cat-title {
  display: block; padding: 6px 10px;
  font-size: 13px; font-weight: 650; letter-spacing: .01em;
  color: var(--text); border-radius: var(--radius-sm);
}
.nav-cat-title:hover { background: var(--bg-alt); text-decoration: none; }

.nav-articles { margin: 2px 0 10px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-articles a {
  display: block; padding: 5px 10px; margin-left: -1px;
  font-size: 14px; color: var(--text-muted);
  border-left: 2px solid transparent; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.nav-articles a:hover { color: var(--text); background: var(--bg-alt); text-decoration: none; }
.nav-articles a[aria-current="page"] {
  color: var(--accent); font-weight: 600;
  border-left-color: var(--accent); background: var(--accent-soft);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 40px;
  padding: 32px 32px 80px;
}
.content-wide { grid-template-columns: minmax(0, 1fr); }

.article { min-width: 0; max-width: var(--content-max); }

/* ------------------------------------------------------------ article */

.breadcrumbs ol {
  list-style: none; display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 18px; padding: 0; font-size: 13px; color: var(--text-muted);
}
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--text-faint); }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs [aria-current] { color: var(--text); }

.article-head { margin-bottom: 28px; }
.article-head h1 { margin: 0 0 10px; font-size: 34px; line-height: 1.2; letter-spacing: -.02em; }
.lede { margin: 0 0 14px; font-size: 18px; color: var(--text-muted); line-height: 1.55; }

.plan-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.plan-badge {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-ring);
}

.prereq {
  margin: 0; padding: 10px 14px; font-size: 14.5px;
  background: var(--bg-alt); border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.stale-note {
  margin: 12px 0 0; padding: 8px 12px; font-size: 13.5px;
  background: var(--warn-bg); color: var(--warn-text);
  border: 1px solid var(--warn-border); border-radius: var(--radius-sm);
}

.prose > *:first-child { margin-top: 0; }
.prose h2 {
  margin: 44px 0 14px; padding-top: 4px;
  font-size: 24px; line-height: 1.3; letter-spacing: -.01em;
}
.prose h3 { margin: 30px 0 10px; font-size: 18.5px; line-height: 1.4; }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose li { margin-bottom: 6px; }
.prose li > ul, .prose li > ol { margin-top: 6px; }

.prose strong { font-weight: 650; color: var(--text); }

.prose code {
  font-family: var(--font-mono); font-size: .88em;
  padding: 2px 5px; border-radius: 4px;
  background: var(--bg-sunken); border: 1px solid var(--border);
}
.prose pre {
  margin: 0 0 20px; padding: 14px 16px; overflow-x: auto;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13.5px; line-height: 1.55;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; }

.prose blockquote {
  margin: 0 0 20px; padding: 2px 0 2px 16px;
  border-left: 3px solid var(--border-strong); color: var(--text-muted);
}

.prose table {
  width: 100%; margin: 0 0 20px; border-collapse: collapse; font-size: 14.5px;
}
.prose thead th {
  text-align: left; font-weight: 650; padding: 9px 12px;
  border-bottom: 2px solid var(--border-strong); background: var(--bg-alt);
}
.prose tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: 0; }

/* Wide content scrolls inside its own box — the page never scrolls sideways. */
.table-scroll { overflow-x: auto; margin: 0 0 20px; }

.heading-anchor {
  margin-left: 8px; font-weight: 400; color: var(--text-faint);
  opacity: 0; transition: opacity .12s;
}
h2:hover .heading-anchor, h3:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; text-decoration: none; }

/* ------------------------------------------------------------ shortcodes */

.callout-box {
  margin: 0 0 20px; padding: 12px 16px;
  border: 1px solid; border-radius: var(--radius); font-size: 15px;
}
.callout-box > *:last-child { margin-bottom: 0; }
.callout-box-label {
  margin: 0 0 4px !important;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.callout-note { background: var(--note-bg); border-color: var(--note-border); }
.callout-note .callout-box-label { color: var(--note-text); }
.callout-warn { background: var(--warn-bg); border-color: var(--warn-border); }
.callout-warn .callout-box-label { color: var(--warn-text); }
.callout-tip  { background: var(--tip-bg);  border-color: var(--tip-border); }
.callout-tip .callout-box-label { color: var(--tip-text); }

.steps { margin: 0 0 20px; }
.steps ol { counter-reset: step; list-style: none; padding-left: 0; }
.steps ol > li {
  position: relative; margin-bottom: 14px; padding-left: 38px; counter-increment: step;
}
.steps ol > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--accent); color: #fff;
}

.ui-path { display: inline-flex; align-items: center; gap: 4px; vertical-align: baseline; }
.ui-chip {
  font-size: 13px; font-weight: 600; padding: 1px 7px; border-radius: 5px;
  background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text);
  white-space: nowrap;
}
.ui-sep { color: var(--text-faint); font-size: 12px; }

/* ------------------------------------------------------------ media */

figure.shot, figure.clip { margin: 24px 0; }

.shot-frame {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-alt); box-shadow: var(--shadow);
}
.shot-frame img, .shot-frame video { display: block; width: 100%; height: auto; }

/* Numbered badges are DOM, positioned from meta.json — never baked into pixels,
   so one screenshot serves every language. */
.callout {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 24px; height: 24px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; font-style: normal;
  color: #fff; background: #e5484d; border: 2px solid #fff; border-radius: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  pointer-events: none;
}

.callout-legend {
  counter-reset: legend; list-style: none;
  margin: 12px 0 0; padding: 0;
  display: grid; gap: 6px; font-size: 14.5px;
}
.callout-legend li { position: relative; padding-left: 30px; counter-increment: legend; }
.callout-legend li::before {
  content: counter(legend);
  position: absolute; left: 0; top: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; background: #e5484d;
}

figcaption {
  margin-top: 10px; font-size: 13.5px; color: var(--text-muted); text-align: center;
}

.shot-placeholder {
  aspect-ratio: 16 / 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-alt); color: var(--text-faint);
  font-size: 14px;
}
.shot-placeholder code { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ------------------------------------------------------------ toc */

.toc {
  position: sticky; top: calc(var(--topbar-h) + 32px);
  max-height: calc(100vh - var(--topbar-h) - 64px); overflow-y: auto;
  font-size: 13.5px;
}
.toc-title {
  margin: 0 0 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a {
  display: block; padding: 4px 0 4px 12px; margin-left: -1px;
  color: var(--text-muted); border-left: 2px solid transparent;
}
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc .toc-h3 a { padding-left: 24px; font-size: 13px; }

/* ------------------------------------------------------------ cards, pager */

.card-grid, .cat-grid, .related-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.article-card, .cat-card, .related-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
}
.article-card:hover, .cat-card:hover, .related-card:hover {
  border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none;
}
.article-card strong, .cat-card strong, .related-card strong { font-size: 15.5px; }
.article-card span, .cat-card span, .related-card span {
  font-size: 14px; color: var(--text-muted); line-height: 1.5;
}
.cat-card em { margin-top: 4px; font-size: 12.5px; font-style: normal; color: var(--text-faint); }

.related { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--border); }
.related h2 { margin: 0 0 14px; font-size: 19px; }

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border);
}
.pager-link {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-weight: 600; font-size: 15px;
}
.pager-link:hover { border-color: var(--accent); text-decoration: none; }
.pager-link small {
  display: block; font-size: 12px; font-weight: 500; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .05em;
}
.pager-next { justify-content: flex-end; text-align: right; }
.pager-link svg { flex: none; color: var(--text-faint); }

.updated { margin-top: 28px; font-size: 13px; color: var(--text-faint); }

.btn {
  display: inline-block; padding: 9px 18px;
  background: var(--accent); color: #fff; border-radius: var(--radius-sm); font-weight: 600;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }

/* ------------------------------------------------------------ home */

.home-hero { padding: 24px 0 36px; text-align: center; }
.home-hero h1 { font-size: 40px; margin: 0 0 10px; letter-spacing: -.025em; }
.home-hero .lede { font-size: 19px; }

.hero-search {
  display: inline-flex; align-items: center; gap: 10px;
  width: 100%; max-width: 520px; margin-top: 12px; padding: 13px 18px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 30px; box-shadow: var(--shadow);
  color: var(--text-faint); font: inherit; font-size: 15.5px; cursor: pointer;
}
.hero-search:hover { border-color: var(--accent); }

.home-heading { margin: 8px 0 16px; font-size: 20px; }
.page-home .article { max-width: 1000px; margin: 0 auto; }

/* ------------------------------------------------------------ search */

.search-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(15, 21, 28, .55); backdrop-filter: blur(3px);
}
.search-panel {
  width: 100%; max-width: 620px; max-height: 70vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}
.search-input-row input {
  flex: 1; border: 0; background: none; outline: none;
  font: inherit; font-size: 16.5px; color: var(--text);
}
.search-input-row input::-webkit-search-cancel-button { display: none; }

.search-results { overflow-y: auto; padding: 6px; }
.search-results:empty::after {
  content: attr(data-empty); display: block;
  padding: 28px 16px; text-align: center; font-size: 14px; color: var(--text-faint);
}
.search-hit {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text);
}
.search-hit:hover, .search-hit.is-active { background: var(--bg-alt); text-decoration: none; }
.search-hit strong { display: block; font-size: 15px; font-weight: 640; }
.search-hit .hit-cat {
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent);
}
.search-hit .hit-sum {
  display: block; font-size: 13.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-hit mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

.page-search .page-search input {
  width: 100%; padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.page-search #page-search-results { padding: 0; }
.page-search .search-hit { border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 4px; }

/* ------------------------------------------------------------ footer */

.site-footer {
  max-width: 1440px; margin: 0 auto;
  padding: 28px 32px 40px;
  border-top: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-muted);
}
.site-footer p { margin: 0 0 4px; }

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(15, 21, 28, .45);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1199px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 899px) {
  .menu-btn { display: inline-flex; }
  .brand-text { display: none; }

  .layout { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 38;
    width: min(300px, 84vw); max-height: none; height: calc(100dvh - var(--topbar-h));
    background: var(--bg);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  @media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

  .content { padding: 24px 18px 64px; }
  .article-head h1 { font-size: 27px; }
  .lede { font-size: 16.5px; }
  .home-hero h1 { font-size: 30px; }
  .pager { grid-template-columns: 1fr; }
  .site-footer { padding: 24px 18px 36px; }
  .search-trigger kbd { display: none; }
}

@media (max-width: 520px) {
  .search-overlay { padding: 0; }
  .search-panel { max-width: none; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .card-grid, .cat-grid, .related-grid { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .site-footer, .search-overlay, .scrim { display: none !important; }
  .layout, .content { display: block; }
  .article { max-width: none; }
}

.ui-line { margin: 0 0 16px; }
