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

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

/* Tutorial-only: leave estilos.css body gradient for the main site */
body.tutorial {
  overflow-y: auto !important;
  /* Darken gradient end ~20% vs --logo-sky so later chapters stay readable */
  --bg-gradient-end: #09192b;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
}

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,
.tree__subsubsection > 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__subsubsection > a:hover,
.tree__section > a.is-active,
.tree__subsection > a.is-active,
.tree__subsubsection > 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__subsubsections {
  list-style: none;
  margin: 0.05rem 0 0.2rem;
  padding: 0 0 0 0.75rem;
}

.tree__subsubsection > a {
  font-size: 0.76rem;
  opacity: 0.85;
  padding: 0.24rem 0.45rem;
}

.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: 1rem;
  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-subsubsection {
  margin: 1rem 0 1rem 0.35rem;
  padding-left: 0.75rem;
  border-left: 2px solid rgba(97, 121, 167, 0.28);
  scroll-margin-top: 110px;
}

.tutorial-subsubsection > h5 {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

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

.tutorial-list {
  max-width: 48rem;
  margin: 0.5rem 0 1rem 1.25rem;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  opacity: 0.9;
}

.tutorial-list li {
  margin-bottom: 0.35rem;
}

.tutorial-section code,
.tutorial-subsection code,
.tutorial-subsubsection code {
  font-family: var(--font-console);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}

.tutorial-content mjx-container {
  max-width: 48rem;
  overflow-x: auto;
  color: rgba(255, 255, 255, 0.92);
}

.tutorial-content mjx-container[display="true"] {
  margin: 0.85rem 0 1.1rem;
  padding: 0.35rem 0;
}

.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;
}

/* Official help / reference callouts */
.tutorial-content a {
  color: #a8bddc;
  text-decoration: underline;
  text-decoration-color: rgba(97, 121, 167, 0.55);
  text-underline-offset: 0.15em;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.tutorial-content a:hover {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.55);
}

.tutorial-refs {
  max-width: 48rem;
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 1rem 0.95rem;
  border-radius: 8px;
  border-left: 3px solid rgba(97, 121, 167, 0.65);
  background: rgba(97, 121, 167, 0.10);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.tutorial-refs p {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
  line-height: 1.55;
  opacity: 0.9;
  max-width: none;
}

.tutorial-refs p:last-child {
  margin-bottom: 0;
}

.tutorial-refs__list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  opacity: 0.92;
}

.tutorial-refs__list li {
  margin-bottom: 0.4rem;
  padding-left: 0;
}

.tutorial-refs__list li:last-child {
  margin-bottom: 0;
}

.tutorial-refs__list strong {
  color: rgba(255, 255, 255, 0.95);
  font-weight: 600;
}

/* --- Chapter pager (Previous / Next) --- */
.tutorial-pager {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.tutorial-pager__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
}

.tutorial-pager__status {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(199, 200, 217, 0.7);
  white-space: nowrap;
}

.tutorial-pager__link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light);
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
  min-height: 3.5rem;
  justify-content: center;
}

.tutorial-pager__link:hover {
  background: rgba(97, 121, 167, 0.22);
  border-color: rgba(97, 121, 167, 0.45);
  color: #fff;
}

.tutorial-pager__link--prev {
  align-items: flex-start;
  text-align: left;
}

.tutorial-pager__link--next {
  align-items: flex-end;
  text-align: right;
}

.tutorial-pager__link--disabled {
  visibility: hidden;
  pointer-events: none;
  border: none;
  background: transparent;
}

.tutorial-pager__dir {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.65;
}

.tutorial-pager__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.tutorial-figure {
  margin: 1rem 0 1.25rem;
  max-width: 48rem;
}

.tutorial-figure img,
.tutorial-figure__video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #000;
}

.tutorial-figure img {
  cursor: zoom-in;
}

.tutorial-figure figcaption {
  margin-top: 0.45rem;
  font-size: 0.85rem;
  font-style: italic;
  opacity: 0.7;
  text-align: center;
}

/* Click-to-zoom lightbox for .tutorial-figure images */
.tutorial-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(3, 9, 16, 0.88);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  cursor: zoom-out;
}

.tutorial-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.tutorial-lightbox__img {
  max-width: min(96vw, 1400px);
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  cursor: default;
}

.tutorial-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-console);
}

.tutorial-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.16);
}

body.tutorial-lightbox-open {
  overflow: hidden;
}

/* --- 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;
  }

  .tutorial-pager__inner {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .tutorial-pager__status {
    order: -1;
    white-space: normal;
  }

  .tutorial-pager__link--prev,
  .tutorial-pager__link--next {
    align-items: flex-start;
    text-align: left;
  }

  .tutorial-pager__link--disabled {
    display: none;
  }
}
