/* Data Science page (topics/data-science.html): the trip explorer, the mini blockchain, the levels quick check,
   and reveal-on-demand answers. Uses the theme's custom properties so light and dark mode both work. */

/* Reveal-on-demand model answers */
.ds-answer { margin: .25rem 0 1.5rem; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px; background: var(--surface); }
.ds-answer > summary { cursor: pointer; padding: .7rem 1rem; font-weight: 700; font-size: .9rem; color: var(--primary); list-style: none; }
.ds-answer > summary::-webkit-details-marker { display: none; }
.ds-answer > summary::before { content: '\25B8'; display: inline-block; margin-right: .55rem; transition: transform .15s ease; }
.ds-answer[open] > summary::before { transform: rotate(90deg); }
.ds-answer > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.ds-answer[open] > summary { border-bottom: 1px solid var(--border); }
.ds-answer > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
.ds-answer > p, .ds-answer > .table-wrap, .ds-answer > .code-block, .ds-answer > ul, .ds-answer > ol { margin-top: .85rem; }
.ds-answer > :last-child { margin-bottom: 1rem; }
@media (prefers-reduced-motion: reduce) { .ds-answer > summary::before { transition: none; } }

/* Shared lab frame */
.ds-lab { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 1rem; margin: 1.25rem 0; }
.ds-lab h5, .ds-h5 { margin: 1.1rem 0 .4rem; font: 600 .95rem/1.3 var(--font-display); color: var(--text-primary); }
.ds-controls { display: flex; flex-wrap: wrap; gap: .6rem 1.25rem; align-items: flex-end; margin-bottom: .75rem; }
.ds-field { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; font-weight: 600; color: var(--text-secondary); }
.ds-field select, .ds-field input, .ds-blk-in, .ds-lv select {
  font: inherit; font-weight: 500; font-size: .9rem; padding: .35rem .5rem; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text-primary); min-height: 2.25rem;
}
.ds-field input { width: 6rem; }
.ds-check { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--text-primary); font-weight: 500; cursor: pointer; }
.ds-slicer { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.ds-slicer-title { font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-right: .2rem; }
.ds-pill {
  font: inherit; font-size: .85rem; font-weight: 600; padding: .3rem .75rem; border-radius: 999px; min-height: 2.25rem;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-secondary); cursor: pointer;
}
.ds-pill[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
:root[data-theme="dark"] .ds-pill[aria-pressed="true"] { color: #0A1220; }
.ds-pill:focus-visible, .ds-sort:focus-visible, .ds-lab select:focus-visible, .ds-lab input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ds-status { margin: .5rem 0 .75rem; font-size: .92rem; line-height: 1.55; color: var(--text-primary); }
.ds-status code, .ds-hrow code { font-family: var(--font-mono); font-size: .85em; }
.ds-cap { caption-side: top; text-align: left; font-size: .8rem; font-weight: 600; color: var(--text-secondary); padding: 0 0 .35rem; }
.ds-table-wrap table { font-size: .85rem; }
.ds-table-wrap th, .ds-table-wrap td { padding: .35rem .6rem; white-space: nowrap; }
.ds-num { text-align: right; font-variant-numeric: tabular-nums; }
.ds-sort { all: unset; cursor: pointer; font-weight: 700; color: inherit; }
.ds-table-wrap table tbody tr td.ds-hot { background: rgba(232, 163, 23, .3); font-weight: 700; }
:root[data-theme="dark"] .ds-table-wrap table tbody tr td.ds-hot { background: rgba(245, 184, 61, .28); }
.ds-total, .ds-grand th, .ds-grand td { font-weight: 700; }
.ds-grand { border-top: 2px solid var(--border-strong); }
.ds-bars { display: grid; gap: .3rem; margin: .75rem 0 .25rem; }
.ds-bar-row { display: grid; grid-template-columns: minmax(6.5rem, 9rem) 1fr 4.5rem; gap: .5rem; align-items: center; font-size: .85rem; }
.ds-bar-track { background: var(--bg-secondary); border-radius: 4px; height: 1rem; overflow: hidden; }
.ds-bar { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .25s ease; }
.ds-bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.ds-reset { margin-top: .5rem; padding: .35rem .9rem; font-size: .85rem; }
.ds-lab .code-block { margin: .25rem 0 .5rem; }

/* Mini blockchain */
.ds-chain { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.ds-block { border: 2px solid var(--text-primary); border-radius: 10px; background: var(--surface); padding: .6rem .7rem .7rem; display: flex; flex-direction: column; gap: .35rem; }
:root[data-theme="dark"] .ds-block { border-color: var(--border-strong); }
.ds-block.is-bad { background: rgba(220, 38, 38, .09); border-color: var(--danger); }
.ds-block-h { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .95rem; }
.ds-flag { font-size: .75rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: rgba(22, 163, 74, .16); color: #166534; }
:root[data-theme="dark"] .ds-flag { color: #86EFAC; }
.ds-block.is-bad .ds-flag { background: rgba(220, 38, 38, .16); color: #991B1B; }
:root[data-theme="dark"] .ds-block.is-bad .ds-flag { color: #FCA5A5; }
.ds-blk-l { font-size: .78rem; font-weight: 600; color: var(--text-secondary); }
.ds-blk-in { width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: .85rem; }
.ds-hrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem .5rem; font-size: .82rem; color: var(--text-secondary); }
.ds-hrow code { background: var(--bg-secondary); color: var(--text-primary); padding: .1rem .4rem; border-radius: 4px; font-weight: 700; }
.ds-hrow:last-of-type code { background: rgba(232, 163, 23, .3); }
.ds-verdict { font-size: .78rem; line-height: 1.4; color: var(--text-secondary); min-height: 2.2em; }
.ds-chain-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }
.ds-chain-btns .btn { padding: .4rem .9rem; font-size: .85rem; }
.ds-chain-btns .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Levels of measurement quick check */
.ds-levels-list { list-style: none; padding-left: 0; margin: 0 0 .75rem; display: grid; gap: .6rem; }
.ds-lv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .75rem; align-items: center; padding: .4rem .5rem; border-radius: 8px; }
.ds-lv-q { font-size: .92rem; color: var(--text-primary); }
.ds-lv-fb { grid-column: 1 / -1; font-size: .82rem; line-height: 1.45; color: var(--text-secondary); }
.ds-lv.is-right { background: rgba(22, 163, 74, .1); }
.ds-lv.is-wrong { background: rgba(220, 38, 38, .08); }

@media (max-width: 520px) {
  .ds-lab { padding: .75rem; }
  .ds-lv { grid-template-columns: 1fr; }
  .ds-bar-row { grid-template-columns: 5.5rem 1fr 3.5rem; }
  .ds-chain { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .ds-bar { transition: none; } }

/* Worked spreadsheet tables: column letters and row numbers look like a sheet */
.ds-sheet table { font-size: .82rem; }
.ds-sheet thead th { background: var(--bg-secondary); color: var(--text-secondary); font-weight: 600; text-align: center; }
.ds-sheet tbody th { background: var(--bg-secondary); color: var(--text-secondary); font-weight: 600; text-align: center; width: 2.2rem; }
.ds-sheet thead tr:nth-child(2) th { color: var(--text-primary); font-weight: 700; text-align: left; background: var(--surface-hover); }
.ds-sheet td, .ds-sheet th { white-space: nowrap; padding: .3rem .6rem; }
.ds-sheet caption { text-align: left; font-size: .8rem; color: var(--text-secondary); padding-bottom: .35rem; }
.ds-rel { display: grid; gap: .25rem; }
.ds-rel caption { text-align: left; font-weight: 700; font-size: .85rem; padding-bottom: .25rem; color: var(--text-primary); }
.ds-rel table { font-size: .82rem; }
.ds-rel td, .ds-rel th { padding: .3rem .6rem; white-space: nowrap; }

/* Dashboard wireframe */
.ds-dash { border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--bg-tertiary); padding: .9rem; margin: 1rem 0 1.25rem; }
.ds-dash-title { font: 700 1rem/1.3 var(--font-display); color: var(--text-primary); margin-bottom: .7rem; }
.ds-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: .7rem; }
.ds-kpi { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--primary); border-radius: 8px; padding: .55rem .7rem; display: flex; flex-direction: column; gap: .1rem; }
.ds-kpi-n { font: 700 1.5rem/1.15 var(--font-display); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.ds-kpi-l { font-size: .78rem; color: var(--text-secondary); }
.ds-dash-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.ds-dash-row:last-child { margin-bottom: 0; }
.ds-dash-cell { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 8px; padding: .7rem .8rem; font-size: .85rem; line-height: 1.45; color: var(--text-secondary); }
.ds-dash-cell strong { color: var(--text-primary); display: block; }
@media (max-width: 640px) {
  .ds-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-dash-row { grid-template-columns: 1fr; }
}

/* Keep field names as typed (the theme upper-cases table headings) */
.ds-sheet th, .ds-table-wrap th, .ds-rel th { text-transform: none; letter-spacing: 0; }
.ds-table-wrap tbody th { text-align: left; }

/* Labs built on the shared kit (css/labs.css) */
.ds-samp-dots svg, .ds-samp-hist svg { color: var(--text-secondary); }
.ds-samp-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .8rem; color: var(--text-secondary); }
.ds-samp-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.ds-samp-legend i { width: .8rem; height: .8rem; border-radius: 50%; display: inline-block; }
.ds-sampling .lab-chips { margin-top: .1rem; }
.ds-anomaly .lab-table { font-size: .82rem; }
.ds-an-input { width: 7.5rem; font: inherit; padding: .2rem .4rem; }

/* SQL practice */

/* Spreadsheet practice */
.ds-sheet-task { margin: .5rem 0 .6rem; font-weight: 600; line-height: 1.5; }
.ds-sheet-bar { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; }
.ds-sheet-addr { flex: none; min-width: 3rem; padding: .35rem .5rem; text-align: center; font: 700 .85rem var(--font-mono); border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-secondary); }
.ds-sheet-fx { flex: none; font: italic 700 .9rem serif; color: var(--text-secondary); }
.ds-sheet-bar input { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: .9rem; }
.ds-sheet-wrap { max-height: 26rem; overflow: auto; }
.ds-sheet-wrap:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ds-sheet-grid { border-collapse: collapse; font-size: .8rem; font-variant-numeric: tabular-nums; width: max-content; min-width: 100%; margin: 0; }
:root[data-theme] .lab .ds-sheet-grid th, :root[data-theme] .lab .ds-sheet-grid td { padding: .2rem .45rem; border: 1px solid var(--border); white-space: nowrap; background: var(--surface); color: var(--text-primary); font-weight: 400; line-height: 1.4; text-align: left; }
:root[data-theme] .lab .ds-sheet-grid thead th, :root[data-theme] .lab .ds-sheet-grid .ds-sheet-rowh { background: var(--bg-secondary); color: var(--text-secondary); font: 700 .72rem var(--font-mono); text-align: center; position: sticky; z-index: 1; }
:root[data-theme] .lab .ds-sheet-grid thead th { top: 0; }
:root[data-theme] .lab .ds-sheet-grid .ds-sheet-rowh { left: 0; }
:root[data-theme] .lab .ds-sheet-grid td.is-head { font-weight: 700; background: var(--bg-tertiary); }
:root[data-theme] .lab .ds-sheet-grid td.is-num { text-align: right; }
:root[data-theme] .lab .ds-sheet-grid td.is-formula { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
:root[data-theme] .lab .ds-sheet-grid td.is-err { color: var(--lab-bad-ink); background: var(--lab-bad); font-weight: 700; }
:root[data-theme] .lab .ds-sheet-grid td.is-ref { outline: 2px dashed var(--lab-info-line); outline-offset: -2px; background: var(--lab-info); color: var(--lab-info-ink); }
:root[data-theme] .lab .ds-sheet-grid td.is-sel { outline: 3px solid var(--primary); outline-offset: -2px; position: relative; z-index: 1; }
.ds-sheet-grid td { cursor: cell; }
.ds-anomaly .lab-split { grid-template-columns: minmax(0, 1fr); }
