/**
 * webquest.css — WebQuest node display (Phase 2).
 *
 * Loaded only on webquest nodes (attached via the node template).
 * Two-column layout: sticky scrollspy sidebar + stacked section cards.
 */

/* Anchor jumps land below the sticky header, not under it. */
html {
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---- Layout -------------------------------------------------------- */
.wq__layout {
  display: flex;
  align-items: flex-start;
  gap: var(--gutter);
}

.wq__nav {
  flex: 0 0 240px;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.wq__sections {
  flex: 1 1 auto;
  min-width: 0;            /* let wide tables shrink instead of overflowing */
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

/* ---- Scrollspy sidebar --------------------------------------------- */
.wq-toc {
  background: var(--surface);
  border: 1px solid var(--surface-variant);
  border-radius: var(--r-xl);
  padding: 0.75rem;
}
.wq-toc__heading {
  margin: 0.25rem 0.75rem 0.5rem;
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tertiary);
}
.wq-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.wq-toc li { margin: 0; }
.wq-toc__link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-lg);
  color: var(--secondary);
  font-size: var(--fs-label);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.wq-toc__link:hover {
  background: var(--surface-low);
  color: var(--ink);
  text-decoration: none;
}
.wq-toc__link.is-current {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
}
.wq-toc__icon { font-size: 1.2rem; }

/* ---- Section cards ------------------------------------------------- */
.wq-section {
  background: var(--surface);
  border: 1px solid var(--surface-variant);
  border-radius: var(--r-xl);
  padding: var(--gutter);
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
}
.wq-section__title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--surface-variant);
  font-size: var(--fs-headline-md);
  font-weight: var(--fw-headline-md);
}
.wq-section__icon {
  flex: 0 0 auto;
  color: var(--brand);
  background: var(--brand-tint);
  border-radius: var(--r-lg);
  padding: 0.35rem;
  font-size: 1.4rem;
}

/* ---- Section body (user-authored formatted text) ------------------- */
.wq-section__body > :first-child { margin-top: 0; }
.wq-section__body > :last-child { margin-bottom: 0; }
.wq-section__body :is(h2, h3, h4) {
  font-size: var(--fs-title);
  margin: 1.5em 0 0.5em;
}
.wq-section__body a { color: var(--brand); }
.wq-section__body a:hover { color: var(--brand-hover); }
.wq-section__body ul,
.wq-section__body ol { padding-left: 1.4em; }
.wq-section__body li { margin: 0.25em 0; }

/* Rubric / data tables inside a section */
.wq-section__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: var(--fs-label);
}
.wq-section__body th,
.wq-section__body td {
  border: 1px solid var(--surface-variant);
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.wq-section__body th {
  background: var(--surface-low);
  color: var(--ink);
  font-weight: 600;
}
.wq-section__body tbody tr:nth-child(even) td { background: var(--surface-low); }
.wq-section__body caption {
  caption-side: top;
  text-align: left;
  color: var(--secondary);
  margin-bottom: 0.5em;
}

.wq-section__body a,
.wq-section__body td {
  overflow-wrap: break-word;   /* break long words/URLs only when needed */
  word-break: break-word;
}

.wq-section__body table {
  width: 100%;
  table-layout: fixed;   /* cells respect the table width instead of growing to fit content */
}

/* Comments block at the foot of the node */
.wq-section--comments { background: transparent; border: 0; padding: 0; }

/* ---- Responsive: drop the sidebar, stack full-width ---------------- */
@media (max-width: 900px) {
  .wq__layout { display: block; }
  .wq__nav { display: none; }
}
@media (max-width: 600px) {
  .wq-section { padding: var(--element-gap); }
  .wq-section__body { overflow-x: auto; }   /* wide rubric scrolls instead of clipping */
}
