/* The quest overview (/quests).  Loaded by templates/quests.html through the head_extra block; nothing
 * here is used by another page.
 *
 * Colours are local tokens on .qv that point at the site's own tokens with a fallback each, so the
 * page follows the shell's palette when it defines one (--panel, --heading, ...) and still reads
 * correctly against pq.css alone.  The dark surface is assumed: the site is dark by design.
 *
 * Layout is three bands -- head, filter panel, body -- and the body is a tree column and a table
 * column.  Below 56rem the tree stacks above the table and the table scrolls sideways inside its
 * own wrapper (pq.css .table-wrap), never the page.
 */

.qv {
  --qv-panel: var(--panel, var(--bg-raised, #1a1c26));
  --qv-inset: var(--panel-inset, var(--bg-inset, #0e0f15));
  --qv-line: var(--line, var(--border, #2b2e3c));
  --qv-line-strong: var(--line-strong, var(--border-strong, #3c4152));
  --qv-text: var(--text, #e7e9f2);
  --qv-dim: var(--text-dim, #a7adc2);
  --qv-faint: var(--text-faint, #7d8399);
  --qv-gold: var(--heading, #e6b422);
  --qv-gold-dim: var(--heading-dim, #b8901a);
  --qv-jade: var(--accent, #6fd18c);
  --qv-jade-dim: var(--accent-dim, #3f7f56);
  --qv-radius: var(--radius, 10px);
  --qv-radius-sm: var(--radius-sm, 6px);
}

/* ------------------------------------------------------------------ head */

.qv-head {
  display: grid;
  gap: 1rem 2rem;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 1.25rem;
}
@media (min-width: 60rem) {
  .qv-head {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
    grid-template-areas: "intro zone" "figures zone";
  }
  .qv-intro { grid-area: intro; }
  .qv-figures { grid-area: figures; }
  .qv-zone { grid-area: zone; align-self: start; }
}

.qv-intro { display: flex; gap: 1rem; align-items: flex-start; }
.qv-icon { flex: 0 0 auto; width: 4rem; height: 4rem; border-radius: var(--qv-radius); }
.qv-intro h1 {
  margin: 0 0 0.35rem;
  color: var(--qv-gold);
  font-variant-caps: small-caps;
  letter-spacing: 0.04em;
}
.qv-lede { color: var(--qv-dim); margin: 0 0 0.5rem; max-width: 62ch; }

.qv-figures {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.25rem;
}
.qv-figures li { display: flex; flex-direction: column; min-width: 7rem; }
.qv-figures strong {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.3rem);
  line-height: 1.05;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--qv-text);
}
.qv-figures span { color: var(--qv-faint); font-size: 0.82rem; }

.qv-zone {
  background: var(--qv-panel);
  border: 1px solid var(--qv-line);
  border-radius: var(--qv-radius);
  padding: 0.9rem 1rem;
}
.qv-zone h2 { font-size: 1rem; margin: 0 0 0.35rem; color: var(--qv-gold); }
.qv-zone p { color: var(--qv-dim); font-size: 0.88rem; margin: 0 0 0.6rem; }
.qv-zone-pick { display: flex; gap: 0.5rem; }
.qv-zone-pick select { flex: 1 1 auto; min-width: 0; }

/* -------------------------------------------------------- filter panel */

.qv-panel {
  background: var(--qv-panel);
  border: 1px solid var(--qv-line);
  border-radius: var(--qv-radius);
  padding: 0.9rem 1rem 0.8rem;
  margin-bottom: 1.25rem;
}
.qv-filters { display: grid; gap: 0.6rem; }
.qv-row {
  display: grid;
  gap: 0.75rem 1rem;
  align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}
.qv-row .qv-f-name { grid-column: span 2; }
@media (max-width: 36rem) { .qv-row .qv-f-name { grid-column: 1 / -1; } }
.qv-row-2 { grid-template-columns: repeat(auto-fit, minmax(9rem, auto)); align-items: end; }

.qv-filters .field label,
.qv-filters legend {
  font-size: 0.78rem;
  color: var(--qv-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0;
}
.qv-filters fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.qv-range { display: flex; align-items: center; gap: 0.4rem; }
.qv-range input { min-width: 0; }

.qv-rule { color: var(--qv-faint); font-size: 0.8rem; margin: 0; max-width: none; }

.qv-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.25rem; }
.qv-chip { position: relative; display: inline-flex; cursor: pointer; }
.qv-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.qv-chip span {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--qv-line-strong);
  border-radius: 999px;
  background: var(--qv-inset);
  color: var(--qv-dim);
  font-size: 0.88rem;
  line-height: 1.3;
}
.qv-chip:hover span { color: var(--qv-text); border-color: var(--qv-gold-dim); }
.qv-chip input:checked + span {
  border-color: var(--qv-gold);
  color: var(--qv-gold);
  background: rgba(230, 180, 34, 0.1);
}
.qv-chip input:focus-visible + span { outline: 2px solid var(--qv-jade); outline-offset: 2px; }
.qv-chip input:disabled + span { opacity: 0.5; cursor: not-allowed; }

.qv-check { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--qv-dim); font-size: 0.9rem; }
.qv-check input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--qv-gold); }

.qv-actions { display: flex; align-items: center; gap: 0.9rem; justify-self: end; }
.qv-reset { color: var(--qv-dim); font-size: 0.9rem; }
.qv-reset:hover { color: var(--qv-text); }

/* ----------------------------------------------------------------- body */

.qv-body { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 56rem) {
  .qv-body { grid-template-columns: 15.5rem minmax(0, 1fr); }
}

/* The tree.  <details> and links, so it needs no script; the count sits at the right of each line. */
.qv-tree {
  background: var(--qv-panel);
  border: 1px solid var(--qv-line);
  border-radius: var(--qv-radius);
  padding: 0.4rem 0.35rem 0.6rem;
  font-size: 0.92rem;
}
.qv-tree ul { list-style: none; margin: 0; padding: 0; }
.qv-tree li { margin: 0; }
.qv-tree-root > li { border-radius: var(--qv-radius-sm); }
.qv-tree-all,
.qv-tree summary,
.qv-leaf,
.qv-tree details li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.28rem 0.55rem;
  border-radius: var(--qv-radius-sm);
}
.qv-tree summary { cursor: pointer; list-style: none; }
.qv-tree summary::-webkit-details-marker { display: none; }
.qv-tree summary::before {
  content: "";
  flex: 0 0 auto;
  align-self: center;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.15rem;
  border-right: 2px solid var(--qv-faint);
  border-bottom: 2px solid var(--qv-faint);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}
.qv-tree details[open] > summary::before { transform: rotate(45deg); }
.qv-tree summary a { flex: 1 1 auto; }
.qv-tree details ul { margin: 0.1rem 0 0.35rem 1.1rem; border-left: 1px solid var(--qv-line); }
.qv-tree details li { padding-left: 0.6rem; font-size: 0.88rem; }
.qv-tree a { color: var(--qv-text); text-decoration: none; }
.qv-tree a:visited { color: var(--qv-text); }
.qv-tree a:hover { color: var(--qv-gold); text-decoration: underline; }
.qv-tree a[aria-current="true"] { color: var(--qv-gold); font-weight: 650; }
.qv-tree-all.is-current,
.qv-tree .is-current > details > summary,
.qv-tree .is-current > .qv-leaf { background: rgba(230, 180, 34, 0.1); }
.qv-count { color: var(--qv-faint); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qv-tree-note { color: var(--qv-faint); font-size: 0.78rem; margin: 0.6rem 0.55rem 0; max-width: none; }

/* The results. */
.qv-results-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.qv-results-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--qv-text);
  font-variant-numeric: tabular-nums;
}
.qv-unit { color: var(--qv-dim); font-weight: 600; }
.qv-sort { display: inline-flex; align-items: center; gap: 0.5rem; }
.qv-sort label { color: var(--qv-dim); font-size: 0.85rem; }
.qv-sort select { width: auto; padding: 0.3rem 0.5rem; }
.qv-note { color: var(--qv-faint); font-size: 0.85rem; margin: 0.25rem 0 0.75rem; max-width: none; }
.qv-note strong { color: var(--qv-dim); font-weight: 600; }

.qv-table { font-size: 0.9rem; }
.qv-table th, .qv-table td { padding: 0.38rem 0.55rem; vertical-align: middle; }
.qv-table thead th { white-space: nowrap; border-bottom: 1px solid var(--qv-line-strong); }
.qv-table th[aria-sort] a { color: var(--qv-gold); }
.qv-table .q-name { min-width: 14rem; }
.qv-table .q-name > a { color: var(--qv-gold); text-decoration: none; font-weight: 600; }
.qv-table .q-name > a:visited { color: var(--qv-gold-dim); }
.qv-table .q-name > a:hover { text-decoration: underline; color: #fff; }
.qv-table .q-zone { color: var(--qv-dim); }
.qv-table .q-xp { color: var(--qv-gold); }
.qv-table .q-side-cell { width: 2.25rem; text-align: center; }
.qv-table .q-rewards { white-space: nowrap; }

/* GUIDE and PLAYERS: a jade and a blue-grey chip.  NEW (green) and CHANGED (amber) are the names the
 * classes will have when the hub keeps a history to say them from (quest_rows.html). */
.q-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border: 1px solid var(--qv-line-strong);
  border-radius: 4px;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 0.1em;
  white-space: nowrap;
}
.q-badge-guide { color: var(--qv-jade); border-color: var(--qv-jade-dim); }
.q-badge-players { color: var(--qv-dim); }
.q-badge-new { color: #7ddc8a; border-color: #3f8f4d; }
.q-badge-changed { color: #f0b24a; border-color: #9a6a1c; }

.q-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  margin-right: 3px;
  vertical-align: middle;
  border: 1px solid var(--qv-line-strong);
  border-radius: 4px;
  background: var(--qv-inset);
}
.q-icon.is-placeholder {
  text-align: center;
  line-height: 22px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--qv-faint);
}

.q-more td { text-align: center; padding: 0.8rem 0.6rem; }
.q-more:hover { background: transparent; }
.qv-pager { margin: 0.75rem 0 0; font-size: 0.9rem; }

.qv-foot { margin-top: 1.5rem; }
.qv-foot p { max-width: 90ch; font-size: 0.82rem; }
