/* =============================================================
   The Q&As page (qa.html). Loaded after styles.css and library.css.
   The band at the top reuses the Library's dark band, search box and
   chips; below it, the question list on the left and the player on the
   right (on a phone the player sits above the list and stays on screen
   while a video plays).
   ============================================================= */

/* ---------- band ----------
   The shelf header (plans:library-head) gives the title and the line under it. The band under it holds the
   search, a few searches to try and the topic chips. Here the player is what stays on screen, so the band
   scrolls away instead of pinning under the site header like the other shelves. */
.qa-band { position: relative; top: auto; margin-bottom: var(--s-6); }
.qa-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.qa-suggest-lbl {
  margin-right: 4px; font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .12em;
  text-transform: uppercase; color: var(--on-dark-soft);
}
.qa-sugg {
  font: inherit; font-size: var(--fs-100); line-height: 1.2; color: var(--on-dark); cursor: pointer;
  background: transparent; border: 1px solid var(--line-dark-strong); border-radius: var(--r-pill, 999px); padding: 5px 12px;
}
.qa-sugg:hover { border-color: var(--cyan); color: #fff; }
.qa-sugg:focus-visible { outline: 3px solid var(--violet-soft); outline-offset: 2px; }
.qa-topics { margin-top: 12px; }

/* ---------- layout ---------- */
.qa-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 430px); gap: var(--s-6);
  align-items: start; padding-bottom: var(--s-8);
}
.qa-player-col { position: sticky; top: calc(var(--header-h) + var(--s-4)); }

/* ---------- the three views (qa-page.js sets data-view) ----------
   home:   the videos, one card each, full width (the page opens here)
   rec:    one video open: its questions, and the player beside them
   search: matching questions from every video, and the player */
.qa-layout[data-view="home"] { grid-template-columns: minmax(0, 1fr); }
.qa-layout[data-view="home"] .qa-player-col,
.qa-layout[data-view="home"] #qa-list,
.qa-layout[data-view="home"] .qa-count,
.qa-layout[data-view="home"] .qa-back,
.qa-layout[data-view="rec"] .qa-count,
.qa-layout:not([data-view="home"]) .qa-home,
.qa-layout:not([data-view="rec"]) .qa-start { display: none; }

.qa-back {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 var(--s-4);
  font-size: var(--fs-200); font-weight: 600; color: var(--teal-deep); text-decoration: none;
}
.qa-back:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- home: the videos ---------- */
.qa-home-h { margin: 0 0 var(--s-4); font-size: var(--fs-500); }
.qa-cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--s-5);
}
.qa-card {
  display: flex; flex-direction: column; height: 100%; overflow: hidden; border-radius: var(--r-lg);
  background: var(--white); border: 1px solid var(--line); color: inherit; text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}
.qa-card:hover { transform: translateY(-2px); box-shadow: 0 18px 36px -24px rgba(11, 18, 32, .55); }
.qa-card:focus-visible { outline: 3px solid var(--violet-soft); outline-offset: 2px; }
.qa-card-art {
  position: relative; aspect-ratio: 16 / 9; display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--s-4) var(--s-5); color: #fff; background-color: var(--ink); background-size: cover; background-position: center;
  background-image: radial-gradient(120% 120% at 100% 0%, rgba(167, 139, 250, .38), transparent 55%), linear-gradient(160deg, var(--navy), var(--ink));
}
.qa-card-art.has-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(5, 8, 15, .55), rgba(5, 8, 15, 0) 50%); }
.qa-card-month { position: relative; z-index: 1; font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1; }
.qa-card-month small { display: block; margin-top: 6px; font-size: var(--fs-200); font-weight: 500; color: var(--on-dark-soft); }
.has-thumb .qa-card-month { display: none; }
.qa-card-kind {
  position: absolute; top: var(--s-4); left: var(--s-5); z-index: 1; padding: 3px 9px; border-radius: 999px;
  font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .12em; text-transform: uppercase;
  color: var(--cyan); background: rgba(5, 8, 15, .6);
}
.qa-card-play {
  position: absolute; right: var(--s-5); bottom: var(--s-4); z-index: 1; display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%; color: var(--ink); background: var(--cyan);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); transition: transform .16s ease;
}
.qa-card:hover .qa-card-play { transform: scale(1.07); }
.qa-card-body { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: var(--s-4) var(--s-5) var(--s-5); }
.qa-card-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-500); line-height: 1.2; color: var(--heading-ink); }
.qa-card-meta { font-size: var(--fs-100); color: var(--muted-light); }
.qa-card .qa-tags { justify-content: flex-start; margin-top: 4px; }
.qa-card-cta { margin-top: auto; padding-top: var(--s-3); font-size: var(--fs-200); font-weight: 600; color: var(--teal-deep); }
.qa-card-cta::after { content: " \2192"; }
@media (prefers-reduced-motion: reduce) { .qa-card, .qa-card-play { transition: none; } .qa-card:hover { transform: none; } }

/* ---------- the list ---------- */
.qa-count { margin: 0 0 var(--s-4); color: var(--muted-light); font-size: var(--fs-200); }
.qa-count b { color: var(--heading-ink); }
.qa-rec[hidden], .qa-q[hidden] { display: none; }
.qa-rec + .qa-rec { margin-top: var(--s-7); }
.qa-rec-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-3);
  padding-bottom: var(--s-3); border-bottom: 2px solid var(--heading-ink);
}
.qa-play.qa-start {
  width: auto; margin: 0; flex: none; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px;
  color: #fff; background: var(--ink);
}
.qa-play.qa-start:hover { background: var(--navy); }
.qa-start .qa-text { font-family: var(--font-body); font-size: var(--fs-200); font-weight: 600; color: #fff; }
.qa-rec-head h2 { margin: 0 0 6px; font-size: var(--fs-500); line-height: 1.2; }
.qa-rec-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0; font-size: var(--fs-100); color: var(--muted-light); }
.qa-kind { font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .1em; text-transform: uppercase; color: var(--teal-deep); }

.qa-qs { list-style: none; margin: 0; padding: 0; }
.qa-q {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 2px var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--header-h) + var(--s-5));
}
.qa-play {
  display: flex; align-items: baseline; gap: var(--s-3); width: calc(100% + 16px); margin: 0 -8px;
  padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}
.qa-play:hover { background: var(--teal-tint); }
.qa-play:focus-visible { outline: 3px solid var(--violet-soft); outline-offset: 1px; }
.qa-time {
  flex: none; min-width: 4.1em; padding: 2px 7px; border-radius: 6px; text-align: center;
  font-family: var(--font-mono); font-size: var(--fs-100); font-weight: 500; line-height: 1.5;
  color: var(--teal-deep); background: var(--teal-tint); font-variant-numeric: tabular-nums;
}
.qa-text { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-400); line-height: 1.35; color: var(--heading-ink); }
.qa-text mark { background: rgba(34, 211, 238, .30); color: inherit; border-radius: 3px; padding: 0 1px; }

.qa-q-side { display: flex; align-items: center; gap: var(--s-2); padding-top: 9px; }
.qa-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.qa-tag {
  font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; color: oklch(0.42 0.11 var(--h, 220)); background: oklch(0.95 0.035 var(--h, 220));
}
.qa-tag[data-topic="bipolar"]     { --h: 158; }
.qa-tag[data-topic="adhd"]        { --h: 28; }
.qa-tag[data-topic="addiction"]   { --h: 220; }
.qa-tag[data-topic="ocd"]         { --h: 305; }
.qa-tag[data-topic="prescribing"] { --h: 190; }
.qa-tag[data-topic="diagnosis"]   { --h: 278; }
.qa-tag[data-topic="therapy"]     { --h: 340; }
.qa-tag[data-topic="practice"]    { --h: 75; }
.qa-tag[data-topic="forensic"]    { --h: 0; }
.qa-tag[data-topic="reading"]     { --h: 120; }
.qa-link {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  color: var(--muted-light); flex: none;
}
.qa-link:hover { color: var(--teal-deep); background: var(--teal-tint); }
.qa-link.is-copied { color: #fff; background: var(--teal-deep); }

/* jump points inside a long answer */
.qa-parts {
  grid-column: 1 / -1; list-style: none; margin: 2px 0 2px calc(2.05em - 1px); padding: 0 0 0 var(--s-3);
  border-left: 2px solid var(--line-strong);
}
.qa-part { scroll-margin-top: calc(var(--header-h) + var(--s-5)); }
.qa-play--part { padding-block: 4px; }
.qa-play--part .qa-time { color: var(--muted-light); background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.qa-play--part .qa-text { font-family: var(--font-body); font-weight: 400; font-size: var(--fs-200); color: var(--slate); }

/* the question being answered right now */
.qa-q.is-current > .qa-play, .qa-part.is-current > .qa-play { background: var(--violet-tint); }
.qa-q.is-current > .qa-play .qa-time, .qa-part.is-current .qa-time { color: #fff; background: var(--violet); box-shadow: none; }
.qa-q.is-current > .qa-play .qa-time::before, .qa-part.is-current .qa-time::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; vertical-align: 1px;
  border-radius: 50%; background: #fff; animation: qa-pulse 1.4s ease-in-out infinite;
}
@keyframes qa-pulse { 50% { opacity: .25; } }
.qa-q.is-target { animation: qa-flash 1.8s ease-out; }
@keyframes qa-flash { 0%, 30% { background: rgba(34, 211, 238, .16); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  .qa-q.is-current > .qa-play .qa-time::before, .qa-part.is-current .qa-time::before, .qa-q.is-target { animation: none; }
}

.qa-none { margin: var(--s-5) 0; padding: var(--s-5); border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--white); }
.qa-none p { margin: 0; }
.qa-none p + p { margin-top: var(--s-2); }
.qa-none a, .qa-ask a:not(.btn) { color: var(--teal-deep); font-weight: 600; }
.qa-ask {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5);
  margin-top: var(--s-7); padding: var(--s-5); border-radius: var(--r); background: var(--paper); border: 1px solid var(--line);
}
.qa-ask p { margin: 0; max-width: 40rem; color: var(--slate); }
.qa-ask b { color: var(--heading-ink); }

/* ---------- the player ---------- */
.qa-player {
  overflow: hidden; border-radius: var(--r-lg); background: var(--ink); color: var(--on-dark);
  border: 1px solid var(--line-dark); box-shadow: 0 18px 40px -24px rgba(11, 18, 32, .55);
}
.qa-screen { position: relative; aspect-ratio: 16 / 9; background: #05080f; }
.qa-yt, .qa-screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.qa-msg {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); padding: var(--s-5); text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, rgba(34, 211, 238, .10), transparent 60%), #05080f;
}
.qa-player[data-state="loading"]  .qa-msg--loading,
.qa-player[data-state="member"]   .qa-msg--member,
.qa-player[data-state="out"]      .qa-msg--out,
.qa-player[data-state="nomember"] .qa-msg--nomember,
.qa-player[data-state="error"]    .qa-msg--error { display: flex; }
.qa-msg--loading { color: var(--on-dark-soft); font-size: var(--fs-200); }
.qa-msg p { margin: 0; max-width: 32ch; color: var(--on-dark-soft); font-size: var(--fs-200); line-height: 1.5; }
.qa-msg b { display: block; margin-bottom: 4px; color: #fff; font-family: var(--font-display); font-size: var(--fs-400); }
.qa-msg-ico { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; color: var(--cyan); background: rgba(34, 211, 238, .12); }
.qa-msg-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }

.qa-now { padding: var(--s-4) var(--s-5) var(--s-5); border-top: 1px solid var(--line-dark); }
.qa-now[hidden] { display: none; }
.qa-now-rec { margin: 0; font-family: var(--font-mono); font-size: var(--fs-50); letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.qa-now-q { margin: 6px 0 0; color: #fff; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-400); line-height: 1.3; }
.qa-now-part { margin: 6px 0 0; color: var(--on-dark-soft); font-size: var(--fs-200); line-height: 1.45; }
.qa-now-part::before { content: "\25B8\00a0"; color: var(--violet-soft); }
.qa-now-ctrl { display: flex; gap: var(--s-2); margin-top: var(--s-4); }
.qa-ctl {
  flex: 1; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer;
  font: inherit; font-size: var(--fs-200); font-weight: 600; color: var(--on-dark);
  background: transparent; border: 1px solid var(--line-dark-strong);
}
.qa-ctl:hover:not(:disabled) { border-color: var(--on-dark-soft); color: #fff; }
.qa-ctl--main { flex: 1.4; color: var(--ink); background: var(--cyan); border-color: var(--cyan); }
.qa-ctl--main:hover:not(:disabled) { color: var(--ink); background: #5ee3f3; border-color: #5ee3f3; }
.qa-ctl:disabled { opacity: .35; cursor: default; }
.qa-ctl:focus-visible { outline: 3px solid var(--violet-soft); outline-offset: 2px; }
.qa-yt-link { display: inline-block; margin-top: var(--s-3); font-size: var(--fs-100); color: var(--on-dark-soft); text-decoration: underline; text-underline-offset: 3px; }
.qa-yt-link:hover { color: #fff; }

/* the join pop-up: two plans side by side, like the Library's */
#qa-modal .lib-modal-what { color: var(--cyan); }

/* ---------- narrower screens ---------- */
@media (max-width: 960px) {
  .qa-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .qa-player-col { order: -1; position: static; }
  /* until a video plays, the panel is just its message, not an empty 16:9 box */
  .qa-player:not([data-state="playing"]) .qa-screen { aspect-ratio: auto; }
  .qa-player:not([data-state="playing"]) .qa-msg { position: static; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; text-align: left; padding: var(--s-4); }
  .qa-player:not([data-state="playing"]) .qa-msg-ico { width: 40px; height: 40px; }
  .qa-player:not([data-state="playing"]) .qa-msg p { max-width: none; flex: 1 1 14rem; }
  /* while a video plays it stays on screen above the list */
  .qa-layout.is-playing .qa-player-col { position: sticky; top: var(--header-h); z-index: 30; }
  .qa-layout.is-playing .qa-player { border-radius: 0 0 var(--r) var(--r); }
  .qa-now { padding: var(--s-3) var(--s-4) var(--s-4); }
  .qa-now-part, .qa-yt-link { display: none !important; }
  .qa-now-q { font-size: var(--fs-300); }
  .qa-now-ctrl { margin-top: var(--s-3); }
}
@media (max-width: 640px) {
  .qa-q { grid-template-columns: minmax(0, 1fr); }
  .qa-q-side { padding: 0 0 0 calc(4.1em + var(--s-3) + 14px); }
  .qa-tags { justify-content: flex-start; }
  .qa-text { font-size: var(--fs-300); }
  .qa-ask { padding: var(--s-4); }
}

/* a member's card shows the video's own thumbnail, which carries its own branding: the label goes, the meta line keeps it */
.has-thumb .qa-card-kind { display: none; }
