/* An act page's side lists (reshape in reader/panes.ts): #versiuni and #cuprins, then the article,
   all children of main; #cuprins only when the act has contents. Only act pages load this file. */

#versiuni {
  order: -1;
  border-right: 1px solid #e5e5e5;
}
#cuprins {
  order: 1;
  border-left: 1px solid #e5e5e5;
}
/* (the header stays over its list as the list scrolls, so "↑ Sus" is always at hand; the site's
   style positions every list item, which would paint the items over the header without z-index) */
main > nav h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0;
  padding: 0 1rem;
  border-bottom: 1px solid #eee;
  text-align: left;
  font:
    600 12px/2rem system-ui,
    sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #666;
}
main > nav h2 a {
  font:
    500 13px/1.6 system-ui,
    sans-serif;
  letter-spacing: 0;
  text-transform: none;
  color: #0b57d0;
  text-decoration: none;
  padding: 0 0.5rem;
  border: 1px solid #c9d7f2;
  border-radius: 6px;
}
main > nav ul {
  font:
    14px/1.45 system-ui,
    sans-serif;
  margin: 0;
  padding: 0.6rem 1rem 2rem;
  list-style: none;
}
main > nav li {
  padding: 0.2rem 0;
}
main > nav li a {
  color: #0b57d0;
  text-decoration: none;
}
main > nav li a:hover {
  text-decoration: underline;
}
main > nav .current {
  font-weight: 600;
}
main > nav a.future {
  color: #999;
}
#cuprins li span {
  display: block;
  font-size: 13px;
  color: #666;
}
/* (the text never scrolls sideways: a long run without spaces wraps, and a table wider than the text
   scrolls inside its own box) */
main > article {
  overflow-wrap: break-word;
}
main > article table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
/* (the margin takes "↑ Sus" to the very top, past the space above the heading) */
#sus {
  scroll-margin-top: 10rem;
}
h1:target {
  background: none;
}

/* Desktop: the document scrolls; the lists stay under the top bar, each scrolling on its own. */
@media (min-width: 768px) {
  nav.top {
    height: 2.5rem;
  }
  main {
    display: flex;
    align-items: flex-start;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  main > article {
    flex: 1;
    min-width: 0;
    max-width: 52rem;
    margin: 1.5rem auto;
    padding: 0 1.2rem;
  }
  main.wide > article {
    max-width: 68rem;
  }
  main > nav {
    flex: none;
    position: sticky;
    top: 2.5rem;
    height: calc(100vh - 2.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #versiuni {
    width: clamp(180px, 18vw, 240px);
  }
  #cuprins {
    width: clamp(200px, 22vw, 300px);
  }
}

/* Phone: the panes swipe sideways, each scrolling on its own; the page opens on the text. */
@media (max-width: 767px) {
  body {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  main {
    flex: 1;
    min-height: 0;
    display: flex;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  main > * {
    flex: none;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
  main > article {
    width: 100%;
    padding: 1.5rem 1.2rem;
    scroll-initial-target: nearest;
  }
  main > nav {
    width: min(280px, calc(100% - 40px));
  }
  #cuprins {
    scroll-snap-align: end;
  }
}

@media print {
  main > nav {
    display: none;
  }
}
