/* realityDebug() — an app's user guide.
 *
 * Loaded after app.css, on the pages scripts/build-guide.mjs makes under
 * apps/<slug>/guide/. A guide is read at length and moved around in, so it
 * gets what an app page doesn't need: a column of chapters beside the text,
 * tables, and blocks of example text. Everything else — the tokens, the
 * headings, the links, the footer — is app.css's. */

.guide {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  column-gap: 64px;
}

.guide-top {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

/* Only a phone needs telling where the chapters went. */
.guide-jump { display: none; }

/* In the page the chapters come before the text, which is the order a
   screen reader wants; the grid, not the markup, puts them side by side. */
.guide-nav { grid-column: 1; grid-row: 2; }
.guide-main { grid-column: 2; grid-row: 2; }
.guide-footer { grid-column: 2; grid-row: 3; max-width: var(--measure); }

/* ------------------------------------------------------------- chapters */

.guide-nav {
  position: sticky;
  top: 32px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.4;
  padding-bottom: 8px;
}

.guide-nav ol { list-style: none; padding: 0; margin: 0; }
.guide-nav li { margin: 0; }

.guide-nav a {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  color: var(--dim);
  text-decoration: none;
}

.guide-nav a:hover { color: var(--menu-text); }
.guide-nav a[aria-current="page"] { color: var(--menu-text); font-weight: 700; }

.guide-nav-title {
  margin-bottom: 10px;
  padding-bottom: 12px !important;
  border-bottom: 1px solid var(--rule);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* The chapter number, in a column of its own so the titles line up. */
.guide-nav .n {
  flex: none;
  width: 1.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  color: var(--dim);
}

/* The sections of the chapter being read, hung under its title. */
.guide-nav .sections {
  margin: 2px 0 10px calc(1.5em + 10px);
  padding-left: 12px;
  border-left: 1px solid var(--rule);
  font-size: 13px;
}

.guide-nav .sections a { padding: 3px 0; font-weight: 400; }

/* ----------------------------------------------------------------- text */

.guide-main { min-width: 0; max-width: var(--measure); }

.guide-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
}

.guide-main h1 { margin-bottom: 36px; }
.guide-main h1 + .updated { margin-top: -22px; }

/* A heading arrived at by a link shouldn't sit hard against the top edge. */
.guide-main h2, .guide-main h3 { scroll-margin-top: 28px; }

.guide-main em { font-style: italic; }

.table-wrap { overflow-x: auto; margin-bottom: 24px; }

.guide-main table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.5;
}

.guide-main th,
.guide-main td {
  text-align: left;
  vertical-align: top;
  padding: 9px 18px 9px 0;
  border-bottom: 1px solid var(--rule);
}

.guide-main th:last-child,
.guide-main td:last-child { padding-right: 0; }

.guide-main th {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.guide-main tr:first-child > td { border-top: 1px solid var(--rule); }
.guide-main thead + tbody tr:first-child > td { border-top: none; }

/* Shortcuts and names: the first column stays on one line. */
.guide-main table.keys td:first-child { white-space: nowrap; }

/* Example text: a title page, a scene in Fountain, a folder's layout. */
.guide-main pre {
  background: #262521;
  border-radius: 3px;
  padding: 14px 16px;
  margin-bottom: 20px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.guide-main pre code { background: none; padding: 0; font-size: inherit; }

/* ------------------------------------------------------------- pictures */

/* Screenshots, as the builder's figures. A phone's screen is tall, so one
   frame is held to a width that shows it whole in a window; two or three
   share the column side by side. */
.guide-main figure {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  margin: 28px 0 32px;
}

.guide-main figure img {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  max-width: 280px;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #0f0f0f;
}

.guide-main figcaption {
  flex: 0 0 100%;
  margin-top: -4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--dim);
}

/* ------------------------------------------------- previous and next */

.guide-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
}

.guide-pager a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--menu-text);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  text-decoration: none;
  transition: border-color 0.3s ease;
}

.guide-pager a:hover { border-color: var(--menu-text); }
.guide-pager .next { text-align: right; }

.guide-pager a span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.guide-footer { margin-top: 48px; }

/* ------------------------------------------------------------ narrower */

/* One column: the text first, the chapters after it, and a link at the top
   that goes down to them. No script, so nothing to fail. */
@media (max-width: 860px) {
  .guide { display: flex; flex-direction: column; max-width: var(--measure); }
  .guide-top { order: 1; }
  .guide-main { order: 2; }
  .guide-nav { order: 3; }
  .guide-footer { order: 4; }
  .guide-jump {
    display: inline;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--dim);
    text-decoration: none;
  }
  .guide-jump:hover { color: var(--menu-text); }
  .guide-nav {
    position: static;
    max-height: none;
    overflow: visible;
    margin-top: 56px;
    padding-top: 26px;
    border-top: 1px solid var(--rule);
    font-size: 15px;
  }
  .guide-nav a { padding: 7px 0; }
}

@media (max-width: 560px) {
  .guide-main figure { gap: 10px; }
  .guide-main figure img { border-radius: 9px; }
  .guide-pager { grid-template-columns: 1fr; }
  .guide-pager .next { text-align: left; }
  .guide-main table { font-size: 14px; }
}
