/* Workbook tools: lab maps and self-check boxes */

.lab-map {
  height: 480px;
  margin: 1em 0;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  z-index: 0;
}
.lab-map img, .lab-map .leaflet-pane svg { max-width: none !important; max-height: none !important; }
/* Leaflet sets Helvetica/Arial, which has no Khmer glyphs: use the book's stack */
.lab-map.leaflet-container,
.lab-map .leaflet-popup-content,
.lab-map .leaflet-control { font-family: var(--md-text-font-family); }
.lab-map .leaflet-popup-content,
.lab-map .leaflet-control-layers,
.lab-map-legend { color: #212121; font-size: 0.72rem; line-height: 1.6; }

.lab-map-legend {
  background: rgba(255, 255, 255, 0.92);
  padding: 6px 10px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.lab-map-legend i {
  display: inline-block; vertical-align: middle; margin-right: 6px;
  width: 12px; height: 12px;
}
.lab-map-legend .lg-dot    { border-radius: 50%; background: var(--c); border: 1.5px solid #fff; box-shadow: 0 0 0 1px #999; }
.lab-map-legend .lg-dot-sm { border-radius: 50%; background: var(--c); width: 7px; height: 7px; margin: 0 8px 0 3px; }
.lab-map-legend .lg-box    { background: var(--c); opacity: 0.45; border: 1px solid var(--c); }
.lab-map-legend .lg-line   { height: 0; border-top: 3px solid var(--c); }

@media screen and (max-width: 600px) { .lab-map { height: 360px; } }

.self-check {
  margin: 0.8em 0;
  padding: 0.6em 0.9em;
  border-left: 4px solid var(--md-default-fg-color--lighter);
  background: var(--md-code-bg-color);
  border-radius: 0 4px 4px 0;
}
.self-check p { margin: 0 0 0.4em; }
.self-check[data-state="ok"]    { border-left-color: #2e7d32; }
.self-check[data-state="close"] { border-left-color: #f9a825; }
.self-check[data-state="bad"]   { border-left-color: #c62828; }

.sc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5em; }
.sc-input {
  flex: 0 1 12em;
  padding: 0.35em 0.6em;
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 4px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font: inherit;
}
.md-typeset .sc-button { padding: 0.3em 1em; margin: 0; font-size: 0.8em; }
.sc-result { font-size: 0.85em; }
.self-check[data-state="ok"]    .sc-result { color: #2e7d32; }
.self-check[data-state="close"] .sc-result { color: #b28704; }
.self-check[data-state="bad"]   .sc-result { color: #c62828; }

/* ---------- Legend extras ---------- */
.lab-map-legend .lg-dash { height: 0; border-top: 2px dashed var(--c); }
.lab-map { position: relative; }

/* ---------- Map tasks ---------- */
.map-tasks {
  margin: 1em 0 -0.4em; padding: 0.6em 0.9em;
  border: 1px solid var(--md-default-fg-color--lightest); border-left: 4px solid var(--md-primary-fg-color);
  border-radius: 6px 6px 0 0; background: var(--md-code-bg-color); font-size: 0.8rem;
}
.map-tasks[data-state="ok"]  { border-left-color: #2e7d32; }
.map-tasks[data-state="bad"] { border-left-color: #c62828; }
.mt-head { font-size: 0.7rem; opacity: 0.7; }
.mt-q { margin: 0.2em 0; }
.mt-fb { min-height: 1.4em; }
.map-tasks[data-state="ok"] .mt-fb  { color: #2e7d32; }
.map-tasks[data-state="bad"] .mt-fb { color: #c62828; }
.md-typeset .map-tasks .md-button { padding: 0.15em 0.8em; margin: 0 0 0 0.4em; font-size: 0.75rem; }

/* ---------- Attribute table ---------- */
.attr-table { margin: -0.6em 0 1em; border: 1px solid var(--md-default-fg-color--lightest); border-top: 0; border-radius: 0 0 6px 6px; font-size: 0.72rem; }
.at-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.4em 0.7em; background: var(--md-code-bg-color); gap: 0.5em; flex-wrap: wrap; }
.at-select { font: inherit; padding: 0.15em 0.3em; color: var(--md-default-fg-color); background: var(--md-default-bg-color); border: 1px solid var(--md-default-fg-color--lighter); border-radius: 3px; }
.at-scroll { max-height: 230px; overflow: auto; }
.md-typeset .attr-table table { display: table; width: 100%; margin: 0; font-size: inherit; border: 0; }
.md-typeset .attr-table th { position: sticky; top: 0; background: var(--md-default-bg-color); cursor: pointer; white-space: nowrap; padding: 0.4em 0.7em; }
.md-typeset .attr-table td { padding: 0.25em 0.7em; }
.attr-table tbody tr { cursor: pointer; }
.attr-table tbody tr:hover { background: var(--md-accent-fg-color--transparent); }
.attr-table tbody tr.at-sel { background: rgba(0, 229, 255, 0.25); }

/* ---------- Swipe ---------- */
.swipe-ui { position: absolute; inset: 0; pointer-events: none; z-index: 800; }
.swipe-line { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 4px rgba(0,0,0,.6); }
.swipe-handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 34px; height: 34px; border-radius: 50%;
  background: #fff; color: #333; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 1px 5px rgba(0,0,0,.5); }
.swipe-label { position: absolute; top: 10px; padding: 2px 10px; border-radius: 12px; background: rgba(33,33,33,.8); color: #fff; font-size: 0.72rem; }
.swipe-l { left: 55px; } .swipe-r { right: 55px; }
.swipe-range { position: absolute; left: 0; width: 100%; top: 50%; transform: translateY(-50%); margin: 0; height: 34px;
  -webkit-appearance: none; appearance: none; background: transparent; pointer-events: auto; cursor: ew-resize; opacity: 0; }

/* ---------- Bar chart ---------- */
.lab-chart { margin: 1em 0; padding: 0.8em 1em; border: 1px solid var(--md-default-fg-color--lightest); border-radius: 6px; font-size: 0.75rem; }
.ch-title { font-weight: 700; margin-bottom: 0.5em; }
.ch-group { margin: 0.5em 0; }
.ch-cat { display: flex; gap: 0.6em; align-items: baseline; }
.ch-delta { font-size: 0.68rem; padding: 0 6px; border-radius: 8px; }
.ch-delta.neg { background: #ffebee; color: #c62828; } .ch-delta.pos { background: #e8f5e9; color: #2e7d32; }
.ch-row { display: grid; grid-template-columns: 3.2em 1fr 7em; align-items: center; gap: 0.5em; }
.ch-sname { opacity: 0.7; }
.ch-bar { display: block; height: 14px; width: 0; background: var(--c); border-radius: 0 3px 3px 0; transition: width 1s ease-out; }
.ch-in .ch-bar { width: var(--w); }
.ch-val { text-align: right; font-variant-numeric: tabular-nums; }
.ch-note { margin-top: 0.6em; font-size: 0.68rem; opacity: 0.7; }

/* ---------- Change matrix ---------- */
.change-matrix { margin: 1em 0; }
.cm-scroll { overflow-x: auto; }
.md-typeset .change-matrix table { display: table; margin: 0; font-size: 0.72rem; }
.md-typeset .change-matrix th, .md-typeset .change-matrix td { padding: 0.35em 0.6em; text-align: right; white-space: nowrap; }
.change-matrix td.cm-off { background: rgba(230, 81, 0, var(--a)); cursor: pointer; }
.change-matrix td.cm-diag { background: rgba(46, 125, 50, 0.18); cursor: pointer; font-weight: 700; }
.change-matrix td.cm-sum { opacity: 0.75; font-style: italic; }
.change-matrix td.cm-sel { outline: 3px solid #00b8d4; outline-offset: -3px; }
.cm-corner { font-size: 0.65rem; line-height: 1.3; }
.cm-info { margin-top: 0.5em; padding: 0.5em 0.8em; background: var(--md-code-bg-color); border-radius: 4px; font-size: 0.78rem; min-height: 2.2em; }

/* ---------- Matching quiz ---------- */
.match-quiz { margin: 1em 0; padding: 0.8em 1em; border: 1px solid var(--md-default-fg-color--lightest); border-radius: 6px; }
.mq-title { font-weight: 700; } .mq-hint { font-size: 0.7rem; opacity: 0.7; margin-bottom: 0.5em; }
.mq-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.8em; }
.mq-col { display: flex; flex-direction: column; gap: 0.4em; }
.mq-item { font: inherit; font-size: 0.75rem; text-align: left; padding: 0.45em 0.7em; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--md-default-fg-color--lighter); background: var(--md-default-bg-color); color: var(--md-default-fg-color); transition: all .2s; }
.mq-item:hover:not(:disabled) { border-color: var(--md-primary-fg-color); }
.mq-pick { border-color: #1976d2 !important; box-shadow: 0 0 0 2px rgba(25,118,210,.35); }
.mq-ok { background: #e8f5e9; border-color: #66bb6a; color: #1b5e20; cursor: default; }
.mq-bad { background: #ffebee; border-color: #e57373; animation: mq-shake .3s; }
@keyframes mq-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.mq-score { margin-top: 0.6em; font-size: 0.78rem; }
.md-typeset .mq-score .md-button { padding: 0.15em 0.8em; font-size: 0.72rem; margin-left: 0.5em; }
@media screen and (max-width: 600px) { .mq-cols { grid-template-columns: 1fr; } }

/* ---------- Raster simulator ---------- */
.raster-sim { margin: 1em 0; padding: 0.8em 1em; border: 1px solid var(--md-default-fg-color--lightest); border-radius: 6px; font-size: 0.75rem; }
.rs-controls { display: flex; flex-wrap: wrap; gap: 0.4em 1.2em; align-items: center; margin-bottom: 0.5em; }
.rs-controls input[type=range] { vertical-align: middle; margin-left: 0.4em; }
.rs-rules label { margin-left: 0.6em; }
.rs-canvas { display: block; }
.rs-stats { display: flex; flex-wrap: wrap; gap: 0.3em 1.4em; margin-top: 0.5em; }
.rs-good { color: #2e7d32; } .rs-bad { color: #c62828; }
