/* the help: a page of its own, or the content of the dialog that shows it (components/help.js) */

/* the text in a column of 42rem, about 80 characters a line: wider reads badly */
body.help {
  display: grid;
  grid-template-columns: 11rem minmax(0, 42rem);
  justify-content: center;
  gap: 40px;
  margin: 0 auto;
  padding: 28px 32px 72px;
  line-height: 1.6;
}

body.help .contents {
  position: sticky;
  top: 28px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

body.help .contents b {
  margin-bottom: 4px;
}

body.help .contents a {
  color: var(--muted);
  text-decoration: none;
}

body.help .contents a:hover {
  color: var(--accent);
}

body.help main {
  padding: 0;
  min-width: 0;
}

body.help h1 {
  display: block;
  margin: 0 0 12px;
  font-size: 20px;
}

body.help h2 {
  margin: 40px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 17px;
}

body.help h3 {
  margin: 24px 0 4px;
  font-size: 14px;
}

body.help p, body.help ul {
  margin: 0 0 12px;
}

body.help li {
  margin-bottom: 4px;
}

body.help section {
  scroll-margin-top: 8px;
}

body.help [id] {
  scroll-margin-top: 12px;
}

/* the feature asked for, when the page was opened at it: shaded, the text kept off the edge of the shade by
   padding that the margin takes back, so that the text stays in line */
body.help :target {
  padding-inline: 14px;
  margin-inline: -14px;
  padding-bottom: 6px;
  background: var(--accent-soft);
  border-radius: 6px;
}

body.help a {
  color: var(--accent);
}

body.help code, body.help kbd {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--sunk);
  font: 12.5px var(--mono);
}

body.help dl {
  margin: 8px 0;
}

body.help dt {
  margin-top: 10px;
  font-weight: 600;
}

body.help dd {
  margin: 2px 0 0 18px;
  color: var(--fg);
}

body.help small {
  color: var(--muted);
  font-weight: 400;
}

body.help .muted {
  color: var(--muted);
}

@media (max-width: 700px) {
  body.help {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 20px 20px 56px;
  }

  body.help .contents {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 12px;
  }
}

/* the section being read, in the contents: marked as the page scrolls (js/help-page.js) */
body.help .contents a {
  padding-left: 8px;
  border-left: 2px solid transparent;
}

body.help .contents a[aria-current] {
  border-left-color: var(--accent);
  color: var(--fg);
  font-weight: 600;
}

/* a thin scrollbar: the page is long, and a wide one is most of the margin */
html:has(body.help) {
  scrollbar-width: thin;
}

/* in the dialog: a row with the title and the close button, the page filling the rest under it */
dialog.help {
  width: min(60rem, calc(100vw - 32px));
  height: min(46rem, calc(100vh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

dialog.help[open] {
  display: flex;
  flex-direction: column;
}

dialog.help::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

dialog.help .help-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 6px 8px 6px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-weight: 650;
}

dialog.help .help-head span {
  flex: 1;
}

dialog.help iframe {
  display: block;
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
}

/* a phone: the dialog is the screen */
@media (max-width: 700px) {
  dialog.help {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  body.help .contents a {
    padding-left: 0;
    border-left: 0;
  }
}

/* a label with a short help while hovered (lib/tip.js), and a button to this page in it */
.has-tip {
  text-decoration: underline dotted var(--line-strong);
  text-underline-offset: 3px;
}

.tip-bubble {
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
  font: 13px/1.45 system-ui, sans-serif;
  text-align: left;
  white-space: normal;
}

.tip-more {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tip-more:hover {
  text-decoration: underline;
}
