/* Layout: Header + Sidebar + Content + TOC */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--doc-header-height) + 1rem);
}

body {
  font-family: var(--doc-font);
  font-weight: 300;
  font-size: 1rem;
  line-height: var(--doc-line-height);
  color: var(--doc-text);
  background-color: var(--doc-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Header ---- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--doc-header-height);
  background-color: var(--doc-primary-dark);
  border-bottom: 1px solid #283d43;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  z-index: 100;
}

.site-header .logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--doc-text-inverse);
  font-weight: 500;
  font-size: 1rem;
  white-space: nowrap;
}

.site-header .logo img {
  height: 28px;
  width: auto;
}

.site-header .logo span {
  opacity: 0.6;
  font-weight: 300;
  font-size: 0.8rem;
  margin-left: 0.25rem;
}

.header-search {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 2rem;
}

.header-search form {
  width: 100%;
  max-width: 400px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border: 1px solid #283d43;
  border-radius: var(--doc-radius);
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--doc-text-inverse);
  font-family: var(--doc-font);
  font-size: 0.85rem;
  font-weight: 300;
  outline: none;
  transition: background-color 0.2s, border-color 0.2s;
}

.header-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.header-search input:focus {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: var(--doc-accent);
}

.header-search .search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
  pointer-events: none;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--doc-text-inverse);
  font-size: 0.85rem;
  font-weight: 300;
  white-space: nowrap;
}

/* ---- Page Wrapper ---- */

.site-wrapper {
  display: flex;
  padding-top: var(--doc-header-height);
  min-height: 100vh;
}

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

.site-sidebar {
  position: fixed;
  top: var(--doc-header-height);
  left: 0;
  bottom: 0;
  width: var(--doc-sidebar-width);
  background-color: var(--doc-primary-dark);
  border-right: 1px solid #283d43;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0;
  z-index: 90;
}

.site-sidebar::-webkit-scrollbar {
  width: 4px;
}

.site-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.site-sidebar::-webkit-scrollbar-thumb {
  background: #283d43;
  border-radius: 2px;
}

/* Sidebar navigation */
.sidebar-nav .section-title {
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  padding: 1rem 1.25rem 0.4rem;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  margin: 0;
}

.sidebar-nav a {
  display: block;
  padding: 0.35rem 1.25rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 300;
  transition: background-color 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-nav .current-page > a,
.sidebar-nav .current_page_item > a {
  background-color: rgba(102, 240, 160, 0.1);
  color: var(--doc-accent);
  font-weight: 500;
  border-left-color: var(--doc-accent);
}

/* Child pages indent */
.sidebar-nav .children {
  padding-left: 0;
}

.sidebar-nav .children a {
  padding-left: 2rem;
  font-size: 0.825rem;
}

.sidebar-nav .children .children a {
  padding-left: 2.75rem;
  font-size: 0.8rem;
}

/* Collapse toggle */
.sidebar-nav .has-children > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-nav .toggle-children {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  cursor: pointer;
  transition: transform 0.2s;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.sidebar-nav .has-children.expanded > a .toggle-children {
  transform: rotate(90deg);
}

.sidebar-nav .has-children:not(.expanded) > .children {
  display: none;
}

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

.site-content {
  flex: 1;
  margin-left: var(--doc-sidebar-width);
  margin-right: var(--doc-toc-width);
  padding: 2rem 2.5rem;
  min-width: 0;
}

.content-wrapper {
  max-width: var(--doc-content-max-width);
  margin: 0 auto;
}

/* ---- TOC ---- */

.site-toc {
  position: fixed;
  top: var(--doc-header-height);
  right: 0;
  bottom: 0;
  width: var(--doc-toc-width);
  padding: 2rem 1rem 2rem 0;
  overflow-y: auto;
  font-size: 0.8rem;
}

.toc-title {
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--doc-text-muted);
  margin-bottom: 0.75rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.75rem;
  color: var(--doc-text-muted);
  text-decoration: none;
  font-weight: 300;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.toc-list a:hover {
  color: var(--doc-text);
}

.toc-list a.active {
  color: var(--doc-primary);
  border-left-color: var(--doc-primary);
  font-weight: 500;
}

/* TOC indent for h3, h4 */
.toc-list .toc-h3 a {
  padding-left: 1.5rem;
  font-size: 0.75rem;
}

.toc-list .toc-h4 a {
  padding-left: 2.25rem;
  font-size: 0.72rem;
}

/* ---- Breadcrumb ---- */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--doc-text-muted);
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: var(--doc-text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--doc-link);
}

.breadcrumb .separator {
  color: var(--doc-border);
}

/* ---- Page Meta ---- */

.page-meta {
  font-size: 0.8rem;
  color: var(--doc-text-muted);
  margin-bottom: 1.5rem;
}

/* ---- Page Navigation (Prev / Next) ---- */

.page-navigation {
  display: flex;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--doc-border);
}

.page-navigation a {
  flex: 1;
  display: block;
  padding: 0.75rem 1rem;
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  text-decoration: none;
  color: var(--doc-text);
  transition: border-color 0.15s;
}

.page-navigation a:hover {
  border-color: var(--doc-primary);
}

.page-navigation .nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--doc-text-muted);
  margin-bottom: 0.25rem;
}

.page-navigation .nav-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.page-navigation .nav-next {
  text-align: right;
}

/* ---- Footer ---- */

.site-footer {
  margin-left: var(--doc-sidebar-width);
  padding: 1.5rem 2.5rem;
  font-size: 0.75rem;
  color: var(--doc-text-muted);
  border-top: 1px solid var(--doc-border-divider);
  text-align: center;
}

/* ---- WordPress Admin Bar offset ---- */

body.admin-bar .site-header {
  top: 32px;
}

body.admin-bar .site-wrapper {
  padding-top: calc(var(--doc-header-height) + 32px);
}

body.admin-bar .site-sidebar {
  top: calc(var(--doc-header-height) + 32px);
}

body.admin-bar .site-toc {
  top: calc(var(--doc-header-height) + 32px);
}

html:has(body.admin-bar) {
  scroll-padding-top: calc(var(--doc-header-height) + 32px + 1rem);
}

@media (max-width: 782px) {
  body.admin-bar .site-header {
    top: 46px;
  }

  body.admin-bar .site-wrapper {
    padding-top: calc(var(--doc-header-height) + 46px);
  }

  body.admin-bar .site-sidebar {
    top: calc(var(--doc-header-height) + 46px);
  }
}

/* ---- Mobile hamburger ---- */

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--doc-text-inverse);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  margin-right: 0.5rem;
}

/* ---- Responsive ---- */

@media (max-width: 1100px) {
  .site-toc {
    display: none;
  }

  .site-content {
    margin-right: 0;
  }
}

@media (max-width: 768px) {
  .mobile-toggle {
    display: block;
  }

  .site-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }

  .site-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 190;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .site-content {
    margin-left: 0;
    padding: 1.5rem 1rem;
  }

  .site-footer {
    margin-left: 0;
  }

  .header-search {
    display: none;
  }

  .page-navigation {
    flex-direction: column;
  }
}
