/* Help (rapid redesign): Start here (#/help), Definitions (#/help?tab=definitions), js/views/help.js, and the Term
   map (#/help?tab=term-map), js/views/help_term_map.js (class prefix term-map-, at the end of this file).
   Class prefix help-. The terms themselves live in js/glossary.js. */

.help-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.help-lede {
  margin: 0.25rem 0 0;
  max-width: 52rem;
  color: var(--ink-dim);
  font: var(--type-body);
}

.help-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.help-card__title {
  margin: 0;
  font: var(--type-title);
  color: var(--ink);
}

.help-card__lede {
  margin: 0;
  color: var(--ink-dim);
}

.help-link {
  color: var(--gold);
}

/* ---- Start here --------------------------------------------------------------------------------- */

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.help-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-map__item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--panel);
}

.help-map__name {
  font: var(--type-headline);
  color: var(--ink);
}

.help-map__where {
  color: var(--gold);
  font: var(--type-footnote);
  font-weight: 600;
}

.help-map__text {
  margin: 0;
  color: var(--ink-dim);
  font: var(--type-body);
}

.help-steps {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: help-step;
}

.help-steps__item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: start;
  counter-increment: help-step;
}

.help-steps__item::before {
  content: counter(help-step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  color: var(--gold);
  font: var(--type-footnote);
  font-weight: 700;
}

.help-steps__name {
  display: block;
  font: var(--type-headline);
  color: var(--ink);
}

.help-steps__text {
  margin: 0.1rem 0 0;
  color: var(--ink-dim);
}

.help-tasks {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-tasks__item + .help-tasks__item {
  border-top: 1px solid var(--border);
}

.help-tasks__link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0;
  color: var(--ink);
  text-decoration: none;
}

.help-tasks__link:hover .help-tasks__q,
.help-tasks__link:focus-visible .help-tasks__q {
  color: var(--gold);
}

.help-tasks__q {
  font: var(--type-headline);
}

.help-tasks__a {
  color: var(--ink-dim);
  font: var(--type-body);
}

.help-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--ink-body);
  font: var(--type-footnote);
  font-weight: 600;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
}

.help-chip:hover,
.help-chip:focus-visible,
.help-chip.is-current {
  border-color: var(--border-gold);
  color: var(--gold);
}

/* ---- Definitions -------------------------------------------------------------------------------- */

.help-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.help-search {
  flex: 1 1 18rem;
  max-width: 28rem;
}

.help-count {
  color: var(--ink-muted);
  font: var(--type-footnote);
}

.help-groups {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.help-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-margin-top: calc(var(--navbar-h) + 1rem);
}

.help-group__head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.help-group__title {
  margin: 0;
  font: var(--type-title);
  color: var(--ink);
}

.help-group__text {
  margin: 0;
  color: var(--ink-dim);
}

.help-terms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* A card is as tall as its own text; the grid's default stretches it to the tallest in the row (audit 39). */
  align-items: start;
  gap: 0.75rem;
}

.help-term {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-margin-top: calc(var(--navbar-h) + 1rem);
  transition: border-color var(--dur-slow) ease;
}

.help-term.is-highlighted {
  border-color: var(--border-gold);
  background: linear-gradient(135deg, var(--gold-soft), var(--card-to));
}

.help-term__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.6rem;
}

.help-term__name {
  margin: 0;
  font: var(--type-headline);
  color: var(--ink);
}

.help-term__name:focus {
  outline: none;
}

.help-term__aka {
  color: var(--ink-muted);
  font: var(--type-footnote);
}

.help-term__short {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.help-term__body {
  margin: 0;
  color: var(--ink-body);
}

.help-term__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: auto;
  padding-top: 0.25rem;
  font: var(--type-footnote);
}

.help-term__key {
  color: var(--ink-muted);
  margin-right: 0.35rem;
}

.help-term__links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
}

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

.help-empty {
  margin: 0;
  color: var(--ink-dim);
}

@media (max-width: 1023px) {
  .help-grid,
  .help-terms {
    grid-template-columns: minmax(0, 1fr);
  }
  .help-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .help-map {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .help-term {
    transition: none;
  }
}

/* ---- Term map (ticket 001128) -------------------------------------------------------------------- */
/* Quiet boxes, thin arrows, one gold accent for the selected word. The boxes are HTML; the arrows are one SVG
   layer (js/views/help_term_map.js) laid over the stage and ignoring the pointer. Below 1100 px the rows do not fit
   side by side, so the boxes stack, the arrows are not drawn and each box lists them as text instead. */

.term-map__views .segmented {
  display: flex;
  flex-wrap: wrap;
}

.term-map__intro {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.term-map__view-title {
  margin: 0;
  font: var(--type-title);
  color: var(--ink);
}

.term-map__view-text {
  margin: 0;
  max-width: 52rem;
  color: var(--ink-dim);
  font: var(--type-body);
}

.term-map__stage {
  position: relative;
  padding: var(--space-3) 0 var(--space-5);
}

.term-map__rows {
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

.term-map__row {
  display: flex;
  flex-wrap: nowrap; /* a row never splits: the arrows are drawn for the rows as written */
  justify-content: center;
  align-items: flex-start;
  gap: 2.5rem 11rem; /* room for a label (up to about 9 rem) and an arrowhead on an arrow between neighbours */
}

.term-map__row--tight {
  column-gap: 9rem; /* four boxes in a row (they shrink to fit): room for the longest label there */
}

.term-map__box {
  display: flex;
  flex: 0 1 13.5rem;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 9rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  background: var(--panel);
}

.term-map__box:has(.is-selected) {
  border-color: var(--border-gold);
}

.term-map__term {
  appearance: none;
  align-self: flex-start;
  margin: -0.2rem -0.35rem;
  padding: 0.2rem 0.35rem;
  border: 0;
  border-radius: 0.4rem;
  background: transparent;
  color: var(--ink);
  font: var(--type-headline);
  text-align: left;
  cursor: pointer;
}

.term-map__term:hover {
  color: var(--gold);
}

.term-map__term:focus-visible,
.term-map__link:focus-visible,
.term-map__close:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.term-map__term.is-selected {
  background: var(--gold-soft);
  box-shadow: inset 0 0 0 1px var(--border-gold);
  color: var(--gold);
}

.term-map__term--kind {
  color: var(--ink-body);
  font: var(--type-body);
}

.term-map__kinds {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin: 0;
  padding: 0 0 0 0.6rem;
  border-left: 1px solid var(--border-strong);
  list-style: none;
}

.term-map__kinds .term-map__kinds {
  margin-top: 0.15rem;
}

.term-map__lines {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0.5rem 0 0;
  border-top: 1px solid var(--border);
  color: var(--ink-dim);
  font: var(--type-footnote);
  list-style: none;
}

.term-map__arrows {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.term-map__line {
  fill: none;
  stroke: var(--ink-muted);
  stroke-linejoin: round;
  stroke-width: 1;
}

.term-map__line.is-active {
  stroke: var(--gold);
  stroke-width: 1.5;
}

.term-map__head {
  fill: var(--ink-muted);
}

.term-map__head.is-active {
  fill: var(--gold);
}

/* The label sits on the line; a stroke in the page color behind the letters keeps it readable. */
.term-map__label {
  fill: var(--ink-dim);
  font: var(--type-footnote);
  paint-order: stroke;
  stroke: var(--bg);
  stroke-linejoin: round;
  stroke-width: 5px;
}

.term-map__label.is-active {
  fill: var(--gold);
}

.term-map__dialog {
  z-index: 3;
  inset: auto;
  width: min(24rem, calc(100vw - 2rem));
  max-height: min(44rem, calc(100vh - 2rem)); /* a long entry (Station) shows whole; place() keeps it inside the window */
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 0.9rem;
  background: var(--panel-deep);
  box-shadow: 0 0.75rem 2rem rgb(0 0 0 / 0.5);
  color: var(--ink);
}

.term-map__dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.term-map__sheet {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 1.1rem;
}

.term-map__sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.term-map__sheet-title {
  margin: 0;
  font: var(--type-title);
}

.term-map__close {
  appearance: none;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--ink-dim);
  font: var(--type-footnote);
  cursor: pointer;
}

.term-map__close:hover {
  color: var(--ink);
}

.term-map__aka {
  margin: 0;
  color: var(--ink-muted);
  font: var(--type-footnote);
}

.term-map__short {
  margin: 0;
  font: var(--type-headline);
}

.term-map__body {
  margin: 0;
  color: var(--ink-body);
  font: var(--type-body);
}

.term-map__fact {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font: var(--type-footnote);
}

.term-map__key {
  color: var(--ink-muted);
}

.term-map__links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
}

.term-map__rels {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  color: var(--ink-dim);
  list-style: none;
}

.term-map__link {
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  font: inherit;
  cursor: pointer;
}

.term-map__link:hover {
  text-decoration: underline;
}

@media (max-width: 1099px) {
  .term-map__rows {
    gap: 1rem;
    max-width: 40rem;
    margin-inline: auto;
  }
  .term-map__row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .term-map__box {
    flex-basis: auto;
  }
  .term-map__lines {
    display: flex;
  }
  .term-map__arrows {
    display: none;
  }
  .term-map__term,
  .term-map__link {
    min-height: 2.75rem;
  }
  .term-map__link {
    display: inline-flex;
    align-items: center;
  }
  .term-map__dialog {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    max-height: 80vh;
    border-bottom: 0;
    border-radius: 1rem 1rem 0 0;
  }
}
