/* Clevix Ed — simulation page layout and control-panel widgets */
@import url('base.css');
@import url('models.css');
@import url('explorer.css');
@import url('column.css');

.sim-page { min-height: 100vh; display: flex; flex-direction: column; }

.sim-top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.sim-title { flex: 1; min-width: 0; padding-left: 16px; border-left: 1px solid var(--line); }
.sim-title h1 { margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-meta { margin: 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-top-actions { display: flex; gap: 8px; }

.sim-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding: 16px 20px;
  max-width: 1440px; width: 100%; margin: 0 auto; }

.stage { position: relative; background: var(--stage); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; height: min(72vh, 680px); min-height: 400px; box-shadow: var(--shadow); }
.stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.dom { height: auto; min-height: 400px; padding: 16px; overflow: visible; }  /* for sims built from HTML, not canvas */
.stage-hint { position: absolute; left: 12px; top: 10px; font-size: 12px; color: var(--ink-2); pointer-events: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent); padding: 4px 9px; border-radius: 8px; border: 1px solid var(--line); }
.stage-badge { position: absolute; right: 12px; top: 12px; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); pointer-events: none;
  transition: opacity .25s, transform .25s; }
.stage-badge[hidden] { display: block; opacity: 0; transform: translateY(-6px); }
.stage-badge.good { color: var(--good); border-color: var(--good); }
.stage-badge.bad { color: var(--bad); border-color: var(--bad); }

/* ---- control panel ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 16px; align-self: start; box-shadow: var(--shadow);
  position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.group { display: flex; flex-direction: column; gap: 12px; }
.group[hidden], .ctl[hidden] { display: none !important; }
.group + .group { border-top: 1px solid var(--line); padding-top: 16px; }
.group h3 { margin: 0; font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }

.ctl label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.ctl output { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: 14px; }
.ctl.disabled { opacity: .45; }
.ctl-label { font-size: 14px; margin-bottom: 6px; }
.slider { display: flex; flex-direction: column; gap: 4px; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; cursor: pointer; margin: 0; }
input[type=range]:disabled { cursor: not-allowed; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--surface-2) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; margin-top: -7px;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-2); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

.select { display: flex; flex-direction: column; gap: 6px; }
select { width: 100%; min-height: 38px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .sw { width: 36px; height: 20px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); position: relative; flex: none; transition: background .15s; }
.toggle .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform .15s, background .15s; }
.toggle input:checked + .sw { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .sw::after { transform: translateX(16px); background: var(--accent-ink); }
.toggle input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg-btn { flex: 1 1 0; min-height: 32px; border: 0; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); padding: 4px 8px; white-space: nowrap; }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns .btn { flex: 1 1 auto; }

.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.readouts > div { background: var(--surface-2); border-radius: 10px; padding: 7px 10px; border-left: 3px solid var(--rc, transparent); }
.readouts > div.wide { grid-column: 1 / -1; }
.readouts dt { font-size: 11.5px; color: var(--ink-2); }
.readouts dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.note { margin: 0; font-size: 13px; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* ---- learning section ---- */
.sim-learn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 4px 20px 32px; max-width: 1440px; width: 100%; margin: 0 auto; }
.learn-card { min-width: 0; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.learn-card.wide { grid-column: 1 / -1; }
.learn-card h2 { font-size: 17px; margin: 0 0 10px; }
.learn-card ul, .learn-card ol { margin: 0; padding-left: 20px; }
.learn-card li { margin: 6px 0; font-size: 15px; }
.learn-card p { margin: 8px 0; font-size: 15px; }
.formula { font-family: 'Cambria Math', 'STIX Two Math', Georgia, serif; font-size: 17px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin: 8px 0; overflow-x: auto; white-space: nowrap; }

.quiz { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.quiz-q { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.quiz-stem { margin: 0; }
.quiz-opts { display: flex; flex-direction: column; gap: 6px; }
.quiz-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; font-size: 14.5px; }
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt input { margin-top: 4px; accent-color: var(--accent); }
.quiz-opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.quiz-opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.quiz-fb { margin: 0; font-size: 14px; min-height: 1.4em; color: var(--ink-2); }
.quiz-fb b { color: var(--ink); }

.sim-foot { margin-top: auto; padding: 18px 20px; text-align: center; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); }

@media (max-width: 960px) {
  .sim-layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .stage { height: 58vh; min-height: 320px; }
  .panel { position: static; max-height: none; }
  .sim-learn { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 24px; }
}
@media (max-width: 560px) {
  .sim-top { padding: 8px 16px; gap: 10px; flex-wrap: wrap; }
  .sim-top .brand { font-size: 17px; }
  .sim-title { order: 3; flex-basis: 100%; border-left: 0; padding-left: 0; }
  .sim-top-actions { margin-left: auto; }
  .sim-top-actions .btn.ghost.back { display: none; }
}

/* ---- "Keep exploring" related simulations (added by related.js) ---- */
.sub-physics { --sc: var(--c1); } .sub-chemistry { --sc: var(--c2); } .sub-math { --sc: var(--c5); } .sub-biology { --sc: var(--c3); } .sub-earth { --sc: var(--c6); }
.sub-computer { --sc: var(--c5); }
.related-wrap { max-width: 1440px; width: 100%; margin: 0 auto; padding: 0 20px 36px; }
.related-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.related-head h2 { margin: 0; font-size: 20px; }
.related-head a { font-weight: 600; text-decoration: none; font-size: 14px; }
.related { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.rcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; text-decoration: none; color: inherit; transition: transform .2s, box-shadow .2s, border-color .2s; }
.rcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--sc) 50%, var(--line)); }
.rel-thumb { aspect-ratio: 5 / 3; padding: 10px; background: color-mix(in srgb, var(--sc) 8%, var(--stage)); border-bottom: 1px solid var(--line); }
.rel-thumb svg { width: 100%; height: 100%; }
.rbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.rbody b { font-size: 15px; }
.rbody span { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rel-thumb .k { stroke: var(--ink); fill: none; stroke-width: 2.5; } .rel-thumb .m { stroke: var(--ink-2); fill: none; stroke-width: 1.5; opacity: .55; }
.rel-thumb .s1, .rel-thumb .s2, .rel-thumb .s3, .rel-thumb .s4, .rel-thumb .s5, .rel-thumb .s6 { fill: none; stroke-width: 3; }
.rel-thumb .s1 { stroke: var(--c1); } .rel-thumb .s2 { stroke: var(--c2); } .rel-thumb .s3 { stroke: var(--c3); } .rel-thumb .s4 { stroke: var(--c4); } .rel-thumb .s5 { stroke: var(--c5); } .rel-thumb .s6 { stroke: var(--c6); }
.rel-thumb .thin { stroke-width: 1.5; opacity: .7; }
.rel-thumb .f1 { fill: var(--c1); } .rel-thumb .f2 { fill: var(--c2); } .rel-thumb .f3 { fill: var(--c3); } .rel-thumb .f4 { fill: var(--c4); } .rel-thumb .f5 { fill: var(--c5); } .rel-thumb .f6 { fill: var(--c6); }
.rel-thumb .fk { fill: var(--ink); } .rel-thumb .fs { fill: var(--surface); } .rel-thumb .o { fill-opacity: .35; } .rel-thumb .d { stroke-dasharray: 6 6; }
.rel-thumb .t { fill: var(--ink); font: 600 15px var(--font); } .rel-thumb * { stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 960px) { .related { grid-template-columns: repeat(2, minmax(0, 1fr)); } .related-wrap { padding: 0 16px 28px; } }

/* ---- "Quiz time" after the lab (sim-kit.js) ---- */
.qt-launch { white-space: nowrap; }
html.qt-open { overflow: hidden; }
.qt-toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 140%); z-index: 60; display: flex; align-items: center; gap: 12px;
  width: min(560px, calc(100% - 24px)); padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--accent);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .22); transition: transform .3s cubic-bezier(.2, .9, .3, 1.2); flex-wrap: wrap; }
.qt-toast.in { transform: translate(-50%, 0); }
.qt-toast > div { flex: 1; min-width: 170px; font-size: 14.5px; }
.qt-ti { font-size: 28px; }
.qt { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(10, 14, 30, .6); animation: qtfade .2s; }
@keyframes qtfade { from { opacity: 0; } }
.qt-card { width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: 22px; padding: 18px 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3); animation: qtpop .28s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes qtpop { from { transform: translateY(16px) scale(.97); } }
.qt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.qt-kick { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.qt-head h2 { margin: 2px 0 0; font-size: 20px; }
.qt-x { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 50%; font-size: 16px; cursor: pointer; color: var(--ink); flex: none; }
.qt-dots { display: flex; gap: 6px; margin: 14px 0 4px; }
.qt-dots i { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); transition: background .2s; }
.qt-dots i.cur { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
.qt-dots i.ok { background: var(--good); } .qt-dots i.bad { background: var(--bad); }
.qt-n { margin: 12px 0 4px; font-size: 13px; color: var(--ink-2); }
.qt-q { margin: 0 0 14px; font-size: clamp(17px, 3.6vw, 20px); font-weight: 600; line-height: 1.4; }
.qt-opts { display: grid; gap: 10px; }
.qt-opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; min-height: 52px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; cursor: pointer; transition: border-color .15s, transform .1s, background .15s; }
.qt-opt:hover:not([disabled]) { border-color: var(--accent); }
.qt-opt:active:not([disabled]) { transform: scale(.99); }
.qt-opt[disabled] { cursor: default; }
.qt-k { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.qt-opt.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.qt-opt.ok .qt-k { background: var(--good); color: #fff; }
.qt-opt.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); animation: qtshake .35s; }
@keyframes qtshake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.qt-fb { margin: 14px 0 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.qt-fb:empty { display: none; }
.qt-fb b { color: var(--ink); } .qt-fb.good b { color: var(--good); } .qt-fb.badf b { color: var(--bad); }
.qt-next { width: 100%; margin-top: 14px; }
.qt-next[hidden] { display: none; }
.qt-done { text-align: center; padding: 10px 0 2px; }
.qt-stars { font-size: 46px; letter-spacing: 6px; color: var(--surface-2); }
.qt-stars .on { color: #f5b301; text-shadow: 0 2px 10px rgba(245, 179, 1, .4); display: inline-block; animation: qtstar .5s cubic-bezier(.2, .9, .3, 1.5) both; }
.qt-stars .on:nth-child(2) { animation-delay: .15s; } .qt-stars .on:nth-child(3) { animation-delay: .3s; }
@keyframes qtstar { from { transform: scale(0) rotate(-40deg); } }
.qt-done h3 { margin: 6px 0 4px; font-size: 22px; }
.qt-done p { margin: 0 0 16px; color: var(--ink-2); }
.qt-done .btns { justify-content: center; }
@media (max-width: 560px) { .qt-launch .qt-l { display: none; } .qt { padding: 0; place-items: end stretch; } .qt-card { border-radius: 22px 22px 0 0; max-height: 92dvh; } }
@media (prefers-reduced-motion: reduce) { .qt, .qt-card, .qt-opt.bad, .qt-stars .on, .qt-toast { animation: none; transition: none; } }
