/* Feature styles on top of assets/theme.css.
 * Keep theme.css + site.css identical across SandustryModTemplate and SandustryTypes. */
:root {
  --sidebar-toggle-height: 40px;
  --sidebar-toggle-margin-block: 0;
  --sidebar-toggle-width: 36px;
  --sidebar-toggle-alignment: flex-start;
}

/* Hide Docsify GitHub corner if a repo option is re-added later. */
.github-corner {
  display: none !important;
}

#smt-page-toc {
  display: none;
}
.smt-page-toc-title {
  margin: 0 0 0.5rem 0;
  font-size: var(--font-size-xs, 0.75rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--theme-color);
}
#smt-page-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
#smt-page-toc ul ul {
  padding-left: 0.75rem;
  margin-top: 0.25rem;
}
#smt-page-toc li {
  margin: 0.35em 0;
}
#smt-page-toc a {
  color: var(--sidebar-link-color, var(--color-text));
  text-decoration: none;
  display: block;
}
#smt-page-toc a:hover {
  color: var(--sidebar-link-color-active, var(--theme-color));
}
#smt-page-toc a.smt-page-toc-active {
  color: var(--sidebar-link-color-active, var(--theme-color));
  font-weight: 600;
}
/* Active page link only — not nested children under an active parent. */
.sidebar-nav li.active > a.page-link,
.sidebar-nav li.active > p > a.page-link {
  color: var(--sidebar-link-color-active, var(--theme-color));
}
.sidebar-nav li.active ul a.page-link {
  color: var(--sidebar-link-color, var(--color-text));
}
.sidebar-nav li.active ul li.active > a.page-link,
.sidebar-nav li.active ul li.active > p > a.page-link {
  color: var(--sidebar-link-color-active, var(--theme-color));
}
.sidebar-toggle,
.sidebar-toggle:hover,
.sidebar-toggle:focus,
.sidebar-toggle:focus-visible,
.sidebar-toggle:active {
  border: 0 !important;
  box-shadow: none !important;
  filter: none !important;
  outline: none !important;
  background: transparent !important;
}
.sidebar-toggle {
  padding: max(0.65rem, env(safe-area-inset-top, 0px)) 0 0 0;
  box-sizing: border-box;
}
.sidebar-toggle .sidebar-toggle-button {
  color: var(--sidebar-toggle-color, var(--sidebar-link-color, var(--color-text)));
  border: 0;
  border-radius: 0;
  outline: none;
  background: var(--sidebar-bg, var(--color-bg));
}
.sidebar-toggle .sidebar-toggle-button .smt-sidebar-toggle-icon {
  display: block;
  transform: rotate(0deg);
  transform-origin: center;
  transition: transform var(--duration-medium, 250ms) ease;
}
body:has(.sidebar.show) .sidebar-toggle .smt-sidebar-toggle-icon {
  transform: rotate(180deg);
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-toggle .sidebar-toggle-button .smt-sidebar-toggle-icon {
    transition: none;
  }
}
.sidebar-toggle .sidebar-toggle-button:focus-visible {
  outline: 2px solid var(--border-color, rgba(0, 0, 0, 0.22));
  outline-offset: 2px;
  box-shadow: none;
}
.sidebar-toggle .sidebar-toggle-button:focus:not(:focus-visible) {
  outline: none;
}
@media screen and (any-hover) {
  body:where(:has(.sidebar-toggle:hover)) .sidebar-toggle-button:not(:hover) {
    color: var(--sidebar-toggle-color, var(--sidebar-link-color, var(--color-text)));
    background: var(--sidebar-bg, var(--color-bg));
  }
  .sidebar-toggle .sidebar-toggle-button:hover {
    color: var(--sidebar-link-color, var(--color-text));
    background: color-mix(in srgb, var(--color-text, #333) 8%, var(--sidebar-bg, var(--color-bg)));
    outline: none;
    box-shadow: none;
  }
  .sidebar-toggle .sidebar-toggle-button:active {
    background: color-mix(in srgb, var(--color-text, #333) 14%, var(--sidebar-bg, var(--color-bg)));
    outline: none;
  }
}
#smt-drawer-scrim {
  display: none;
}
@media screen and (max-width: 640px) {
  #smt-drawer-scrim {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--sidebar-width);
    z-index: 45;
    background: transparent;
    cursor: pointer;
  }
  body.smt-drawer-open .sidebar {
    padding-top: calc(
      max(0.65rem, env(safe-area-inset-top, 0px)) + var(--sidebar-toggle-height, 40px) + 0.4rem
    );
  }
  body.smt-drawer-open .sidebar-toggle {
    position: fixed;
    left: max(0px, env(safe-area-inset-left, 0px));
    top: calc(max(0.65rem, env(safe-area-inset-top, 0px)));
    right: auto;
    bottom: auto;
    width: auto !important;
    height: auto;
    padding: 0;
    translate: none !important;
    z-index: 61;
    align-items: flex-start;
    animation: smt-drawer-close-btn-in var(--duration-medium, 250ms) ease forwards;
  }
}
@keyframes smt-drawer-close-btn-in {
  from {
    transform: translateX(calc(0px - var(--sidebar-width)));
  }
  to {
    transform: translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  body.smt-drawer-open .sidebar-toggle {
    animation: none !important;
    transform: none !important;
  }
}
@media (min-width: 1100px) {
  /* Reserve space: TOC is position fixed (Docsify's absolute .content breaks sticky). */
  main > .content .markdown-section {
    padding-right: 13.5rem;
    box-sizing: border-box;
  }
  #smt-page-toc {
    display: block;
    position: fixed;
    top: calc(var(--navbar-height, 4em) + 0.75rem);
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    width: 12rem;
    max-height: calc(100vh - var(--navbar-height, 4em) - 2rem);
    overflow-y: auto;
    z-index: 45;
    font-size: var(--font-size-s, 0.875rem);
    line-height: 1.35;
    padding-left: 1rem;
    box-sizing: border-box;
    border-left: 1px solid var(--border-color, #ddd);
    background: var(--color-bg, #fff);
  }
  .markdown-section :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: calc(var(--navbar-height, 4em) + 0.75rem);
  }
}

/* Sidebar body: keep nested links at the same size (Docsify can shrink them). */
.sidebar-nav ul ul {
  font-size: inherit;
}
.sidebar-nav a {
  font-size: inherit;
}
.sidebar-nav a[target="_blank"]::after,
.markdown-section a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.85em;
  opacity: 0.7;
}

/* Group titles only (plain text). Top-level page links also wrap in <p>. */
.sidebar-nav > ul > li > p:not(:has(a)) {
  margin: 1.1em 0 0.35em;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--theme-color);
}

/* Prose links: no underline (matches SandustryTypes). */
.markdown-section :not(pre) a:not(.button):not(.anchor) {
  color: var(--link-color, var(--theme-color));
  text-decoration: none;
}
@media screen and (any-hover) {
  .markdown-section :not(pre) a:not(.button):not(.anchor):hover {
    color: var(--theme-color);
    text-decoration: none;
  }
}

/* Heading permalink: icon sits next to title (not full-width space-between). */
.markdown-section :is(h1, h2, h3, h4, h5, h6).smt-heading-with-anchor {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 0.35em;
  overflow: visible;
}
.markdown-section .smt-heading-text {
  flex: 0 1 auto;
  min-width: 0;
}
.markdown-section .smt-heading-copy {
  position: relative;
  overflow: visible;
  box-sizing: border-box;
  flex-shrink: 0;
  margin: 0;
  padding: 0.2rem;
  border: 0;
  border-radius: var(--border-radius, 3px);
  background: transparent;
  color: color-mix(in srgb, var(--heading-color, var(--strong-color)) 55%, var(--theme-color) 45%);
  cursor: pointer;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--duration-fast, 150ms) ease,
    color var(--duration-fast, 150ms) ease,
    background var(--duration-fast, 150ms) ease;
}
@media (hover: none) {
  .markdown-section .smt-heading-copy {
    opacity: 0.55;
    pointer-events: auto;
  }
}
.markdown-section .smt-heading-copy.smt-heading-copy-feedback {
  opacity: 1;
  pointer-events: auto;
}
.markdown-section .smt-heading-copy,
.markdown-section .smt-heading-copy * {
  cursor: pointer;
}
.markdown-section .smt-heading-copy-icon {
  display: block;
  flex-shrink: 0;
  shape-rendering: geometricPrecision;
}
.markdown-section :is(h1, h2, h3, h4, h5, h6).smt-heading-with-anchor:hover .smt-heading-copy,
.markdown-section
  :is(h1, h2, h3, h4, h5, h6).smt-heading-with-anchor:focus-within
  .smt-heading-copy {
  opacity: 0.55;
  pointer-events: auto;
}
.markdown-section :is(h1, h2, h3, h4, h5, h6).smt-heading-with-anchor:hover .smt-heading-copy:hover,
.markdown-section
  :is(h1, h2, h3, h4, h5, h6).smt-heading-with-anchor:focus-within
  .smt-heading-copy:hover {
  opacity: 1;
  color: var(--theme-color);
  background: color-mix(in srgb, var(--theme-color) 14%, var(--color-bg, #fff));
}
.markdown-section .smt-heading-copy:active {
  background: color-mix(in srgb, var(--theme-color) 22%, var(--color-bg, #fff));
  opacity: 1;
}
.markdown-section .smt-heading-copy:focus-visible {
  outline: 2px solid var(--border-color, rgba(0, 0, 0, 0.22));
  outline-offset: 2px;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .markdown-section .smt-heading-copy {
    transition: none;
  }
}

/* "Copied" tooltip: absolutely positioned above the copy button (child of button). */
.smt-heading-copy-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  z-index: 20;
  box-sizing: border-box;
  margin: 0;
  padding: 0.35em 0.65em;
  font-family: var(--font-family, system-ui, sans-serif);
  font-size: var(--font-size-xs, 12px);
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-bg, #fff);
  background: color-mix(in srgb, var(--color-text, #222) 88%, var(--color-bg, #fff) 12%);
  border-radius: var(--border-radius, 4px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  opacity: 0;
  animation: smt-heading-copy-tooltip 2.1s ease forwards;
}
@media (prefers-reduced-motion: reduce) {
  .smt-heading-copy-tooltip {
    animation: smt-heading-copy-tooltip-rm 1.6s ease forwards;
  }
}
@keyframes smt-heading-copy-tooltip {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  10% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  70% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }
}
/* TypeDoc API signatures (blockquote → ```ts fences in docs:api output). */
.markdown-section :is(h3, h4, h5, h6) + pre:has(> code.language-ts) {
  margin-top: 0.35rem;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--blockquote-bg, var(--code-inline-bg));
  border-left: 3px solid var(--theme-color);
  border-radius: 0 4px 4px 0;
  overflow-x: auto;
}

.markdown-section :is(h3, h4, h5, h6) + pre:has(> code.language-ts) code {
  background: transparent;
  padding: 0;
  font-size: 0.9em;
  white-space: pre-wrap;
  word-break: break-word;
}

@keyframes smt-heading-copy-tooltip-rm {
  0% {
    opacity: 0;
    transform: translateX(-50%);
  }
  12% {
    opacity: 1;
    transform: translateX(-50%);
  }
  78% {
    opacity: 1;
    transform: translateX(-50%);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%);
  }
}

/* Tables: Docsify stripes tr:nth-child(2n); with thead/tbody the header and first body row are both odd and look identical. */
.markdown-section thead th {
  background: var(--table-header-bg);
  border-bottom-width: 2px;
}
.markdown-section thead tr:nth-child(2n) {
  background: var(--table-header-bg);
}
.markdown-section tbody tr:nth-child(odd) {
  background: transparent;
}
.markdown-section tbody tr:nth-child(2n) {
  background: var(--table-row-alt-bg);
}

/* Doc screenshots and figures */
.markdown-section img {
  display: block;
  max-width: min(100%, 42rem);
  height: auto;
  margin-block: 1rem;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.18));
  border-radius: 6px;
}

.search .results-panel {
  max-height: min(60vh, 28rem);
  overflow: auto;
}

.search .matching-post .title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

/* Search field: fill the input row (Docsify default leaves unused vertical space). */
.search .input-wrap {
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  min-height: 2.75rem;
}

.search input[type="search"] {
  box-sizing: border-box;
  flex: 1 1 auto;
  align-self: stretch;
  height: auto;
  min-height: 2.75rem;
  margin: 0;
  padding-block: 0.65rem;
  padding-inline: 0.75rem 2.5rem;
  line-height: 1.35;
  font-size: 1rem;
}

.search .clear-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  height: auto;
  min-height: 2.75rem;
}

/* Sandkit API module index: grouped namespace chips. */
.smt-api-landing {
  line-height: 1.6;
}

.smt-api-landing h1 {
  margin-block: 0 0.55em;
}

.smt-api-landing h2 {
  margin-block: 1.5em 0.55em;
}

.smt-api-landing h3 {
  margin-block: 1.1em 0.4em;
  font-weight: 600;
  color: var(--heading-color, var(--color-text));
}

.smt-api-landing > p {
  margin-block: 0 1em;
}

.smt-api-landing > ul {
  line-height: 1.75;
  margin-block: 0.35em 1.1em;
}

.smt-api-landing > ul > li {
  margin-block: 0.28em;
}

.smt-api-landing ul.smt-api-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  align-items: start;
  gap: 0.35rem 1.25rem;
  list-style: none;
  margin: 0 0 1.15em;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.14));
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-text, #333) 4%, var(--color-bg, #fff));
  line-height: 1.5;
}

.smt-api-landing ul.smt-api-group > li {
  margin: 0;
  padding: 0.18rem 0;
}

.smt-api-landing ul.smt-api-group > li > a {
  font-weight: 600;
}

.smt-api-landing ul.smt-api-tree {
  list-style: none;
  margin: 0.05rem 0 0.15rem;
  padding: 0 0 0 0.15rem;
}

.smt-api-landing ul.smt-api-tree li {
  position: relative;
  margin: 0;
  padding: 0.02rem 0 0.02rem 0.95rem;
}

.smt-api-landing ul.smt-api-tree li::before,
.smt-api-landing ul.smt-api-tree li::after {
  content: "";
  position: absolute;
  background: color-mix(in srgb, var(--color-text, #ddd) 38%, transparent);
  pointer-events: none;
}

/* Vertical stem */
.smt-api-landing ul.smt-api-tree li::after {
  left: 0.28rem;
  top: 0;
  bottom: 0;
  width: 1px;
}

/* Horizontal elbow */
.smt-api-landing ul.smt-api-tree li::before {
  left: 0.28rem;
  top: 0.78em;
  width: 0.55rem;
  height: 1px;
}

/* Last child: stem stops at the elbow */
.smt-api-landing ul.smt-api-tree li:last-child::after {
  bottom: auto;
  height: 0.78em;
}

.smt-api-landing ul.smt-api-tree a {
  font-weight: 500;
}
