/* page specifics: home, docs, blog */

/* ===== home ===== */

.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-6);
  padding-block: var(--space-6) var(--space-5);
}

.home h1 {
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  margin-bottom: var(--space-3);
  color: var(--accent);
}

.home .lead {
  margin-bottom: var(--space-3);
}

.home-body {
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* the logo sits on a tilted sticker */
.home-logo {
  width: 260px;
  padding: var(--space-4);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-fill-alt);
  box-shadow: var(--shadow-large);
  transform: rotate(3deg);
}

.section {
  padding-block: var(--space-4);
}

/* matches a chapter heading in the docs */
.section-heading {
  font-size: var(--text-step-2);
  color: var(--accent);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: var(--line) solid var(--border);
}

/* cards, used by the blog */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
  max-width: none;
  margin-top: var(--space-5);
  list-style: none;
  padding: 0;
}

.card-grid li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: 0;
  padding: var(--space-4);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}

/* an orange band across the top of each card */
.card-grid li::before {
  content: '';
  height: 10px;
  margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) var(--space-2);
  border-bottom: var(--line) solid var(--border);
  background: var(--accent-fill);
}

.card-grid li:hover {
  transform: translate(-3px, -3px);
  box-shadow: var(--shadow-large);
}

.card-grid li:active {
  transform: translate(5px, 5px);
  box-shadow: none;
}

/* focus ring on the card */
.card-grid li:focus-within {
  outline: var(--line) solid var(--accent);
  outline-offset: 4px;
}

.card-title,
.card-title:hover {
  color: var(--text-heading);
  background: transparent;
  font-family: var(--font-heading);
  font-size: var(--text-step-1);
  font-weight: 900;
  line-height: var(--leading-tight);
  text-decoration: none;
}

/* stretches the title link over the card */
.card-title::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card-title:focus-visible {
  outline: none;
}

.card-grid li:hover .card-title {
  color: var(--accent-hover);
}

.card-meta {
  color: var(--text-muted);
  font-size: var(--text-small);
}

.card-note {
  color: var(--text-muted);
}

/* note box, from a markdown blockquote */
.note {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: var(--line) solid var(--border);
  border-left: 12px solid var(--accent-fill);
  border-radius: var(--radius);
  background: var(--bg-raised);
  box-shadow: var(--shadow-small);
  color: var(--text);
  max-width: var(--content-width);
}

@media (max-width: 860px) {
  .home {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
    padding-block: var(--space-5) var(--space-3);
  }

  .home-logo {
    width: 150px;
    padding: var(--space-3);
    order: -1;
    margin-inline: auto;
  }
}

/* ===== docs ===== */

/* fixed to the left edge, below the header */
.docs-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  z-index: 10;
  width: var(--docs-nav-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-raised);
  border-right: var(--line) solid var(--border);
  padding: var(--space-3) var(--space-3) var(--space-4);
}

.docs-toc-toggle {
  display: none;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-fill);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-small);
  font-family: inherit;
  font-size: var(--text-small);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
}

.docs-toc-list {
  list-style: none;
  padding: 0;
}

.docs-toc-list li {
  margin-top: 0;
}

.docs-toc-list a {
  display: block;
  padding: var(--space-1) var(--space-3);
  border: var(--line-thin) solid transparent;
  color: var(--text-muted);
  font-size: var(--text-small);
  font-weight: 600;
  text-decoration: none;
}

.docs-toc-list a:hover {
  border-color: var(--border);
  background: var(--sidebar-hover-bg);
  color: var(--text);
}

/* the active chapter link is marked */
.docs-toc-chapter.is-active > a {
  color: var(--text);
  font-weight: 800;
}

/* after the chapter rule, a current chapter link keeps its fill colors */
.docs-toc-list a.is-current {
  border-color: var(--border);
  background: var(--accent-fill);
  color: var(--accent-contrast);
  font-weight: 800;
}

/* sections show only under the active chapter */
.docs-toc-sections {
  display: none;
  list-style: none;
  padding: 0;
}

.docs-toc-chapter.is-active .docs-toc-sections {
  display: block;
}

.docs-toc-sections a {
  padding-left: var(--space-5);
}

/* anchor targets for previously published links */
.legacy-anchor {
  display: block;
  height: 0;
}

.docs-main h4 {
  font-size: var(--text-body);
  color: var(--accent);
  margin: var(--space-4) 0 var(--space-2);
}

.docs-main table {
  margin-bottom: var(--space-4);
}

.docs-main blockquote,
.docs-main .note {
  margin-bottom: var(--space-4);
}

.docs-main ul,
.docs-main ol {
  margin-bottom: var(--space-3);
}

.docs-main {
  margin-left: var(--docs-nav-width);
  max-width: 920px;
  padding: var(--space-5) var(--space-5) var(--space-6);
}

.docs-main h1 {
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.docs-lead {
  color: var(--text-muted);
  font-size: var(--text-step-1);
  margin-bottom: var(--space-5);
}

/* a thick rule under every chapter */
.docs-main h2 {
  font-size: var(--text-step-2);
  color: var(--accent);
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: var(--line) solid var(--border);
}

.docs-main h3 {
  font-size: var(--text-step-1);
  color: var(--accent);
  margin: var(--space-5) 0 var(--space-3);
}

.docs-main p {
  margin-bottom: var(--space-3);
}

.docs-main pre {
  margin-bottom: var(--space-5);
}

/* the heading text links to its own anchor */
.heading-link,
.heading-link:hover {
  color: inherit;
  background: transparent;
  font-weight: inherit;
  text-decoration: none;
}

.heading-link:hover,
.heading-link:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: var(--line);
  text-underline-offset: 5px;
}

/* the hash shows on hover */
.heading-hash,
.heading-hash:hover {
  margin-left: var(--space-2);
  background: transparent;
  color: var(--text-muted);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}

h1:hover .heading-hash,
h2:hover .heading-hash,
h3:hover .heading-hash,
h4:hover .heading-hash,
.heading-link:focus-visible + .heading-hash {
  opacity: 1;
}

@media (max-width: 900px) {
  .docs-sidebar {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    background: transparent;
    border-right: 0;
    padding: var(--space-4) var(--space-4) 0;
  }

  .docs-main {
    margin-left: 0;
    max-width: none;
    padding: var(--space-3) var(--space-4) var(--space-6);
  }

  .docs-toc-toggle {
    display: block;
  }

  .docs-toc-list {
    display: none;
    margin-top: var(--space-3);
    padding: var(--space-2);
    border: var(--line) solid var(--border);
    background: var(--bg-raised);
  }

  .docs-toc[data-open='true'] .docs-toc-list {
    display: block;
  }
}

/* ===== blog ===== */

.blog-list-main {
  padding-block: var(--space-5) var(--space-6);
}

.blog-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.blog-title-row h1 {
  color: var(--accent);
}

/* bare icon beside the title */
.rss-link,
.rss-link:hover {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  background: transparent;
}

.post-meta {
  color: var(--text-muted);
  font-size: var(--text-small);
  margin-bottom: var(--space-4);
}

/* sits above the contents in a post rail */
.post-rail-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: var(--line) solid var(--border);
  font-size: var(--text-small);
  font-weight: 800;
}

.post-rail-links a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-3);
  border: var(--line-thin) solid transparent;
  text-decoration: none;
}

/* same hover as the contents below */
.post-rail-links a:hover {
  border-color: var(--border);
  background: var(--sidebar-hover-bg);
  color: var(--text);
}

.post-toc-empty {
  color: var(--text-muted);
  font-size: var(--text-small);
}

/* post headings have no rule */
.post-main h1 {
  margin-bottom: var(--space-3);
}

.post-content h2 {
  font-size: var(--text-step-2);
  color: var(--accent);
  margin: var(--space-5) 0 var(--space-3);
  padding-bottom: 0;
  border-bottom: 0;
}

.post-content h3 {
  font-size: var(--text-step-1);
  margin: var(--space-4) 0 var(--space-2);
}

.post-content p,
.post-content ul,
.post-content ol {
  margin-bottom: var(--space-3);
}

.post-content pre {
  margin-bottom: var(--space-5);
}

.docs-updated {
  color: var(--text-muted);
  font-size: var(--text-small);
  margin-bottom: var(--space-4);
}

/* ===== image viewer ===== */

.image-zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.image-zoom img {
  margin: var(--space-4) 0;
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}

.image-zoom:hover img {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-large);
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(0, 0, 0, 0.8);
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer-image {
  max-width: min(92vw, 1100px);
  max-height: 86vh;
  width: auto;
  height: auto;
  border: var(--line) solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-large);
}

.image-viewer-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  border: var(--line) solid #000000;
  border-radius: var(--radius);
  background: var(--accent-fill);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-ink);
  font-family: inherit;
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.image-viewer-close:hover {
  background: var(--accent-fill-alt);
}

/* the page behind does not scroll */
body.image-viewer-open {
  overflow: hidden;
}
