/* Pico provides the palette, responsive type, article cards and dark mode.
   Keep site styles to layout and a few reading-specific details. */
:root {
  --pico-border-radius: 0.5rem;
}

html {
  scroll-behavior: smooth;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.5rem 0.75rem;
  transform: translateY(-200%);
  background: var(--pico-background-color);
  border: 1px solid var(--pico-primary);
  border-radius: var(--pico-border-radius);
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 2px solid var(--pico-primary-focus);
  outline-offset: 3px;
}

/* Match the header to Pico's centered main container. */
body > .site-header {
  max-width: none;
  padding-inline: 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.site-header__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  max-width: 48rem;
  margin-inline: auto;
}

.site-header__brand {
  font-weight: 700;
  text-decoration: none;
}

.site-header__back,
.site-header__context {
  color: var(--pico-muted-color);
  font-size: 0.875rem;
}

.site-header__context {
  margin-left: auto;
}

body > main.shell {
  width: min(100% - 2rem, 48rem);
  max-width: 48rem;
  padding-inline: 0;
}

article {
  overflow-wrap: anywhere;
}

article > header h1 {
  margin: 0;
}

.section-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--pico-muted-color);
}

.series-byline,
.series-description,
.project-item__meta,
.chapter-group__count {
  color: var(--pico-muted-color);
}

.series-byline {
  margin: 0.4rem 0 0;
}

.series-description {
  margin: 0.75rem 0 0;
  white-space: pre-line;
}

/* Simple lists rather than nested cards. */
.project-list,
.page-list {
  padding: 0;
  list-style: none;
}

.project-list li,
.page-list li {
  padding-block: 0.85rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.project-list li:last-child,
.page-list li:last-child {
  border-bottom: 0;
}

.project-item__title {
  font-size: 1.2rem;
  font-weight: 600;
}

.project-item__meta {
  display: block;
  margin-top: 0.5rem;
}

.chapter-group + .chapter-group {
  margin-top: 2rem;
}

.chapter-group h2 {
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}

.chapter-group__count {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
}

.page-list {
  margin-bottom: 0;
}

.page-list a {
  display: block;
  overflow-wrap: anywhere;
}

.empty-state {
  color: var(--pico-muted-color);
}

/* Let Pico style the Markdown elements; constrain only long reading content. */
.reading-card {
  margin-bottom: 0;
}

.content {
  font-size: 1.075rem;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.content > :last-child {
  margin-bottom: 0;
}

.content img,
.content video,
.content svg {
  max-width: 100%;
  height: auto;
}

.content pre,
.content table {
  max-width: 100%;
  overflow-x: auto;
}

.content pre {
  white-space: pre;
}

.content table {
  display: block;
}

.content input[type="checkbox"] {
  margin-right: 0.4rem;
}

/* Compact, legible chapter navigation at either end of the reading view. */
nav.pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 0.75rem;
  margin-block: 1rem;
}

.pager__item,
.pager__index {
  display: block;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  text-decoration: none;
}

.pager__index {
  align-content: center;
  text-align: center;
}

.pager__item--next {
  text-align: right;
}

.pager__label {
  display: block;
  color: var(--pico-muted-color);
  font-size: 0.8rem;
}

.pager__title {
  display: block;
  overflow-wrap: anywhere;
}

.pager__item--disabled {
  opacity: 0.5;
}

@media (max-width: 40rem) {
  nav.pager {
    grid-template-areas: "index index" "previous next";
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .pager__item--previous { grid-area: previous; }
  .pager__index { grid-area: index; }
  .pager__item--next { grid-area: next; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .site-header,
  .pager,
  .skip-link { display: none !important; }

  article { box-shadow: none; }
}
