/* ==============================
   Wiki-only variables
   ============================== */
:root {
  --card: #0a0a0a;
  --glass: rgba(255, 255, 255, 0.03);
  --radius: 12px;
  --gap: 18px;
  --max-width: 1800px;
}

/* ==============================
   Body / global layout
   ============================== */
html,
body {
  height: 100%;
  margin: 0;
  font: 1rem/1.5 monospace;
  color: var(--fontcolor);
  background: var(--bgcolor);
  overflow-x: auto;
}

a {
  color: var(--linkcolor);
  text-decoration: none;
}

a:visited {
  color: var(--visitedcolor);
}

/* ==============================
   Global layout
   ============================== */
.wrap {
  max-width: var(--max-width);
  margin: 28px auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  overflow: auto;
}

/* ==============================
   Sidebar
   (sticky Table of Contents)
   ============================== */
nav.sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border-radius: var(--radius);
  padding: 16px;
  height: calc(100vh - 80px);
  position: sticky;
  top: 40px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

nav h2 {
  margin: 6px 0 12px 6px;
  font-size: 14px;
  color: var(--headingcolor);
  letter-spacing: 0.06em;
}

nav details {
  background: transparent;
  padding: 6px 0;
  margin: 2px 0;
}

nav summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--fontcolor);
}

nav summary::-webkit-details-marker {
  display: none;
}

nav summary::before {
  content: '>';
  display: inline-block;
  transform-origin: 50% 50%;
  transition: transform 0.18s ease;
  opacity: 0.9;
}

nav details[open] > summary::before {
  transform: rotate(90deg);
}

nav summary:hover {
  background: var(--glass);
}

nav summary:focus {
  outline: 3px solid rgba(255, 0, 0, 0.3);
  outline-offset: 3px;
}

nav .children {
  margin-left: 12px;
  padding-left: 6px;
  border-left: 1px dashed rgba(0, 255, 0, 0.15);
}

nav .children a {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--visitedcolor);
  font-weight: 500;
}

nav .children a:hover {
  color: var(--hovercolor);
  background: rgba(255, 255, 255, 0.02);
}

nav .sidebar-divider {
  border: none;
  border-top: 1px solid rgba(0, 255, 0, 0.1);
  margin: 12px 0;
}

nav .sidebar-footer {
  padding: 8px;
  color: var(--fontcolor);
  font-size: 13px;
  opacity: 0.6;
}

/* ==============================
   Main content area
   ============================== */
main {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.01));
  padding: 26px;
  border-radius: var(--radius);
  min-height: 60vh;
  border: 1px solid rgba(255, 255, 255, 0.03);
  overflow-wrap: break-word;
  overflow-wrap: anywhere;
}

main h1,
main h2,
main h3,
main h4,
main h5,
main h6 {
  color: var(--headingcolor);
  font-weight: bold;
}

header.page-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}

header.page-title h1 {
  margin: 0;
  font-size: 20px;
  color: var(--headingcolor);
}

header.page-title p {
  margin: 0;
  color: var(--fontcolor);
}

section {
  margin-bottom: 28px;
}

section h3 {
  margin: 0 0 10px 0;
}

pre {
  background: #0a0a0a;
  padding: 14px;
  border-radius: 10px;
  overflow-x: auto;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

:target {
  scroll-margin-top: 18px;
}

/* ==============================
   Global site header
   (blog navigation)
   ============================== */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 16px 0;
}

#brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

header nav a {
  color: var(--linkcolor);
}

header hr {
  border: none;
  border-top: 2px solid rgba(0, 255, 0, 0.2);
  width: 23%;
  margin: 12px auto;
}

/* ==============================
   Footer
   ============================== */
footer {
  display: block;
  margin-top: 30px;
  text-align: center;
  color: var(--fontcolor);
}

footer a {
  color: var(--linkcolor);
}

footer a:visited {
  color: var(--visitedcolor);
}

footer hr {
  border: none;
  border-top: 2px solid rgba(0, 255, 0, 0.2);
  width: 45%;
  margin: 12px auto;
}

/* ==============================
   Responsive adjustments
   ============================== */
@media (max-width: 880px) {
  .wrap {
    grid-template-columns: 1fr;
  }

  nav.sidebar {
    position: relative;
    height: auto;
    top: unset;
    overflow: visible;
  }
}

@media (min-width: 768px) {
  header #root {
    margin-top: 25px;
  }

  header #brand {
    flex-direction: row;
    align-items: center;
    text-align: unset;
  }

  header #brand .text {
    margin-left: 10px;
  }

  header .site-title {
    font-size: 35px;
  }

  header #brand h3 {
    font-size: 25px;
  }
}

/* ==============================
   Reduced Motion
   ============================== */
@media (prefers-reduced-motion: reduce) {
  nav summary::before {
    transition: none;
  }
}
