/*
 * Quark 2 — Helios-style fidelity overrides (v6)
 * Original implementation. This file intentionally contains only our overrides.
 */

:root,
:root[data-theme="light"] {
  --hd-sidebar-width: 282px;
  --hd-sidebar: #ffffff;
  --hd-sidebar-row-hover: #f4f4f5;
  --hd-sidebar-row-open: #f1f1f3;
  --hd-nav-active: #eef4ff;
  --hd-nav-active-text: #2f65d9;
  --hd-nav-line: #dedfe4;
  --hd-nav-icon: #858b97;
  --hd-nav-chevron: #7c828e;
  --hd-toggle-bg: #eeeeef;
  --hd-toggle-hover: #e2e2e5;
}

:root[data-theme="dark"] {
  --hd-bg: #18181b;
  --hd-sidebar: #18181b;
  --hd-surface: #1a1a1c;
  --hd-border: #2e2e33;
  --hd-border-strong: #3f3f46;
  --hd-text: #f4f4f5;
  --hd-muted: #d4d4d8;
  --hd-subtle: #9a9aa4;
  --hd-hover: #27272a;
  --hd-sidebar-row-hover: #222225;
  --hd-sidebar-row-open: #262629;
  --hd-nav-active: #1d2638;
  --hd-nav-active-text: #71a5ff;
  --hd-nav-line: #3f3f46;
  --hd-nav-icon: #8f8f99;
  --hd-nav-chevron: #b0b0b8;
  --hd-toggle-bg: #3b3b41;
  --hd-toggle-hover: #494950;
}

/* LEFT SIDEBAR ----------------------------------------------------------- */
.helios-sidebar {
  width: var(--hd-sidebar-width);
  background: var(--hd-sidebar);
}
.helios-stage { margin-left: var(--hd-sidebar-width); }

/* Version selector was intentionally removed from the sidebar in v6. */
.helios-sidebar-head {
  min-height: 62px;
  height: 62px;
  flex: 0 0 62px;
  display: flex;
  align-items: center;
  padding: 0 14px;
}
.helios-brand-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}
.helios-version-wrap { display: none !important; }

.helios-tree { padding: 8px 11px 28px; }
.helios-tree li { position: relative; margin: 2px 0; }
.helios-tree li > a {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 42px 8px 13px;
  border-radius: 7px;
  color: var(--hd-muted);
  font-size: 15px;
  font-weight: 480;
  line-height: 1.35;
  text-decoration: none;
}
.helios-tree li > a:hover {
  background: var(--hd-sidebar-row-hover);
  color: var(--hd-text);
  text-decoration: none;
}
.helios-tree li > a.active {
  background: var(--hd-nav-active);
  color: var(--hd-nav-active-text);
  font-weight: 540;
}
/* Parent of the current child is neutral gray, like the original docs tree. */
.helios-tree li.active-branch > a {
  background: var(--hd-sidebar-row-open);
  color: var(--hd-text);
  font-weight: 520;
}
.helios-tree li.active-branch > a:hover { background: var(--hd-sidebar-row-open); }

.helios-nav-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  display: inline-grid;
  place-items: center;
  color: var(--hd-nav-icon);
}
.helios-nav-icon svg { width: 19px; height: 19px; display: block; }
.helios-tree li > a:hover .helios-nav-icon,
.helios-tree li.active-branch > a .helios-nav-icon,
.helios-tree li > a.active .helios-nav-icon { color: currentColor; opacity: .88; }
.helios-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The icon stays on the left. The chevron is a separate neutral button on the RIGHT. */
.helios-tree-toggle {
  position: absolute;
  z-index: 6;
  top: 3px;
  right: 3px;
  left: auto !important;
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--hd-nav-chevron);
  box-shadow: none;
  cursor: pointer;
}
.helios-tree-toggle:hover { background: var(--hd-toggle-bg); color: var(--hd-text); }
.helios-tree li.active-branch > .helios-tree-toggle,
.helios-tree li.current-page > .helios-tree-toggle {
  background: var(--hd-toggle-bg);
  color: var(--hd-nav-chevron);
}
.helios-tree li.active-branch > .helios-tree-toggle:hover,
.helios-tree li.current-page > .helios-tree-toggle:hover { background: var(--hd-toggle-hover); }
.helios-tree-toggle svg {
  width: 16px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(0deg);
  transform-origin: center;
  transition: transform .15s ease;
}
.helios-tree li.tree-open > .helios-tree-toggle svg { transform: rotate(90deg); }

.helios-tree li.has-children > ul {
  position: relative !important;
  margin: 2px 0 8px 16px !important;
  padding: 0 0 0 9px !important;
  border-left: 1px solid var(--hd-nav-line) !important;
}
.helios-tree li.has-children > ul::before { display: none !important; }
.helios-tree li li { margin: 1px 0; }
.helios-tree li li > a {
  min-height: 36px;
  gap: 0;
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--hd-muted);
  font-size: 15px;
  font-weight: 450;
}
.helios-tree li li > a.active {
  background: var(--hd-nav-active);
  color: var(--hd-nav-active-text);
  font-weight: 520;
}
.helios-tree > ul > li:not(.has-children) + li.has-children {
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}
.helios-tree > ul > li:not(.has-children) + li.has-children > .helios-tree-toggle { top: 3px; }

/* Copyright sits where Powered by Grav used to be. */
.helios-sidebar-foot {
  margin-top: auto;
  flex: 0 0 auto;
  display: block !important;
  padding: 14px 14px 15px;
  border-top: 1px solid var(--hd-border);
  color: var(--hd-subtle);
  font-size: 10.5px;
  font-weight: 450;
  line-height: 1.45;
}
.helios-sidebar-copyright { display: block; }

/* TOP BAR ---------------------------------------------------------------- */
.helios-topbar {
  min-height: 62px;
  height: 62px;
  padding: 0 22px 0 30px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--hd-border);
  background: color-mix(in srgb, var(--hd-bg) 97%, transparent);
}
.helios-topbar-context { flex: 1 1 auto; min-width: 0; }
.helios-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, #22c55e 12%, transparent);
  color: #22c55e;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}
.helios-version-badge small { font-size: 11px; font-weight: 650; }

.helios-topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.helios-top-links {
  display: flex;
  align-items: center;
  gap: 28px;
  margin: 0;
  padding: 0;
}
.helios-top-links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--hd-muted);
  font-size: 14px;
  font-weight: 450;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.helios-top-links a:hover { color: var(--hd-text); text-decoration: none; }

.helios-search-trigger {
  height: 36px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0 9px 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--hd-hover);
  color: var(--hd-muted);
  box-shadow: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 450;
  cursor: pointer;
  white-space: nowrap;
}
.helios-search-trigger:hover { background: color-mix(in srgb, var(--hd-hover) 76%, var(--hd-border)); color: var(--hd-text); }
.helios-search-trigger > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.helios-search-keys { display: inline-flex; align-items: center; gap: 3px; }
.helios-search-trigger kbd {
  min-width: 23px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border: 0;
  border-radius: 5px;
  background: color-mix(in srgb, var(--hd-border-strong) 58%, transparent);
  color: var(--hd-muted);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, #000 14%, transparent);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* Three-state appearance capsule: light / system / dark. */
.helios-topbar .theme-toggle.helios-appearance-toggle {
  position: relative;
  width: auto;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 999px;
  background: var(--hd-hover);
  color: var(--hd-muted);
  box-shadow: none;
}
.helios-appearance-toggle .theme-toggle-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hd-subtle);
  box-shadow: none;
  cursor: pointer;
}
.helios-appearance-toggle .theme-toggle-btn:hover { color: var(--hd-text); }
.helios-appearance-toggle .theme-toggle-btn.theme-toggle-btn-active {
  background: color-mix(in srgb, var(--hd-border-strong) 80%, var(--hd-bg));
  color: var(--hd-text);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.helios-appearance-toggle .theme-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* BREADCRUMBS ------------------------------------------------------------ */
.helios-breadcrumbs {
  margin: -5px 0 24px;
}
.helios-breadcrumbs .breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--hd-subtle);
  font-size: 12.5px;
  line-height: 1.5;
}
.helios-breadcrumbs .breadcrumbs li { display: flex; align-items: center; }
.helios-breadcrumbs .breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin: 0 8px;
  color: var(--hd-border-strong);
}
.helios-breadcrumbs .breadcrumbs a { color: var(--hd-muted); text-decoration: none; }
.helios-breadcrumbs .breadcrumbs a:hover { color: var(--hd-text); }
.helios-breadcrumbs .breadcrumbs li[aria-current="page"] { color: var(--hd-text); }

/* RIGHT: ON THIS PAGE ---------------------------------------------------- */
.helios-toc-inner { padding-left: 18px; }
.helios-toc-title {
  margin-bottom: 13px;
  color: var(--hd-text);
  font-size: 14px !important;
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: .01em;
}
.helios-toc nav { gap: 1px; }
.helios-toc-link {
  display: block;
  padding: 5px 0 !important;
  color: var(--hd-subtle);
  font-size: 14px !important;
  font-weight: 450;
  line-height: 1.45 !important;
  text-decoration: none;
}
.helios-toc-link:hover,
.helios-toc-link.active { color: var(--hd-active-text); }
.helios-toc-link.level-h3 { padding-left: 10px !important; }

/* SEARCH FALLBACK -------------------------------------------------------- */
.helios-search-box-fallback {
  width: 100%;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--hd-text);
  box-shadow: none;
  font: inherit;
  font-size: 15px;
}
.helios-fallback-results {
  display: none;
  max-height: 360px;
  overflow: auto;
  border-top: 1px solid var(--hd-border);
  padding: 8px;
}
.helios-fallback-results.has-results { display: block; }
.helios-fallback-result {
  display: block;
  padding: 9px 11px;
  border-radius: 7px;
  color: var(--hd-muted);
  font-size: 13px;
  text-decoration: none;
}
.helios-fallback-result:hover { background: var(--hd-hover); color: var(--hd-text); text-decoration: none; }
.helios-fallback-empty { padding: 12px; color: var(--hd-subtle); font-size: 12px; }

/* PAGE MEDIA ------------------------------------------------------------- */
.helios-auto-page-image { margin: 0 0 1.6rem; }
.helios-auto-page-image img,
.helios-article-body img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 0;
  border-radius: 8px;
  opacity: 1;
  visibility: visible;
}

/* BACK TO TOP ------------------------------------------------------------ */
.helios-floating-top {
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  background: rgba(63,63,70,.72);
  color: #a1a1aa;
  box-shadow: none;
  opacity: 0;
  transform: translateY(8px);
  backdrop-filter: blur(4px);
}
:root[data-theme="light"] .helios-floating-top { background: rgba(228,228,231,.92); color: #71717a; }
.helios-floating-top:hover { background: rgba(82,82,91,.84); color: #d4d4d8; transform: translateY(-1px); }
:root[data-theme="light"] .helios-floating-top:hover { background: rgba(212,212,216,.96); color: #52525b; }
.helios-floating-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.helios-floating-top svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Copyright no longer appears under article content. */
.helios-content-footer { display: none !important; }

@media (max-width: 1180px) {
  .helios-top-links { gap: 18px; }
  .helios-top-links a { font-size: 13px; }
  .helios-topbar-actions { gap: 10px; }
}

@media (max-width: 960px) {
  .helios-sidebar { width: min(88vw, 282px); }
  .helios-stage { margin-left: 0; }
  .helios-version-badge,
  .helios-top-links { display: none; }
  .helios-topbar { padding-inline: 14px; }
  .helios-topbar-actions { margin-left: auto; gap: 8px; }
  .helios-search-trigger > span:not(.helios-search-keys),
  .helios-search-keys { display: none; }
  .helios-search-trigger { width: 36px; padding: 0; }
  .helios-floating-top { width: 50px; height: 50px; right: 16px; bottom: 16px; }
}

.helios-brand-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.helios-brand-title img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    flex-shrink: 0;
}

.helios-brand-title span {
    display: block;
}