/* Microscope Mystery: the Microscopy Bench (microscope + eyepiece view, nosepiece, status line) and the observation
   log. Art by art.js. The eyepiece view stays a bright-field image in both themes; colors from the --mm-* properties. */
html {
  --mm-ink: #172433; --mm-bench1: #2c4a66; --mm-bench2: #1b3045; --mm-wood1: #6e4f37; --mm-wood2: #4a3324;
  --mm-log1: #f4f7fa; --mm-log2: #e7eef4; --mm-line: #c3d0db; --mm-chip: #ffffff; --mm-chip-on: #dce9f5; --mm-chip-line: #a9bccc;
  --mm-accent: #2f5f86; --mm-ok: #13704a; --mm-bad: #b3261e; --mm-card: #ffffff; --mm-muted: #4a5a6a;
  --mm-label: #fffbe9; --mm-label2: #efe3b8;
}
html[data-theme="dark"] {
  --mm-ink: #e5edf4; --mm-bench1: #1d3346; --mm-bench2: #101d29; --mm-wood1: #47321f; --mm-wood2: #2b1e13;
  --mm-log1: #18222c; --mm-log2: #121a22; --mm-line: #33475a; --mm-chip: #15202a; --mm-chip-on: #22405c; --mm-chip-line: #3f5a72;
  --mm-accent: #8fc1ea; --mm-ok: #4fd08c; --mm-bad: #ff8a80; --mm-card: #1b2733; --mm-muted: #a9bac9;
  --mm-label: #2a2717; --mm-label2: #3a351c;
}
.mm { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 12px; padding: 10px; font-size: 16px; color: var(--mm-ink); }
.mm *, .mm *::before, .mm *::after { box-sizing: border-box; }
.mm p { margin: 0; }
.mm button, .mm input { font: inherit; }
.mm :focus-visible { outline: 3px solid #d08a00; outline-offset: 2px; }

/* bench */
.mm-bench { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 8px; min-width: 0; min-height: 0; padding: 8px 10px 10px; border-radius: 14px; color: #eef4f9;
  background: linear-gradient(180deg, var(--mm-bench1) 0, var(--mm-bench2) 74%, var(--mm-wood1) 74%, var(--mm-wood2) 100%);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.25), 0 3px 8px rgba(0,0,0,.18); overflow: hidden; }
.mm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mm-sign { margin-right: auto; }
.mm-sign { padding: 2px 12px; border-radius: 6px; background: #0f1d2a; color: #e8f1f8; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; box-shadow: inset 0 -2px 0 rgba(0,0,0,.35); }
.mm-tag { padding: 1px 10px; border-radius: 999px; background: rgba(0,0,0,.35); font-weight: 700; }
.mm-body { display: grid; grid-template-columns: minmax(150px, 190px) minmax(0, 1fr); gap: 12px; min-height: 0; align-items: center; justify-items: center; }
.mm-viewwrap { width: 100%; height: 100%; min-height: 0; container-type: size; display: grid; place-items: center; }
.mm-side { width: 100%; height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; }
.mm-scope-art { display: block; width: 100%; height: 100%; max-height: 420px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.mm-turret { transition: transform .6s cubic-bezier(.4,.1,.2,1); }
.mm-beam { transition: opacity .4s; }
.mm-view { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); border-radius: 16px; box-shadow: 0 6px 14px rgba(0,0,0,.45); }
.mm-view:focus-visible { outline-offset: 3px; }
.mm-view-svg { display: block; width: 100%; height: 100%; border-radius: 16px; }
.mm-view.is-focusing .mm-view-svg { animation: mm-focus .5s ease-out; }
@keyframes mm-focus { from { filter: blur(7px) brightness(.7); } to { filter: none; } }
.mm-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; min-height: 0 !important; padding: 0 !important; }
.mm--identify .mm-body { grid-template-columns: minmax(0, 1fr); }
.mm--identify .mm-side { display: none; }
.mm-label { width: 100%; padding: 8px 12px; border-radius: 6px; color: #2b2615; line-height: 1.35;
  background: linear-gradient(175deg, var(--mm-label), var(--mm-label2)); border-top: 6px solid rgba(47,95,134,.7); box-shadow: 0 3px 6px rgba(0,0,0,.35); }
html[data-theme="dark"] .mm-label { color: #f3ecd2; }
.mm-label-h { display: inline; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #2f5f86; margin-right: 8px !important; }
.mm-label-t { display: inline; }
html[data-theme="dark"] .mm-label-h { color: #f1c97a; }

/* controls row */
.mm-ctrl { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: 8px; }
.mm-nose { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; flex: 1 1 300px; max-width: 420px; }
.mm-obj { position: relative; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 10px; border: 2px solid #9fb6ca; border-radius: 10px;
  background: #e9f1f7; color: #172433; cursor: pointer; text-align: left; }
.mm-obj-t { display: flex; flex-direction: column; line-height: 1.1; }
.mm-obj-t b { font-size: 18px; }
.mm-obj-t small { font-size: 16px; }
.mm-band { flex: none; width: 12px; height: 30px; border-radius: 3px; background: var(--band); box-shadow: inset 0 0 0 2px rgba(0,0,0,.3); }
.mm-obj[aria-pressed="true"] { background: #0f1d2a; color: #ffffff; border-color: #ffd23f; box-shadow: inset 0 0 0 2px #ffd23f; }
.mm-obj:disabled { cursor: default; }
.mm-obj.is-key { border-color: var(--mm-ok); box-shadow: inset 0 0 0 2px #4fd08c; }
.mm-obj.is-wrong { border-color: var(--mm-bad); box-shadow: inset 0 0 0 2px #ff8a80; }
.mm-obj .mm-mark { position: absolute; top: calc(50% - 12px); left: 4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: #ffffff; color: #172433; border: 2px solid currentColor; }
.mm-obj.is-key .mm-mark { color: #13704a; }
.mm-obj.is-wrong .mm-mark { color: #b3261e; }
.mm-open { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 6px 16px; border: 2px solid #ffd23f; border-radius: 10px;
  background: #ffd23f; color: #1d252e; font-weight: 800; cursor: pointer; flex: 0 1 auto; }
.mm-open svg { width: 24px; height: 24px; flex: none; }
.mm-open.is-open { background: rgba(0,0,0,.3); color: #e8f1f8; border-color: rgba(255,255,255,.35); }
.mm-open:disabled { cursor: default; }
.mm-status { min-height: calc(2 * 1.35em + 12px); padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.35); line-height: 1.35; color: #f4efe6; }
.mm-status b { color: #ffd23f; }

/* reveal animations (practice only; reveal() never runs in assess mode) */
.mm-seg, .mm-count, .mm-callout { opacity: 0; animation: mm-pop .35s ease-out forwards; }
.mm-dim { animation: mm-fade .5s ease-out both; }
@keyframes mm-pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes mm-fade { from { opacity: 0; } to { opacity: 1; } }

/* About this model: a pop-over panel on the bench */
.mm-about summary { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 12px 2px 6px; border-radius: 999px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.3); font-weight: 700; cursor: pointer; list-style: none; }
.mm-about summary::-webkit-details-marker { display: none; }
.mm-about summary::before { content: 'i'; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 6px; border-radius: 50%; background: #e8f1f8; color: #0f1d2a; font-weight: 800; font-style: italic; }
.mm-about[open] summary { background: #e8f1f8; color: #0f1d2a; }
.mm-about p { position: absolute; z-index: 6; left: 10px; right: 10px; top: 48px; padding: 12px 14px; border-radius: 10px; background: var(--mm-card); color: var(--mm-ink); border: 2px solid var(--mm-accent); line-height: 1.4; box-shadow: 0 8px 20px rgba(0,0,0,.4); }

/* log */
.mm-log { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; overflow: auto; padding: 10px 12px; border-radius: 14px;
  background: linear-gradient(180deg, var(--mm-log1), var(--mm-log2)); border: 3px solid var(--mm-accent); }
.mm-log-h { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--mm-accent); }
.mm-card { padding: 8px 10px; border-radius: 8px; background: var(--mm-card); border: 1px solid var(--mm-line); line-height: 1.35; }
.mm-calchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.mm-calchip { padding: 2px 10px; border-radius: 999px; background: var(--mm-chip-on); font-weight: 700; }
.mm-card-t { color: var(--mm-muted); }
.mm-step { display: flex; flex-direction: column; gap: 6px; }
.mm-step-h { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.mm-step-t { flex: 1; min-width: 0; }
.mm-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--mm-accent); color: var(--mm-log1); font-weight: 800; }
.mm-step.is-done .mm-n { box-shadow: 0 0 0 3px var(--mm-chip-on); }
.mm-mark { flex: none; font-weight: 800; }
.mm-mark.is-ok { color: var(--mm-ok); }
.mm-mark.is-bad { color: var(--mm-bad); }
.mm-num { display: flex; align-items: stretch; max-width: 280px; }
.mm-num input { flex: 1; min-width: 0; min-height: 46px; padding: 6px 10px; border: 2px solid var(--mm-chip-line); border-right: 0; border-radius: 10px 0 0 10px; background: var(--mm-chip); color: var(--mm-ink); font-size: 18px; }
.mm-unit { display: grid; place-items: center; min-width: 52px; padding: 0 10px; border: 2px solid var(--mm-chip-line); border-radius: 0 10px 10px 0; background: var(--mm-chip-on); font-weight: 700; }
.mm-step.is-ok .mm-num input { border-color: var(--mm-ok); }
.mm-step.is-bad .mm-num input { border-color: var(--mm-bad); }
.mm-chips { display: grid; grid-template-columns: 1fr; gap: 5px; }
.mm--identify { grid-template-columns: minmax(0, 1fr) 540px; }
.mm-chips--identity { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mm-chip { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 3px 10px; border: 2px solid var(--mm-chip-line); border-radius: 10px; background: var(--mm-chip); color: var(--mm-ink);
  text-align: left; line-height: 1.25; cursor: pointer; }
.mm-chip svg { width: 22px; height: 22px; flex: none; }
.mm-chip-t { flex: 1; min-width: 0; }
.mm-chip-m { flex: none; font-weight: 800; }
.mm-chip[aria-pressed="true"] { background: var(--mm-chip-on); border-color: var(--mm-accent); box-shadow: inset 0 0 0 1px var(--mm-accent); }
.mm-chip:disabled { cursor: default; }
.mm-chip.is-key { border-color: var(--mm-ok); box-shadow: inset 0 0 0 2px var(--mm-ok); }
.mm-chip.is-key .mm-chip-m { color: var(--mm-ok); }
.mm-chip.is-wrong { border-color: var(--mm-bad); border-style: dashed; }
.mm-chip.is-wrong .mm-chip-m { color: var(--mm-bad); }
.mm-key { font-weight: 700; color: var(--mm-bad); }
.mm.is-locked .mm-num input { opacity: 1; color: var(--mm-ink); -webkit-text-fill-color: var(--mm-ink); }

/* Briefing worked example */
.mm-ex svg { display: block; width: 100%; height: auto; }
.mm-ex .mm-count, .mm-ex .mm-dim, .mm-ex .mm-seg, .mm-ex .mm-callout { animation: none; opacity: 1; }

@media (max-width: 1180px) and (min-width: 901px) {
  .mm { grid-template-columns: minmax(0, 1fr) 380px; }
  .mm--identify { grid-template-columns: minmax(0, 1fr) 460px; }
  .mm-body { grid-template-columns: minmax(110px, 140px) minmax(0, 1fr); }
  .mm--identify .mm-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .mm { position: static; grid-template-columns: 1fr; }
  .mm-bench { overflow: visible; grid-template-rows: auto auto auto auto; background: linear-gradient(180deg, var(--mm-bench1), var(--mm-bench2)); }
  .mm-body { grid-template-columns: minmax(90px, 150px) minmax(0, 420px); justify-content: center; }
  .mm-viewwrap { container-type: normal; height: auto; }
  .mm-view { width: 100%; height: auto; aspect-ratio: 1; max-width: 420px; }
  .mm-log { overflow: visible; }
  .mm--identify { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .mm { padding: 6px; }
  .mm-bench { padding: 6px 4px 8px; }
  .mm-body { grid-template-columns: 1fr; }
  .mm-side .mm-scope-art { display: none; }
  .mm-side:has(.mm-scope-art) { display: none; }
  .mm-nose { flex-basis: 100%; }
  .mm-open { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .mm-seg, .mm-count, .mm-callout, .mm-dim { opacity: 1 !important; transform: none !important; }
  .mm *, .mm *::before, .mm *::after { animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
