/* Shared styles for the documentation pages (docs, tutorial, cookbook,
   spec). The app stylesheet (style.css) builds a flex app-shell for the
   editor (body: 100vh column, main: flex row) — these pages are normal
   scrolling documents, so the shell is undone here. */

body {
  height: auto;
  min-height: 100vh;
  display: block;
  overflow-y: auto;
}

main.doc {
  display: block;
  flex: initial;
  min-height: initial;
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 1rem 1.5rem 6rem;
  line-height: 1.55;
}

/* the sidebar nav (doc-page.js buildNav): headings TOC + ▶ example entries.
   Injected only when the page has enough structure; the grid is gated on
   body.has-nav so nav-less pages keep the plain centered layout. */
body.has-nav {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
}
body.has-nav > header {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 10;
}
body.has-nav > main.doc { grid-column: 2; }
.doc-nav {
  grid-column: 1;
  position: sticky;
  top: var(--header-h, 37px);
  max-height: calc(100vh - var(--header-h, 37px));
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 1rem 0 2rem 0.4rem;
  font-size: 0.82rem;
  line-height: 1.35;
  border-right: 1px solid #262a31;
}
.doc-nav ul { list-style: none; margin: 0; padding: 0; }
.doc-nav li.lvl1 { margin-top: 0.7rem; }
.doc-nav li.lvl1:first-child { margin-top: 0; }
.doc-nav li.lvl2 { padding-left: 0.9rem; }
.doc-nav li.play a { font-family: ui-monospace, Menlo, monospace; font-size: 0.78rem; }
.doc-nav a,
.doc-nav a:visited {
  display: block;
  padding: 0.12rem 0.6rem;
  color: #8a919e;
  text-decoration: none;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-nav li.lvl1 a { color: #b8bec8; }
.doc-nav a:hover { color: #d6d9df; }
.doc-nav a.active {
  color: #7cb3ff;
  border-left-color: #4d80c0;
  background: #1a1e26;
}
@media (max-width: 68rem) {
  body.has-nav { display: block; }
  .doc-nav { display: none; }
}
/* prose stays at a comfortable reading measure; examples use the full width */
main.doc p, main.doc ul, main.doc ol { max-width: 46rem; }
main.doc h1 { margin-top: 0.5rem; }
main.doc h2 { margin-top: 2.2rem; border-bottom: 1px solid #333; padding-bottom: 0.2rem; }
main.doc h3 { margin-top: 1.6rem; }
main.doc table { border-collapse: collapse; margin: 0.8rem 0; }
main.doc th, main.doc td { border: 1px solid #333; padding: 0.3rem 0.6rem; text-align: left; }
main.doc th { background: #1e2127; }
main.doc code { background: #1e2127; padding: 0.05rem 0.3rem; border-radius: 3px; }
main.doc pre { background: #16181d; border: 1px solid #333; border-radius: 6px; padding: 0.6rem 0.8rem; overflow-x: auto; }
main.doc pre code { background: transparent; padding: 0; }
main.doc blockquote { border-left: 3px solid #333; margin-left: 0; padding-left: 1rem; color: #8a919e; }

/* the welcome page's doc cards */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.doc-cards a,
.doc-cards a:visited {
  display: block;
  border: 1px solid #333;
  border-radius: 6px;
  background: #16181d;
  padding: 1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
}
.doc-cards .card-title { color: #7cb3ff; }
.doc-cards a:hover { border-color: #4d80c0; background: #1a1e26; }
.doc-cards .card-title { font-size: 1.1rem; margin-bottom: 0.3rem; }
.doc-cards .card-blurb { color: #8a919e; font-size: 0.9rem; line-height: 1.4; }
.doc-cards a.card-accent { border-color: #4a7a5a; background: #1a2620; }
.doc-cards a.card-accent .card-title { color: #66d9a5; font-size: 1.15rem; }
.doc-cards a.card-accent:hover { border-color: #66d9a5; background: #1e2e24; }

/* inline playable example widgets (the mirror-pair player) */
.recipe {
  border: 1px solid #333;
  border-radius: 6px;
  margin: 0.8rem 0 1.4rem;
  background: #16181d;
  overflow: hidden;
}
.recipe-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0.6rem;
  background: #1e2127;
  border-bottom: 1px solid #333;
  font-size: 0.85rem;
}
.recipe-bar button {
  font-size: 0.9rem;
  padding: 0.15rem 0.7rem;
  cursor: pointer;
}
.recipe-bar .name { color: #8a919e; font-family: monospace; }
.recipe-bar .state { margin-left: auto; color: #8a919e; }
/* mirror pair: identical metrics on the visible <pre> and the
   transparent-text <textarea> above it, so highlights line up exactly */
.recipe .code { position: relative; }
.recipe .code-text {
  display: block;
  margin: 0;
  border: 0;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.6rem 0.8rem;
  tab-size: 2;
  white-space: pre;
}
.recipe .mirror {
  color: #d6d9df;
  min-height: 1.45em;
  overflow: hidden;          /* the textarea owns scrolling; JS syncs us */
}
.recipe .mirror mark {
  background: #2a4a35;
  color: #a5f0c8;
  outline: 1px solid #66d9a5;
  border-radius: 2px;
}
.recipe .mirror mark.v {          /* active value: blue, softer */
  background: #22344d;
  color: #a8ccf5;
  outline: 1px solid #4d80c0;
}
.recipe .mirror mark.h {          /* active harmony: amber */
  background: #4d3d1e;
  color: #f0d9a0;
  outline: 1px solid #c9a34d;
}
.recipe .mirror .ann {            /* live mod readout at line end */
  color: #6f7885;
  font-style: italic;
}
.recipe .input {
  position: absolute;
  inset: 0;
  resize: none;
  color: transparent;
  caret-color: #d6d9df;
  overflow-x: auto;          /* long lines scroll here… */
  overflow-y: hidden;
  scrollbar-width: thin;
}
.recipe .input::selection { background: rgba(102, 179, 255, 0.3); }
.recipe .input:focus { outline: 1px solid #3a4150; }
.recipe .problems {
  padding: 0.3rem 0.8rem 0.5rem;
  font-size: 0.8rem;
  font-family: monospace;
  white-space: pre-wrap;
}
.recipe .problems .error { color: #ff7a7a; }
.recipe .problems .warning { color: #e6c07b; }
.recipe.playing { border-color: #4a7a4a; }
.recipe.playing .recipe-bar { background: #1d2a1d; }

/* blog index */
.blog-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.blog-sort {
  font-size: 0.82rem;
  padding: 0.2rem 0.7rem;
}
.blog-tag {
  padding: 0.15rem 0.6rem;
  border: 1px solid #333;
  border-radius: 12px;
  font-size: 0.78rem;
  color: #8a919e;
  cursor: pointer;
  user-select: none;
}
.blog-tag:hover { border-color: #4d80c0; color: #b8bec8; }
.blog-tag.active { border-color: #4d80c0; color: #7cb3ff; background: #1a1e26; }
.blog-entry {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid #1e2127;
}
.blog-entry .blog-title { flex: 1; font-size: 1.05rem; }
.blog-entry .blog-tags { display: flex; gap: 0.3rem; }
.blog-entry .blog-tags .blog-tag { cursor: default; font-size: 0.72rem; }
.blog-entry .blog-date {
  color: #8a919e;
  font-size: 0.82rem;
  font-family: ui-monospace, Menlo, monospace;
  white-space: nowrap;
}
.blog-back { margin-bottom: 0.5rem; }
.blog-back a { color: #8a919e; text-decoration: none; font-size: 0.9rem; }
.blog-back a:hover { color: #7cb3ff; }
.article-header h1 { margin-bottom: 0.2rem; }
.article-meta { color: #8a919e; font-size: 0.88rem; margin-bottom: 1.5rem; }

/* landing page footer */
.site-footer {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #333;
  font-size: 0.82rem;
  color: #8a919e;
}
