/* Amaete Chem Lab: one stylesheet for the lab, the home page and the periodic table. */
:root {
  --bg: #f4f1ea; --panel: #fffdf8; --panel2: #f7f3ea; --ink: #1c2126; --ink2: #4c555d; --mute: #7b838a; --line: #e2dccf;
  --accent: #d98a00; --on-accent: #10151d; --accent2: #f2b134; --teal: #0f9488; --ok: #1f9d55; --no: #cf3b2a;
  --shadow: 0 1px 2px rgba(30,25,15,.06), 0 6px 22px rgba(30,25,15,.07);
  --r: 14px; --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111418; --panel: #191d22; --panel2: #20252b; --ink: #eef1f3; --ink2: #b7c0c7; --mute: #8a939b; --line: #2c3238;
  --accent: #ffb020; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 26px rgba(0,0,0,.35); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.muted { color: var(--mute); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; padding: .8em 1.25em; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 650; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.wide { width: 100%; }

/* ---------------- lab ---------------- */
body.labpage { overflow: hidden; height: 100dvh; }
.lab { height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; z-index: 5; }
.bar .home { display: flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 800; letter-spacing: -.01em; flex: none; }
.bar .home svg { width: 26px; height: 26px; }
.bar .lvl { flex: none; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--hue, var(--accent)) 16%, transparent); color: color-mix(in srgb, var(--hue, var(--accent)) 75%, var(--ink)); }
.bar .ttl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.bar .btns { display: flex; gap: 6px; flex: none; }
.ib { height: 36px; min-width: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); display: inline-flex; align-items: center; justify-content: center; }
.ib svg { width: 19px; height: 19px; }
.ib.txt { font-size: 13px; font-weight: 700; padding: 0 11px; }
.ib.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.ib.off .w { opacity: 0; }

.stage { min-height: 0; display: grid; grid-template-columns: 330px 1fr 320px; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "guide view shelf" "guide view read"; }
.view { grid-area: view; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #e7e3da; }
[data-theme="dark"] .view { background: #15181d; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.tabs { display: none; }
.pane { overflow: auto; background: var(--panel); padding: 16px; min-height: 0; -webkit-overflow-scrolling: touch; }
#guide { grid-area: guide; border-right: 1px solid var(--line); }
.pane[data-p="shelf"] { grid-area: shelf; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pane[data-p="read"] { grid-area: read; border-left: 1px solid var(--line); background: var(--panel2); }
.ph { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }

/* guide */
.g-head h1 { font-size: 23px; line-height: 1.15; margin: 10px 0 6px; letter-spacing: -.02em; }
.g-head .goal { margin: 0 0 14px; color: var(--ink2); line-height: 1.45; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--hue) 15%, transparent); color: color-mix(in srgb, var(--hue) 75%, var(--ink)); }
.prog { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--mute); margin-bottom: 10px; }
.prog .bar { flex: 1; height: 6px; padding: 0; border: 0; border-radius: 9px; background: var(--panel2); overflow: hidden; display: block; }
.prog .bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; transition: width .4s; }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 12px; color: var(--mute); }
.steps li p { margin: 1px 0 0; line-height: 1.4; }
.steps li small { display: block; margin-top: 4px; color: var(--ink2); }
.steps li .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--panel2); border: 1px solid var(--line); }
.steps li.now { background: color-mix(in srgb, var(--accent) 9%, var(--panel)); color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.steps li.now .n { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.steps li.done { color: var(--ink2); }
.steps li.done .n { background: var(--ok); color: #fff; border-color: var(--ok); }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; margin: 0 0 12px; }
.pane[data-p="read"] .card { background: var(--panel); }
.card h3, .card summary { margin: 0 0 6px; font-size: 14px; font-weight: 800; }
.card summary { cursor: pointer; margin: 0; }
.card details[open] summary, details.card[open] summary { margin-bottom: 6px; }
.card p { margin: 0; line-height: 1.5; color: var(--ink2); font-size: 14px; }
.card.win { background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.card.real { background: color-mix(in srgb, var(--accent2) 14%, var(--panel)); border-color: color-mix(in srgb, var(--accent2) 40%, transparent); }
.words { margin: 0; display: grid; gap: 6px; font-size: 14px; }
.words dt { font-weight: 750; } .words dd { margin: 0 0 4px; color: var(--ink2); }
.ideas { margin: 0; padding-left: 18px; color: var(--ink2); font-size: 14px; line-height: 1.5; }
.quiz .q { margin: 10px 0 14px; }
.quiz .q > p { font-weight: 650; color: var(--ink); margin-bottom: 8px; }
.opts { display: grid; gap: 6px; }
.opt { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.opt.right { background: color-mix(in srgb, var(--ok) 16%, var(--panel)); border-color: var(--ok); }
.opt.wrong { background: color-mix(in srgb, var(--no) 14%, var(--panel)); border-color: var(--no); }
.opt:disabled { cursor: default; color: var(--ink); }
.quiz small { display: block; margin-top: 6px; font-size: 13px; }
.quiz small.ok { color: var(--ok); } .quiz small.no { color: var(--no); }
.quiz .score { font-weight: 800; color: var(--ink); }

/* shelf */
#shelf h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }
#shelf h4:first-child { margin-top: 0; }
.items { display: grid; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); text-align: left; }
.item:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.item.on { border-color: var(--accent2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent2) 45%, transparent); background: color-mix(in srgb, var(--accent2) 12%, var(--panel)); }
.item b { display: block; font-size: 14px; font-weight: 650; }
.item small { display: block; font-size: 12px; color: var(--mute); }
.sw { flex: none; width: 22px; height: 30px; border-radius: 4px 4px 7px 7px; background: linear-gradient(to top, var(--c) 62%, transparent 62%); border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent); position: relative; }
.sw.bottle { margin-top: 6px; border-color: var(--t); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--t) 40%, transparent); }
.sw.bottle::before { content: ""; position: absolute; left: 4px; right: 4px; top: -7px; height: 6px; border-radius: 2px; background: var(--t); }
.sw.dropper { width: 16px; height: 22px; border-radius: 4px; }
.sw.dropper::before { content: ""; position: absolute; left: 3px; right: 3px; top: -8px; height: 8px; border-radius: 5px 5px 0 0; background: #222; }
.sw.solid, .sw.salt { width: 28px; height: 14px; border-radius: 0 0 14px 14px; background: var(--c); }

/* readings */
.read .rhead { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.read .rhead h4 { margin: 0; font-size: 16px; } .read .rhead small { color: var(--mute); }
.swatch { width: 30px; height: 30px; border-radius: 9px; background: var(--c); border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent); flex: none; }
.read .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.read .grid div { background: var(--panel2); border-radius: 10px; padding: 7px 9px; }
.read .grid small { display: block; color: var(--mute); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.read .grid b { font-size: 17px; font-variant-numeric: tabular-nums; }
.phbar { position: relative; height: 10px; border-radius: 9px; margin: 4px 0 20px; background: linear-gradient(90deg, #d91c1f, #f56b1a, #f7d21e, #3cb34a, #1f78d1, #3e33b3, #73209c); }
.phbar i { position: absolute; top: -4px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: var(--c); border: 3px solid var(--panel); box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: left .3s; }
.phbar span { position: absolute; top: 13px; font-size: 10px; color: var(--mute); } .phbar span:nth-of-type(1) { left: 0; } .phbar span:nth-of-type(2) { left: 50%; transform: translateX(-50%); } .phbar span:nth-of-type(3) { right: 0; }
.read h5 { margin: 8px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }
.inside, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.inside li { display: flex; justify-content: space-between; gap: 10px; } .inside small { color: var(--mute); font-variant-numeric: tabular-nums; }
.log li { display: grid; gap: 2px; padding: 4px 0; border-bottom: 1px dashed var(--line); } .log code, .toast code { font-family: var(--mono); font-size: 12px; color: var(--ink2); }
.gas { margin: 0 0 6px; padding: 6px 9px; border-radius: 8px; background: color-mix(in srgb, var(--teal) 13%, transparent); color: var(--ink); font-size: 13px; }
.meter h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); }
.meter .big { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; } .meter .big small { font-size: 14px; color: var(--mute); }
.meter .mono { font-family: var(--mono); }
.trow { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; } .trow b { font-variant-numeric: tabular-nums; } .trow b.stop { color: var(--ok); }

/* overlays on the 3D view */
#tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow); margin-top: -6px; }
.tag.sel { background: #0f9488; color: #fff; border-color: #0f9488; z-index: 2; }
.tag.mini { font-size: 10px; padding: 2px 6px; opacity: .85; }
.hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); max-width: min(620px, calc(100% - 20px)); padding: 8px 14px; border-radius: 14px; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); font-size: 14px; line-height: 1.35; box-shadow: var(--shadow); text-align: center; backdrop-filter: blur(6px); }
.hint b { color: var(--accent); margin-right: 4px; }
.toast { position: absolute; right: 12px; top: 64px; width: min(360px, calc(100% - 24px)); padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity .25s, transform .25s; cursor: pointer; }
.toast.on { opacity: 1; transform: none; pointer-events: auto; }
.toast .tt { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 4px; }
.toast b { font-size: 15px; } .toast p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink2); }
.actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); overflow-x: auto; scrollbar-width: none; background: linear-gradient(to top, color-mix(in srgb, var(--bg) 85%, transparent), transparent); }
.actions::-webkit-scrollbar { display: none; }
.act { flex: none; height: 40px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 14px; box-shadow: var(--shadow); white-space: nowrap; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.act.ghost { background: transparent; box-shadow: none; }
.act.hot { background: #ffefe5; border-color: #f08a4b; color: #a3400c; }
[data-theme="dark"] .act.hot { background: #3a2216; color: #ffb08a; }
.act.tap.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.holding { flex: none; display: flex; flex-direction: column; line-height: 1.1; padding: 0 4px; }
.holding i { font-style: normal; font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: .08em; } .holding b { font-size: 15px; }
.seg { flex: none; display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.seg button { border: 0; background: none; height: 34px; padding: 0 12px; border-radius: 999px; font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.seg button.on { background: var(--accent2); color: #2a1d00; }
.note { flex: none; font-size: 13px; color: var(--ink2); padding: 0 4px; }
.howto { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10,12,15,.45); z-index: 20; padding: 16px; }
.howto[hidden] { display: none; }
.hcard { background: var(--panel); border-radius: 20px; padding: 22px; width: min(440px, 100%); box-shadow: var(--shadow); }
.hcard h2 { margin: 0 0 12px; font-size: 21px; } .hcard ol { margin: 0 0 18px; padding-left: 20px; display: grid; gap: 8px; line-height: 1.45; color: var(--ink2); } .hcard b { color: var(--ink); }

/* medium screens and phones in landscape: the view and one tabbed column */
@media (max-width: 1359px) {
  .stage { grid-template-columns: 1fr 340px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "view tabs" "view pane"; }
  .tabs { grid-area: tabs; display: flex; gap: 4px; padding: 8px; background: var(--panel); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .tabs button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--ink2); }
  .tabs button.on { background: var(--panel2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
  .pane, #guide, .pane[data-p="shelf"], .pane[data-p="read"] { grid-area: pane; display: none; border: 0; border-left: 1px solid var(--line); }
  .lab[data-tab="steps"] #guide, .lab[data-tab="shelf"] .pane[data-p="shelf"], .lab[data-tab="read"] .pane[data-p="read"] { display: block; }
  .ph { display: none; }
}
/* phones upright */
@media (max-width: 760px) and (orientation: portrait), (max-width: 560px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 54dvh auto minmax(0, 1fr); grid-template-areas: "view" "tabs" "pane"; }
  .tabs { border-left: 0; border-top: 1px solid var(--line); }
  .pane, #guide, .pane[data-p="shelf"], .pane[data-p="read"] { border-left: 0; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); }
  .bar { gap: 8px; padding: 6px 10px; } .bar .home span, .bar .lvl { display: none; } .bar .ttl { font-size: 14px; text-align: center; }
  .ib { height: 34px; min-width: 34px; } .ib.txt { padding: 0 9px; } #reset { display: none; }
  .hint { top: 8px; font-size: 13px; padding: 6px 11px; }
  .toast { top: auto; bottom: 64px; right: 10px; left: 10px; width: auto; }
  .g-head h1 { text-align: center; font-size: 21px; } .g-head { text-align: center; }
  .act { height: 38px; padding: 0 13px; font-size: 13.5px; }
}
/* phones sideways */
@media (max-height: 540px) and (orientation: landscape) {
  .stage { grid-template-columns: 1fr 300px; }
  .bar { padding-top: 4px; padding-bottom: 4px; } .ib { height: 30px; min-width: 30px; }
  .hint { font-size: 12.5px; padding: 5px 10px; top: 6px; max-width: calc(100% - 16px); }
  .toast { top: 46px; width: 300px; }
  .act { height: 34px; font-size: 13px; padding: 0 12px; } .seg button { height: 28px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 760px) and (orientation: portrait), (max-height: 540px) and (orientation: landscape) {
  .toast { padding: 9px 12px; } .toast p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }
}

/* ---- experiment menu, school names, Play ---- */
.bar .ttl { background: none; border: 0; padding: 4px 6px; border-radius: 8px; font: inherit; font-weight: 700; color: inherit; cursor: pointer; text-align: left; }
.bar .ttl::after { content: " ▾"; color: var(--ink2); font-size: .85em; }
.bar .ttl:hover { background: var(--panel2); }
.xnav { display: flex; gap: 6px; margin: 0 0 12px; }
.xnav .nb { flex: none; font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: inherit; text-decoration: none; cursor: pointer; font-family: inherit; }
.xnav .nb.all { flex: 1; text-align: center; }
.xnav .nb.off { opacity: .35; }
.g-head .nick { margin: -2px 0 6px; color: var(--ink2); font-style: italic; }
.card.learn { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.card.learn ul { margin: 6px 0 8px; padding-left: 18px; line-height: 1.45; }
.card.learn li { margin: 3px 0; }
.card.learn .syl { margin: 0; font-size: 12.5px; color: var(--ink2); }
.menu { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 18, .45); display: grid; place-items: center; padding: 16px; }
.menu[hidden] { display: none; }
.mcard { width: min(560px, 100%); max-height: min(86vh, 900px); overflow: auto; background: var(--panel); border-radius: 18px; padding: 16px 18px 20px; box-shadow: var(--shadow); }
.mhead { display: flex; align-items: center; justify-content: space-between; }
.mhead h2 { margin: 0; font-size: 20px; }
.mcard h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); }
.mi { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: inherit; }
.mi:hover, .mi.on { background: color-mix(in srgb, var(--hue) 12%, transparent); }
.mi i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--hue); }
.mi span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mi small { color: var(--ink2); }
.mi em { font-style: normal; color: #2b9a55; font-weight: 800; }
.hint .play { margin: 0 8px 0 0; font: inherit; font-weight: 800; font-size: 13px; padding: 4px 11px; border-radius: 999px; border: 0; background: var(--accent); color: var(--on-accent); cursor: pointer; vertical-align: 1px; }
.hint .play.on { background: var(--ink); color: var(--panel); }

/* big desktop monitors (27 and 32 inch): the panels and the overlays grow with the screen, the bench fills the rest */
@media (min-width: 2200px) and (min-height: 1200px) {
  .stage { grid-template-columns: 400px 1fr 390px; }
  .bar, .pane, .tabs, .hint, .actions, .toast { zoom: 1.2; }
}
@media (min-width: 3200px) and (min-height: 1800px) {
  .stage { grid-template-columns: 500px 1fr 480px; }
  .bar, .pane, .tabs, .hint, .actions, .toast { zoom: 1.5; }
}
