/* Docs layout for subpages/kren_tutorial.html */

html {
  scroll-snap-type: none !important;
}

body {
  overflow-y: auto !important;
}

main.tutorial-page {
  padding-top: 100px;
  min-height: 100vh;
}

.tutorial-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 0;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 100px);
}

/* --- Left TreeView --- */
.tutorial-sidebar {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem 1.25rem;
  border-right: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(3, 9, 16, 0.35);
}

.tutorial-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tutorial-sidebar__title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(199, 200, 217, 0.75);
  margin: 0;
}

.tutorial-sidebar__toggle {
  display: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-light);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-family: var(--font-console);
  font-size: 0.85rem;
  cursor: pointer;
}

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

.tree__chapter {
  margin-bottom: 0.35rem;
}

.tree__chapter-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 8px;
  transition: background 160ms ease;
}

.tree__chapter-row:hover,
.tree__chapter-row.is-active {
  background: rgba(255, 255, 255, 0.07);
}

.tree__expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-light);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.tree__expand:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tree__chevron {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 180ms ease;
  opacity: 0.7;
}

.tree__chapter.is-open > .tree__chapter-row .tree__chevron {
  transform: rotate(45deg);
}

.tree__chapter-link {
  flex: 1;
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.45rem 0.4rem 0.45rem 0.15rem;
  border-radius: 6px;
}

.tree__chapter-link:hover,
.tree__chapter-link.is-active {
  color: #fff;
}

.tree__sections {
  list-style: none;
  margin: 0.15rem 0 0.4rem;
  padding: 0 0 0 1.15rem;
  display: none;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.tree__chapter.is-open > .tree__sections {
  display: block;
}

.tree__section > a,
.tree__subsection > a {
  display: block;
  color: rgba(199, 200, 217, 0.85);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.32rem 0.5rem;
  border-radius: 6px;
  transition: background 160ms ease, color 160ms ease;
}

.tree__section > a:hover,
.tree__subsection > a:hover,
.tree__section > a.is-active,
.tree__subsection > a.is-active {
  color: #fff;
  background: rgba(97, 121, 167, 0.25);
}

.tree__subsections {
  list-style: none;
  margin: 0.1rem 0 0.25rem;
  padding: 0 0 0 0.9rem;
}

.tree__subsection > a {
  font-size: 0.82rem;
  opacity: 0.9;
}

.tree__leaf > a {
  display: block;
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
}

.tree__leaf > a:hover,
.tree__leaf > a.is-active {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

/* --- Content --- */
.tutorial-content {
  padding: 1.5rem 2rem 4rem;
  text-align: left;
}

.tutorial-content__intro {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.tutorial-content__intro h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

.tutorial-content__intro p {
  max-width: 42rem;
  opacity: 0.9;
}

.tutorial-chapter {
  margin-bottom: 3rem;
  scroll-margin-top: 110px;
}

.tutorial-chapter > h2 {
  font-size: 1.65rem;
  color: #fff;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.tutorial-section {
  margin: 1.75rem 0;
  scroll-margin-top: 110px;
}

.tutorial-section > h3 {
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 0.55rem;
}

.tutorial-subsection {
  margin: 1.15rem 0 1.15rem 0.75rem;
  padding-left: 0.85rem;
  border-left: 2px solid rgba(97, 121, 167, 0.45);
  scroll-margin-top: 110px;
}

.tutorial-subsection > h4 {
  font-size: 1.02rem;
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 0.4rem;
}

.tutorial-section p,
.tutorial-subsection p,
.tutorial-chapter > p {
  max-width: 48rem;
  font-size: 0.98rem;
  line-height: 1.65;
  opacity: 0.9;
}

.tutorial-placeholder {
  margin-top: 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  font-size: 0.88rem;
  opacity: 0.75;
}

/* --- Mobile --- */
@media (max-width: 900px) {
  .tutorial-layout {
    grid-template-columns: 1fr;
  }

  .tutorial-sidebar {
    position: sticky;
    top: 72px;
    z-index: 50;
    max-height: none;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(3, 9, 16, 0.92);
    backdrop-filter: blur(10px);
    padding-bottom: 0.85rem;
  }

  .tutorial-sidebar__toggle {
    display: inline-flex;
  }

  .tutorial-sidebar .tree {
    display: none;
    max-height: min(60vh, 420px);
    overflow-y: auto;
    margin-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .tutorial-sidebar.is-open .tree {
    display: block;
  }

  .tutorial-content {
    padding: 1.25rem 1.15rem 3rem;
  }

  .tutorial-content__intro h1 {
    font-size: 1.55rem;
  }
}
