/* Lab site styles. Colours come from Bootstrap's CSS variables so both the
   light (cosmo) and dark (darkly) themes work without extra rules. */

:root {
  --lab-ok: #1a7f37;
  --lab-bad: #c62828;
  --lab-warn: #b26a00;
  --lab-ok-bg: rgba(26, 127, 55, 0.12);
  --lab-bad-bg: rgba(198, 40, 40, 0.12);
  --lab-warn-bg: rgba(255, 170, 0, 0.18);
  --lab-radius: 10px;
  /* Own surface colors: Quarto's dark theme keeps Bootstrap's light values for
     --bs-tertiary-bg and --bs-border-color, which made light-on-light text. */
  --lab-subtle-bg: #f3f4f6;
  --lab-border: #dee2e6;
}
body.quarto-dark {
  --lab-subtle-bg: #2f3237;
  --lab-border: #4a4f57;
  --lab-ok: #56d364;
  --lab-bad: #ff7b72;
  --lab-warn: #f2cc60;
}

/* ---------- lab logo (top right of the navbar) ---------- */
.lab-logo { display: flex; align-items: center; margin-left: 14px; order: 1000; flex: none; }
.lab-logo img { height: 40px; width: auto; }
/* Quarto puts .quarto-light or .quarto-dark on <body> when the theme toggles. */
.lab-logo .logo-for-dark { display: none; }
body.quarto-dark .lab-logo .logo-for-light { display: none; }
body.quarto-dark .lab-logo .logo-for-dark { display: block; }
@media (max-width: 991px) { .lab-logo img { height: 30px; } }
@media (max-width: 767px) { .lab-logo { display: none; } }

/* ---------- landing page ---------- */
.course-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin: 1.2rem 0 2rem;
}
.course-map a.exp-tile {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  text-decoration: none;
  color: inherit;
  background: var(--bs-body-bg);
  transition: border-color 0.15s, transform 0.15s;
}
.course-map a.exp-tile:hover { border-color: var(--bs-primary); transform: translateY(-2px); }
.exp-tile .n { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bs-secondary-color); }
.exp-tile .t { font-weight: 600; margin: 2px 0 6px; line-height: 1.25; }
.exp-tile .d { font-size: 0.88rem; color: var(--bs-secondary-color); }
.exp-tile .tag { display: inline-block; font-size: 0.72rem; padding: 1px 7px; border-radius: 99px; background: var(--lab-subtle-bg); margin-top: 8px; }

.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: 1rem; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--bs-primary); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 0.9rem;
}

/* ---------- generic card used by every widget ---------- */
.lab-widget { margin: 1.2rem 0 1.6rem; }
.lab-card {
  border: 1px solid var(--lab-border);
  border-radius: var(--lab-radius);
  padding: 14px 16px;
  background: var(--bs-body-bg);
}
.lab-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; }
.lab-kicker { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--bs-primary); }
.lab-spacer { flex: 1; }
.lab-muted { color: var(--bs-secondary-color); }
.lab-small { font-size: 0.86rem; }
.strong { font-weight: 600; }
.lab-error { color: var(--lab-bad); }
.txt-ok { color: var(--lab-ok); font-weight: 600; }
.txt-bad { color: var(--lab-bad); font-weight: 600; }
.lab-card .form-select-sm, .lab-card .form-control-sm { width: auto; max-width: 100%; }

/* ---------- quiz ---------- */
.quiz-list { padding-left: 1.2rem; margin: 0; }
.quiz-list > li { margin-bottom: 1rem; }
.quiz-q { margin-bottom: 0.4rem; font-weight: 500; }
.quiz-options { display: grid; gap: 6px; }
.quiz-option {
  text-align: left; border: 1px solid var(--lab-border); background: transparent; color: inherit;
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.quiz-option:hover { border-color: var(--bs-primary); }
.quiz-option.is-correct { border-color: var(--lab-ok); background: var(--lab-ok-bg); }
.quiz-option.is-wrong { border-color: var(--lab-bad); background: var(--lab-bad-bg); }
.quiz-feedback { font-size: 0.9rem; margin-top: 6px; }
.quiz-feedback.right { color: var(--lab-ok); }
.quiz-feedback.wrong { color: var(--lab-bad); }
.quiz-feedback strong { margin-right: 4px; }

/* ---------- molecules ---------- */
.mol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.mol-card { margin: 0; border: 1px solid var(--lab-border); border-radius: 8px; overflow: hidden; }
.mol-view { position: relative; width: 100%; height: 170px; background: var(--lab-subtle-bg); }
.mol-meta { padding: 7px 10px; font-size: 0.85rem; }
.mol-name { font-weight: 600; }
.mol-dl { font-size: 0.78rem; word-break: break-all; }
.mol-picker { margin-bottom: 10px; }
.mol-picker + div .mol-view { height: 280px; }

/* ---------- predictions ---------- */
.pred-list { display: grid; gap: 12px; }
.pred-item { display: grid; grid-template-columns: 1fr minmax(160px, 220px); gap: 6px 14px; align-items: center; padding-bottom: 10px; border-bottom: 1px dashed var(--lab-border); }
.pred-item:last-child { border-bottom: 0; }
.pred-verdict, .pred-pending { grid-column: 1 / -1; font-size: 0.88rem; }
.pred-verdict.match { color: var(--lab-ok); }
.pred-verdict.miss { color: var(--lab-warn); }
.pred-pending { color: var(--bs-secondary-color); font-style: italic; }
.pred-card.is-locked { border-color: var(--lab-warn); }
@media (max-width: 600px) { .pred-item { grid-template-columns: 1fr; } }

/* ---------- jobs / Q-Chem inputs ---------- */
.job-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.job-progress .progress { flex: 0 0 180px; height: 8px; }
.job-layout { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 14px; }
.job-layout > * { min-width: 0; }
.job-list { max-height: 430px; overflow-y: auto; border: 1px solid var(--lab-border); border-radius: 8px; padding: 4px 0; }
.job-group { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--bs-secondary-color); padding: 8px 10px 2px; position: sticky; top: -4px; background: var(--bs-body-bg); }
.job-row { display: flex; align-items: center; gap: 8px; padding: 3px 10px; }
.job-row.is-current { background: var(--lab-subtle-bg); }
.job-row .form-check-input { margin: 0; flex: none; }
.job-link { background: none; border: 0; color: inherit; padding: 0; text-align: left; flex: 1; font-size: 0.9rem; cursor: pointer; }
.job-link:hover { text-decoration: underline; }
.risk { font-size: 0.7rem; padding: 1px 6px; border-radius: 99px; white-space: nowrap; }
.risk-low { background: var(--lab-ok-bg); color: var(--lab-ok); }
.risk-med { background: var(--lab-warn-bg); color: var(--lab-warn); }
.risk-high { background: var(--lab-bad-bg); color: var(--lab-bad); }
.job-preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.job-preview-title { font-family: var(--bs-font-monospace); font-size: 0.82rem; word-break: break-all; }
.job-preview { max-height: 380px; overflow: auto; font-size: 0.8rem; background: var(--lab-subtle-bg); padding: 10px; border-radius: 8px; margin: 0; }
@media (max-width: 760px) { .job-layout { grid-template-columns: 1fr; } .job-list { max-height: 260px; } }

/* ---------- results table ---------- */
.res-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--lab-border); margin-bottom: 8px; }
.res-tab { border: 1px solid transparent; border-bottom: 0; background: none; color: inherit; padding: 6px 12px; border-radius: 8px 8px 0 0; font-size: 0.9rem; cursor: pointer; }
.res-tab.active { border-color: var(--lab-border); background: var(--bs-body-bg); font-weight: 600; margin-bottom: -1px; }
.res-scroll { max-height: 560px; overflow: auto; }
.res-table { border-collapse: separate; border-spacing: 0; font-size: 0.86rem; font-variant-numeric: tabular-nums; width: auto; }
.res-table th, .res-table td { border-bottom: 1px solid var(--lab-border); padding: 3px 6px; vertical-align: middle; }
.res-table thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 1; font-weight: 600; min-width: 92px; vertical-align: bottom; }
.res-table tbody th { position: sticky; left: 0; background: var(--bs-body-bg); white-space: nowrap; font-weight: 500; }
.res-table .th-sub { font-weight: 400; font-size: 0.75rem; color: var(--bs-secondary-color); }
.res-table tr.res-group th { background: var(--lab-subtle-bg); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.res-table td { position: relative; }
.res-input { width: 130px; border: 1px solid var(--lab-border); border-radius: 5px; padding: 2px 5px; background: var(--bs-body-bg); color: inherit; font-variant-numeric: tabular-nums; }
.res-input:focus { outline: 2px solid var(--bs-primary); outline-offset: -1px; }
td.is-bad .res-input, td.is-mismatch .res-input { border-color: var(--lab-bad); background: var(--lab-bad-bg); }
td.is-ok .res-input { border-color: var(--lab-ok); background: var(--lab-ok-bg); }
td.is-incomplete .res-input { border-style: dashed; }
td.is-outlier .res-input { border-color: var(--lab-warn); background: var(--lab-warn-bg); }
.res-table td { white-space: nowrap; }
.cell-badge { display: inline-block; min-width: 3.4em; margin-left: 4px; font-size: 0.72rem; color: var(--bs-secondary-color); text-align: right; }
.cell-badge:empty { visibility: hidden; }
.res-help { margin: 4px 0 8px; }
.res-summary { font-size: 0.86rem; }
.res-table.compact td.num, .res-table.compact th { text-align: right; }
.res-table.compact tbody th { text-align: left; }
.err-big { color: var(--lab-bad); }
.err-small { color: var(--lab-ok); }

/* ---------- explore ---------- */
.explore-h { font-size: 1rem; margin: 0.4rem 0; }
.explore-chart { margin-top: 1.2rem; overflow-x: auto; }
.explore-chart figure, .explore-chart svg { max-width: 100%; height: auto; }
.explore-chart h2 { font-size: 1rem; }
.explore-chart figure h3 { font-size: 0.86rem; font-weight: 400; color: var(--bs-secondary-color); margin: 0 0 6px; border: 0; }

/* ---------- questions ---------- */
.q-list { padding-left: 1.2rem; }
.q-list > li { margin-bottom: 1rem; }
.q-text { margin-bottom: 0.35rem; }
.q-answer { font-size: 0.95rem; min-height: 80px; resize: vertical; }
.q-classify { display: grid; gap: 6px; }
.q-classify-row { display: grid; grid-template-columns: 120px minmax(0, 280px); gap: 10px; align-items: center; }
.q-muddy { border-top: 1px dashed var(--lab-border); padding-top: 10px; }

/* ---------- submit ---------- */
.submit-grid { display: grid; grid-template-columns: 1fr 260px; gap: 16px; }
.submit-id { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.submit-id input { flex: 1 1 200px; width: auto; }
.submit-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.submit-check { list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.9rem; }
.submit-check .ok { color: var(--lab-ok); }
.submit-check .todo { color: var(--bs-secondary-color); }
.submit-foot { border-top: 1px dashed var(--lab-border); margin-top: 10px; padding-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (max-width: 760px) { .submit-grid { grid-template-columns: 1fr; } }

/* ---------- Jacob's ladder (Ex2) ---------- */
.ladder-legend { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 0.86rem; margin: 0 0 12px; }
.ladder-legend dt { font-weight: 600; }
.ladder-legend dd { margin: 0; color: var(--bs-secondary-color); }
.ladder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.ladder-item { border: 1px solid var(--lab-border); border-radius: 8px; padding: 8px 10px; }
.ladder-item.is-right { border-color: var(--lab-ok); background: var(--lab-ok-bg); }
.ladder-item.is-wrong { border-color: var(--lab-bad); background: var(--lab-bad-bg); }
.ladder-name { font-weight: 600; margin-bottom: 4px; }
.ladder-item .form-select { width: 100%; }
.ladder-why { font-size: 0.8rem; margin-top: 6px; }

/* ---------- results: extra cell types ---------- */
.na-cell { color: var(--bs-secondary-color); text-align: center; opacity: 0.6; }
.computed-cell { white-space: nowrap; }
.res-import { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 10px; }
.csv-import { border: 1px dashed var(--lab-border); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; background: var(--lab-subtle-bg); }
.csv-import .res-import { margin-bottom: 6px; }
.csv-details summary { cursor: pointer; }
.csv-paste { width: 100%; max-width: 100%; font-family: var(--bs-font-monospace); font-size: 0.78rem; margin-top: 6px; }
.csv-status:not(:empty) { margin-top: 8px; }

/* ---------- explorers ---------- */
.lab-reveal { margin-top: 8px; border: 1px dashed var(--lab-border); border-radius: 8px; padding: 6px 10px; }
.lab-reveal summary { cursor: pointer; font-weight: 600; }
.anomaly-table td.anomaly-cell { padding: 3px; text-align: center; }
.anomaly-cell button { width: 100%; min-width: 84px; border: 1px solid var(--lab-border); background: transparent; color: inherit; border-radius: 6px; padding: 4px 6px; font-variant-numeric: tabular-nums; }
.anomaly-cell.picked button { border-color: var(--lab-warn); background: var(--lab-warn-bg); }
.anomaly-cell.right button { border-color: var(--lab-ok); background: var(--lab-ok-bg); }
.anomaly-cell.wrong button { border-color: var(--lab-bad); background: var(--lab-bad-bg); }
.anomaly-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.wiggle-cell { min-width: 150px; }
.wiggle-cell.smooth .strong { color: var(--lab-ok); }
.wiggle-cell.wiggly .strong { color: var(--lab-bad); }

/* ---------- Ex7 grid explorer ---------- */
.grid-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.grid-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.grid-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 14px; align-items: center; }
.grid-canvas { width: 100%; height: auto; background: var(--lab-subtle-bg); border-radius: 8px; }
.grid-stats .big, .result-numbers .big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.grid-stats > div { margin-bottom: 8px; }
@media (max-width: 760px) { .grid-layout { grid-template-columns: 1fr; } }

/* ---------- Ex8 stability landscape ---------- */
.landscape-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.landscape-controls .form-range { width: 200px; }
.landscape-svg { width: 100%; height: auto; max-height: 320px; display: block; }
.landscape-svg .curve { fill: none; stroke: var(--bs-primary); stroke-width: 3; }
.landscape-svg .ax { stroke: var(--bs-secondary-color); stroke-width: 1; }
.landscape-svg .dashed { stroke-dasharray: 4 4; }
.landscape-svg .lbl { fill: var(--bs-secondary-color); font-size: 12px; }
.landscape-svg .ball { fill: #d62728; stroke: var(--bs-body-bg); stroke-width: 2; }
.landscape-msg { border-left: 4px solid var(--lab-border); padding: 6px 10px; margin: 6px 0; font-size: 0.92rem; }
.landscape-msg.ok { border-color: var(--lab-ok); background: var(--lab-ok-bg); }
.landscape-msg.bad { border-color: var(--lab-bad); background: var(--lab-bad-bg); }

/* ---------- Ex9 NIST panel ---------- */
.nist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.nist-grid label { font-size: 0.86rem; font-weight: 600; display: grid; gap: 3px; }
.nist-grid .form-select, .nist-grid .form-control { width: 100%; }
.nist-eq { font-variant-numeric: tabular-nums; }

/* ---------- Ex10 method card and result ---------- */
.mc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 10px; }
.mc-grid label, .mc-why label { font-size: 0.86rem; font-weight: 600; display: grid; gap: 4px; }
.mc-grid { align-items: start; }
.mc-grid label { align-content: start; }
.mc-grid label > * { align-self: start; }
.mc-grid .form-select, .mc-grid .form-control { width: 100%; }
.mc-check { display: flex !important; align-items: center; gap: 6px; padding-top: 22px; }
.mc-why { display: grid; gap: 10px; margin: 10px 0; }
.mc-warn > div { color: var(--lab-warn); font-size: 0.9rem; margin: 3px 0; }
.mc-inputs details { margin: 4px 0; }
.mc-inputs summary { cursor: pointer; }
.result-card { border: 1px solid var(--lab-border); border-radius: var(--lab-radius); padding: 12px 16px; }
.result-method { font-weight: 700; margin-bottom: 8px; }
.result-numbers { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 10px; }
.numline { position: relative; height: 22px; margin: 6px 0 2px; border-bottom: 2px solid var(--lab-border); }
.numline-band { position: absolute; top: 4px; bottom: 0; background: var(--lab-ok-bg); border-left: 1px solid var(--lab-ok); border-right: 1px solid var(--lab-ok); }
.numline-zero { position: absolute; top: 0; bottom: -4px; width: 2px; background: var(--bs-body-color); transform: translateX(-1px); }
.numline-dot { position: absolute; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #d62728; transform: translateX(-7px); }
.numline-labels { display: flex; justify-content: space-between; }

/* ---------- Ex10 report ---------- */
.report-item input.form-control { font-weight: 600; margin-bottom: 6px; }
.report-body { min-height: 220px; }
.report-count { display: block; text-align: right; margin-top: 2px; }
.report-refs-label { margin: 10px 0 4px; }

/* ---------- static content helpers ---------- */
.ref-table { font-variant-numeric: tabular-nums; }
.output-annot pre { font-size: 0.8rem; }
mark.hl { background: var(--lab-warn-bg); color: inherit; padding: 0 2px; border-radius: 3px; }
.figure img { max-width: 100%; }
.reaction-fig img { max-width: 560px; }

/* Markdown tables scroll sideways on phones instead of widening the page. */
@media (max-width: 600px) {
  main table.table { display: block; overflow-x: auto; }
}

@media print {
  .lab-widget { display: none !important; }
}

/* Long display equations scroll inside their own box on narrow screens. */
mjx-container[display="true"] { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; }
