/* The documentation, drawn after play/base.css, which it shares with the
   playground and the player: the fonts, the colour tokens and the theme
   switch. */

:root {
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* The teal of the Net Yaroze User's Guide, the Software Development
     Tool manual, from the SCEI catalog's picture of the three manuals,
     lightened for the black. */
  --teal: light-dark(#007394, #5cc3dd);
}

html { scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 Barlow, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* The header: name, sections, search, repository. */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font: 600 1.5rem/1 "Barlow Condensed", Barlow, system-ui, sans-serif;
  letter-spacing: 0.005em;
  color: var(--ink);
  text-decoration: none;
  margin-right: 8px;
}
.sections { display: flex; gap: 4px; flex-wrap: wrap; }
.sections a {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.sections a:hover { background: var(--surface-2); }
.sections a[aria-current] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
/* The GitHub mark and the theme switch, as the playground draws them. */
.top-icons { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.top-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.top-icon:hover, .top-icon:focus-visible { background: var(--surface-2); color: var(--ink); }
a.top-icon { color: var(--ink); }
.top-icon svg { width: 20px; height: 20px; }

.search { position: relative; }
.search input {
  width: 200px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(440px, calc(100vw - 32px));
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.results a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.results a:hover, .results a:focus { background: var(--surface-2); }
.results b { font-weight: 600; }
.results small { color: var(--muted); align-self: baseline; }
.results span { grid-column: 1 / -1; color: var(--muted); font-size: 0.9rem; }
.results .none { padding: 8px 10px; color: var(--muted); }

/* Three columns: the section's pages, the page, its headings. */

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  gap: 40px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.layout.front { grid-template-columns: minmax(0, 1fr); }
.layout.front main { max-width: 760px; margin: 0 auto; }

.side, .toc { font-size: 0.95rem; }
.side nav, .toc nav { position: sticky; top: 76px; }
.side ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.side li a:hover { background: var(--surface-2); }
.side li a[aria-current] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }

/* A group's sections, as the docs are: each section's name, and under the
   one the page is in, its pages. */
.grouped nav { max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin; }
.grouped .head {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.grouped .head:hover { background: var(--surface-2); }
.grouped .head[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.grouped .group + .group { margin-top: 2px; }
.grouped .open ul { margin: 2px 0 10px 10px; padding-left: 6px; border-left: 1px solid var(--line); }

/* A section whose pages are listed with what each is, as the examples are:
   the list as the player had it, a wider column for it, and the page's
   headings left out to give the player the room. */
.layout.described { grid-template-columns: 260px minmax(0, 1fr); max-width: 1180px; }
.described .side li a {
  padding: 8px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
}
.described .side li a b { display: block; font-weight: 500; }
.described .side li a small { display: block; margin-top: 1px; color: var(--muted); font-size: 0.875rem; font-weight: 400; line-height: 1.35; }
.described .side li a[aria-current] { box-shadow: none; border-left-color: var(--accent); }
.described .side nav { max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin; }

.lede { font-size: 1.15rem; color: var(--muted); margin: -8px 0 20px; }

.controls {
  margin: 0 0 1.5em;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
article .controls h2 {
  margin: 0 0 4px;
  padding: 0;
  border: 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.controls p:last-child, .controls ul:last-child { margin-bottom: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 1.5em 0 0 !important;
  padding: 0;
  list-style: none;
}
.cards li { margin: 0; }
.cards a {
  display: block;
  height: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.cards a:hover { background: var(--surface); border-color: var(--line-strong); }
.cards b { display: block; font-weight: 600; }
.cards span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.925rem; line-height: 1.4; }

.toc p { margin: 0 0 6px; font-weight: 600; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.toc li a { display: block; padding: 3px 0; color: var(--muted); text-decoration: none; }
.toc li a:hover { color: var(--ink); }
.toc li.l3 a { padding-left: 14px; }

/* The page. */

article { min-width: 0; }
article h1 {
  margin: 0 0 20px;
  font: 600 2.375rem/1.05 "Barlow Condensed", Barlow, system-ui, sans-serif;
  letter-spacing: 0.005em;
}

/* A page with a tagline, the front page: the title as a banner, in the
   teal with a band of it at the edge, and the tagline under it. */
.hero {
  margin: 8px 0 28px;
  padding: 10px 0 10px 24px;
  border-left: 12px solid var(--teal);
}
.hero h1 {
  margin: 0;
  font-size: clamp(3.25rem, 9vw, 5.5rem);
  line-height: 0.95;
  color: var(--teal);
  text-shadow: 6px 6px 0 #000;
}
.hero p { margin: 10px 0 0; font-size: 1.25rem; color: var(--ink); }
article h2 {
  margin: 2.2em 0 0.6em;
  padding-top: 0.4em;
  border-top: 1px solid var(--line);
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 600;
}
article h3 { margin: 1.8em 0 0.5em; font-size: 1.15rem; font-weight: 600; }
article h4 { margin: 1.4em 0 0.4em; font-size: 1rem; font-weight: 600; }

/* A section's link to itself, shown when its heading is hovered. */
article h2 .anchor, article h3 .anchor, article h4 .anchor {
  margin-left: 0.4em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.1s;
}
article h2:hover .anchor, article h3:hover .anchor, article h4:hover .anchor,
article .anchor:focus { opacity: 1; }
article .anchor:hover { color: var(--accent); }
article p, article ul, article ol { margin: 0 0 1em; }
article li { margin: 0.25em 0; }
article hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
article img { max-width: 100%; height: auto; }
article blockquote {
  margin: 1em 0;
  padding: 0.6em 1em;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}

article code, article kbd {
  font: 0.9em/1.4 var(--mono);
}
article :not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface-2);
}
article pre {
  margin: 0 0 1.2em;
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.875rem;
  line-height: 1.5;
}
article pre code { background: none; padding: 0; font-size: inherit; }
.chroma { background: var(--surface) !important; }

article table {
  width: 100%;
  margin: 0 0 1.2em;
  border-collapse: collapse;
  font-size: 0.95rem;
}
article th, article td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
article th { font-weight: 600; background: var(--surface); }
article td:first-child { white-space: nowrap; }

/* The player, in an example's page. Its height is whatever the player
   asks for, through player.js; until it does, room for the picture. */
.player {
  display: block;
  width: 100%;
  height: 560px;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.source { margin-top: 2em; }

.prevnext {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.prevnext a {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.prevnext a:hover { background: var(--surface); }
.prevnext small { color: var(--muted); font-weight: 400; }
.prevnext .next { margin-left: auto; text-align: right; }

footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .layout.described { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 760px) {
  /* Two rows: the name, the search box and the icons, then the
     sections. */
  html { scroll-padding-top: 116px; }
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .brand { font-size: 1.3rem; margin-right: 0; }
  .search { flex: 1; min-width: 0; }
  .search input { width: 100%; }
  .top-icons { gap: 0; margin-left: -4px; }
  .sections { order: 1; width: 100%; margin: 0 -10px; }
  .layout, .layout.front { display: block; padding: 20px 16px 40px; }
  .side { margin-bottom: 24px; }
  .side nav { position: static; }
  .side ul { display: flex; flex-wrap: wrap; gap: 4px; }
  .side li a { padding: 5px 9px; border: 1px solid var(--line); }
  article h1 { font-size: 1.9rem; }
  .hero { margin-top: 0; padding-left: 16px; border-left-width: 8px; }
  .hero h1 { font-size: 2.75rem; }
  .hero p { font-size: 1.1rem; }

  /* The group's sections become a row of chips, with the pages of the one
     the page is in in a row of their own below them. */
  .grouped nav { display: flex; flex-wrap: wrap; gap: 4px; max-height: none; overflow: visible; }
  .grouped .group { display: contents; }
  .grouped .group + .group { margin-top: 0; }
  .grouped .head { padding: 5px 9px; border: 1px solid var(--line); }
  .grouped .head[aria-current] { border-color: var(--ink); background: var(--ink); color: var(--bg); box-shadow: none; }
  .grouped .open ul { order: 1; flex-basis: 100%; margin: 8px 0 0; padding: 0; border-left: 0; }

  /* The examples become a row of chips to scroll along, so that the
     picture comes first, as the player had them. */
  .described .side nav { max-height: none; overflow: visible; }
  .described .side ul {
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 -16px;
    padding: 2px 16px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .described .side ul::-webkit-scrollbar { display: none; }
  .described .side li { flex: none; }
  .described .side li a {
    padding: 6px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
  }
  .described .side li a small { display: none; }
  .described .side li a[aria-current] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
}
