/* LABS — the lab-values button and pane on Step 3 practice
   (practice/labs-pane.js, data practice/labs-data.js).

   Seth, 2026-10-13: a "Labs" button right of the run bar; the labs open "on
   the right side pane ... you can drag it to the left and the right and it
   will resize"; on a phone "it just takes up the full screen and then you can
   click the X button to exit".

   Desktop: html.dd-labs-docked — the page gives up --dd-labs-w on the right
   (body padding, so the sticky top band and the centred floating notch
   re-centre in what is left), and the bottom-right bubbles move over with it.
   Phone (≤ 760px): html.dd-labs-full — the pane is the screen.
   Off the run (no html.dd-run) nothing here shows. Token-only colours. */

/* ---- THE BUTTON: the run bar's twin, right of it ------------------------- */
.labs-btn {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;   /* = the run bar's and the timer tab's */
  box-shadow: 0 6px 20px var(--shadow-soft);
  color: var(--text);
  cursor: pointer;
  display: none;
  flex: none;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  gap: 8px;
  letter-spacing: 0.2px;
  padding: 0 18px;
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease, transform 120ms ease;
}
html.dd-run .labs-btn {
  display: inline-flex;
}
.labs-btn svg {
  color: var(--muted);
  transition: color 120ms ease, transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.labs-btn:hover {
  border-color: var(--border-strong);
}
.labs-btn:hover svg {
  color: var(--text);
  transform: rotate(-12deg);
}
.labs-btn:active {
  transform: scale(0.97);
}
.labs-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.labs-btn.is-on {
  /* The wash over the box's own fill: the notch floats over the page. */
  background: linear-gradient(rgb(var(--accent-rgb) / 0.12), rgb(var(--accent-rgb) / 0.12)), var(--surface-2);
  border-color: var(--accent);
  color: var(--accent-text);
}
.labs-btn.is-on svg {
  color: var(--accent);
}
.labs-btn[hidden],
html:not(.dd-run) .labs-btn {
  display: none;
}

/* The notch is centred by `left: 50%`, so it may shrink to half the bar's
   width — and a third box made the run bar cut its own words. As wide as its
   three boxes, then (a phone sets its own width, styles/run-bar.css). */
@media (min-width: 761px) {
  html.dd-run .practice-notch:has(.labs-btn:not([hidden])) {
    max-width: calc(100% - 24px);
    width: max-content;
  }
}

/* ---- THE PAGE GIVES UP THE RIGHT EDGE ------------------------------------ */
html.dd-run.dd-labs-docked body {
  padding-right: var(--dd-labs-w, 420px);
}
html.dd-run body {
  transition: padding-right 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
html.dd-labs-dragging body {
  cursor: col-resize;
  transition: none;
  user-select: none;
}
/* The "?" help and the Chat launcher (feedback-widget/) sit bottom-right. */
html.dd-run.dd-labs-docked .dd-help-launch,
html.dd-run.dd-labs-docked .dsc-launch,
html.dd-run.dd-labs-docked .dsc-toast,
html.dd-run.dd-labs-docked .dsc-panel {
  right: calc(var(--dd-labs-w, 420px) + 20px);
  transition: right 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
html.dd-labs-dragging .dd-help-launch,
html.dd-labs-dragging .dsc-launch {
  transition: none;
}

/* ---- THE PANE ------------------------------------------------------------- */
.labs-pane {
  background: var(--panel);
  border-left: 1px solid var(--border);
  bottom: 0;
  box-shadow: -14px 0 40px var(--shadow-soft);
  color: var(--text);
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  font-family: var(--ui-font);
  position: fixed;
  right: 0;
  top: 0;
  width: var(--dd-labs-w, 420px);
  z-index: 40;   /* over the page and the notch (30), under any modal */
}
.labs-pane[hidden],
html:not(.dd-run) .labs-pane {
  display: none;
}
.labs-pane.is-in {
  animation: labs-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes labs-in {
  from { opacity: 0.4; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}
.labs-pane.is-in .labs-sec {
  animation: labs-rise 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.labs-pane.is-in .labs-sec:nth-child(2) { animation-delay: 40ms; }
.labs-pane.is-in .labs-sec:nth-child(3) { animation-delay: 80ms; }
.labs-pane.is-in .labs-sec:nth-child(n + 4) { animation-delay: 120ms; }
@keyframes labs-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* The left edge: 10px to grab, the course builder's grip to see. */
.labs-split {
  bottom: 0;
  cursor: col-resize;
  display: grid;
  left: -5px;
  place-items: center;
  position: absolute;
  top: 0;
  touch-action: none;
  width: 10px;
  z-index: 2;
}
.labs-split-grip {
  background: var(--muted-dim);
  border-radius: 4px;
  height: 44px;
  opacity: 0.7;
  transition: background-color 150ms ease, height 150ms ease, opacity 150ms ease;
  width: 4px;
}
.labs-split:hover .labs-split-grip,
.labs-split:focus-visible .labs-split-grip,
html.dd-labs-dragging .labs-split-grip {
  background: var(--accent);
  height: 72px;
  opacity: 1;
}
.labs-split:focus-visible {
  outline: none;
}

/* Head: the title in the question's own serif, the close at the right. */
.labs-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 18px 18px 10px 22px;
}
.labs-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.labs-title {
  color: var(--text);
  font-family: var(--prose-heading);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.2px;
  line-height: 1.15;
  margin: 0;
}
.labs-source {
  color: var(--muted);
  font-size: 12px;
}
.labs-close {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: none;
  height: 34px;
  justify-content: center;
  padding: 0;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
  width: 34px;
}
.labs-close:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.labs-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Search: across every tab at once. */
.labs-find {
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  margin: 0 18px 12px 22px;
  padding: 0 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.labs-find:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / 0.18);
}
.labs-find-input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  font: inherit;
  font-size: 14px;
  min-width: 0;
  outline: none;
  padding: 9px 0;
}
.labs-find-input::placeholder {
  color: var(--muted-dim);
}

/* Tabs: the exam's four, an accent rule under the one shown. */
.labs-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 14px 0 18px;
  scrollbar-width: none;
}
.labs-tab {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 8px 11px;
  position: relative;
  transition: color 120ms ease;
  white-space: nowrap;
}
.labs-tab::after {
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  bottom: -1px;
  content: "";
  filter: drop-shadow(0 0 3px rgb(var(--accent-rgb) / 0.55));
  height: 2px;
  left: 8px;
  position: absolute;
  right: 8px;
  transform: scaleX(0);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.labs-tab:hover {
  color: var(--text);
}
.labs-tab.is-on {
  color: var(--text);
}
.labs-tab.is-on::after {
  transform: scaleX(1);
}
.labs-tab:focus-visible {
  border-radius: 6px;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.labs-pane.is-searching .labs-tab {
  opacity: 0.55;
}

/* Column heads: the table's, small caps. */
.labs-cols {
  color: var(--muted-dim);
  display: grid;
  font-size: 10.5px;
  font-weight: 700;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  letter-spacing: 0.08em;
  padding: 8px 18px 6px 22px;
  text-transform: uppercase;
}
.labs-col-si {
  display: none;
}

.labs-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 0 28px;
  scrollbar-width: thin;
}

.labs-sec + .labs-sec {
  margin-top: 6px;
}
.labs-sec-title {
  align-items: center;
  background: var(--panel);
  color: var(--accent-text);
  display: flex;
  font-size: 11px;
  font-weight: 750;
  gap: 8px;
  letter-spacing: 0.09em;
  margin: 0;
  padding: 12px 18px 6px 22px;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}
.labs-sec-title::before {
  background: var(--accent);
  border-radius: 2px;
  content: "";
  flex: none;
  height: 10px;
  width: 3px;
}

/* A row: test on the left, value(s) on the right; SI under it when narrow. */
.labs-row {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  padding: 8px 18px 8px 22px;
  transition: background-color 100ms ease;
}
.labs-sec-title + .labs-row {
  border-top-color: transparent;
}
.labs-row:hover {
  background: rgb(var(--tint-rgb) / 0.045);
}
.labs-name {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
}
.labs-row.is-sub .labs-name {
  color: var(--muted);
  padding-left: 14px;
  position: relative;
}
.labs-row.is-sub .labs-name::before {
  border-bottom: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
  content: "";
  height: 8px;
  left: 2px;
  position: absolute;
  top: 2px;
  width: 7px;
}
.labs-vals {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.labs-line {
  display: flex;
  flex-wrap: wrap;
  gap: 1px 8px;
  line-height: 1.4;
}
.labs-tag {
  align-self: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  flex-basis: 100%;
  font-size: 10.5px;
  font-weight: 600;
  justify-self: start;
  letter-spacing: 0.02em;
  max-width: max-content;
  padding: 0 6px;
}
.labs-conv {
  color: var(--text);
  flex-basis: 100%;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.labs-si {
  color: var(--muted);
  flex-basis: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.labs-hit {
  background: rgb(var(--accent-rgb) / 0.3);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgb(var(--accent-rgb) / 0.3);
  color: inherit;
}
.labs-none {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 22px;
}
.labs-none strong {
  color: var(--text);
}

/* Wide enough: the SI column stands on its own, as on the exam's sheet. */
@container (min-width: 560px) {
  .labs-cols,
  .labs-row {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.9fr) minmax(0, 0.9fr);
  }
  .labs-col-si {
    display: block;
  }
  .labs-vals {
    grid-column: span 2;
  }
  .labs-line {
    display: grid;
    gap: 2px 12px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .labs-tag {
    grid-column: 1 / -1;
  }
  .labs-si {
    font-size: 13px;
  }
}

/* ---- A PHONE: the pane is the screen, X to leave ------------------------- */
@media (max-width: 760px) {
  html.dd-labs-full .labs-pane {
    border-left: 0;
    box-shadow: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    width: 100%;
    z-index: 2147483002;   /* over the help bubbles */
  }
  html.dd-run.dd-labs-full {
    overflow: hidden;   /* <html> is the scrolling element (styles/base.css) */
  }
  .labs-split {
    display: none;
  }
  .labs-pane.is-in {
    animation-name: labs-up;
  }
  .labs-head {
    align-items: center;
    padding: 12px 10px 8px 18px;
  }
  .labs-close {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
    height: 42px;
    width: 42px;
  }
  .labs-find {
    margin: 0 14px 10px 18px;
  }
  .labs-find-input {
    font-size: 16px;   /* under 16px, iOS zooms the page on focus */
  }
  .labs-btn {
    font-size: 13px;
    gap: 5px;
    padding: 0 11px;
  }
}
@keyframes labs-up {
  from { opacity: 0.4; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .labs-pane.is-in,
  .labs-pane.is-in .labs-sec {
    animation: none;
  }
  html.dd-run body,
  .labs-tab::after {
    transition: none;
  }
}
