/* ==========================================================================
   Help & videos page (public/help.php) — the parts portal.css does not have.
   Everything else on the page reuses the portal's own classes: .download-header,
   .eyebrow, .section-toolbar, .quick-filter, .metric, .tool-card, .pill, .btn.
   Only what is new here: the search field, the video grid with its 16:9 poster,
   the FAQ accordion and the assistant panel. No external font, stylesheet or
   script — the privacy policy says the site loads nothing from another host
   (scripts/portal-legal-pages.test.mjs), which is also why a tutorial is a
   self-hosted <video> and never a YouTube embed.
   ========================================================================== */

:root {
  /* The play triangle as an inline data URI: a file of its own would be one
     more request, and another host is out of the question (see above). */
  --help-play-glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff8451'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.help-page { display: block; }

/* --- Hero: search + jump marks ------------------------------------------- */

.help-search {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 520px;
  margin: 18px 0 14px;
}
.help-search input[type="search"] {
  min-height: 42px;
  width: 100%;
  padding: 0 14px 0 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
}
.help-search input[type="search"]::-webkit-search-cancel-button { filter: invert(0.7); }
.help-search input[type="search"]::placeholder { color: var(--dim); }
.help-search input[type="search"]:focus-visible {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-bg);
}
.help-search svg {
  position: absolute;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--dim);
  pointer-events: none;
}
/* Only useful with JavaScript: the page itself shows everything unfiltered. */
.help-search[hidden] { display: none; }

.help-count {
  margin: 0 0 6px;
  color: var(--dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* --- The assistant panel (shipped; the operator brings their own access) - */

.help-ai {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  margin: 26px 0 8px;
  padding: 22px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 132, 81, 0.14), transparent 62%),
    var(--surface-raised);
  box-shadow: var(--shadow-lg), var(--edge);
}
.help-ai h2 { margin: 0 0 10px; font-size: 22px; font-weight: 700; line-height: 1.15; }
.help-ai > div { min-width: 0; }
/* No episode is planned about the assistant (it needs an account of the
   operator's own), so public/help.php renders no media box and the panel has a
   single child — which left the second column blank on wide screens. A panel
   that ever gets a video has two children and this rule stops applying. */
.help-ai > div:only-child { grid-column: 1 / -1; }
.help-ai p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.help-ai p:last-child { margin-bottom: 0; }
.help-ai-points { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 8px; }
.help-ai-points li {
  position: relative;
  padding-left: 22px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}
.help-ai-points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--brand);
}
.help-ai-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.55;
}

/* --- Videos -------------------------------------------------------------- */

.help-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.help-video {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow), var(--edge);
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease;
}
.help-video:hover { border-color: var(--line-strong); transform: translateY(-2px); }
/* A card with nothing to play yet must not look clickable. */
.help-video.is-planned:hover { transform: none; }
/* And it must not reserve the space of a player either. The striped 16:9 box
   carries no information, it is the larger half of the card, and nineteen of
   them pushed the answers off the page — the same reason public/help.php
   refuses an empty media box in the assistant panel ("would promise one").
   Without it a planned card is a list row: title, teaser, state. Only a
   planned card carries .is-planned, so this retires itself per episode. */
.help-video.is-planned .help-media { display: none; }

.help-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0c0c0c;
  border-bottom: 1px solid var(--line);
}
.help-media img,
.help-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0c0c0c;
}
.help-media-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  background:
    radial-gradient(90% 120% at 50% 0%, rgba(255, 132, 81, 0.1), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0 10px, transparent 10px 20px);
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
}
.help-media-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.help-media-play::after {
  content: "";
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: rgba(12, 12, 12, 0.72) var(--help-play-glyph) center / 18px no-repeat;
  box-shadow: var(--glow-accent);
  transition: transform 140ms ease, background-color 140ms ease;
}
.help-media-play:hover::after { transform: scale(1.06); }
.help-media-play:focus-visible { outline: none; }
.help-media-play:focus-visible::after { box-shadow: 0 0 0 3px var(--accent-border); }

.help-video-body { display: flex; flex-direction: column; gap: 10px; padding: 15px 16px 16px; }
.help-video-body h3 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.help-video-body p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.help-video-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: auto; }
.help-video-meta time { color: var(--dim); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* --- FAQ ----------------------------------------------------------------- */

.help-faq { display: grid; gap: 22px; }
.help-faq-group { min-width: 0; }
.help-faq-group > h3 {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.help-faq-group > h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.help-faq-list { display: grid; gap: 8px; }

.help-faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  overflow: hidden;
}
.help-faq-item[open] { border-color: var(--line-strong); background: var(--surface-raised); }
.help-faq-item > summary {
  list-style: none;
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  user-select: none;
}
.help-faq-item > summary::-webkit-details-marker { display: none; }
.help-faq-item > summary::after {
  content: "";
  flex: none;
  margin-left: auto;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 140ms ease, margin-top 140ms ease;
}
.help-faq-item[open] > summary::after { margin-top: 2px; transform: rotate(-135deg); }
.help-faq-item > summary:hover { color: var(--accent); }
.help-faq-item > summary:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-border); }

.help-faq-answer { padding: 2px 16px 16px; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.help-faq-answer > :first-child { margin-top: 0; }
.help-faq-answer > :last-child { margin-bottom: 0; }
.help-faq-answer p { margin: 0 0 10px; }
.help-faq-answer ol,
.help-faq-answer ul { margin: 0 0 10px; padding-left: 20px; }
.help-faq-answer li { margin: 0 0 6px; }
.help-faq-answer strong { color: var(--text); }
.help-faq-answer a { color: var(--accent); }
.help-faq-source {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11.5px;
}

/* Hidden by the search; `hidden` alone loses to the grid display — portal.css
   gives .download-empty a display of its own, so the no-results box has to be
   named here too or it sits on the page while there are hits. */
.help-video[hidden],
.help-faq-item[hidden],
.help-faq-group[hidden],
.help-page .download-empty[hidden] { display: none; }

/* --- Still stuck ---------------------------------------------------------- */

.help-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 0 8px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--edge);
}
.help-contact h2 { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.help-contact p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 60ch; }
.help-contact-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* --- Narrow screens ------------------------------------------------------- */

@media (max-width: 880px) {
  .help-ai { grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 18px; }
  .help-ai h2 { font-size: 19px; }
}
@media (max-width: 560px) {
  .help-search { max-width: none; }
  /* portal.css gives every button width:100% on a phone, which is right for an
     action and wrong for a filter chip: eight topics would be eight rows. */
  .help-page .quick-filter { width: auto; }
  .help-video-grid { grid-template-columns: minmax(0, 1fr); }
  .help-faq-item > summary { font-size: 13.5px; padding: 10px 13px; }
  .help-faq-answer { padding: 2px 13px 14px; }
  .help-contact { padding: 16px; }
  .help-contact-actions .btn { width: 100%; justify-content: center; }
}
