/* MakarantaAI STEM Lab: the shared look of the bilingual simulator pages (salt analysis, food tests, genetics,
   glass block, graph plotter). Tokens follow DESIGN.md / lib/app/theme.dart; fonts are DM Sans (OFL) with
   HausaHooks for the hooked letters, copied from assets/fonts/. */
@font-face { font-family: "DM Sans"; src: url(fonts/DMSans-400.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url(fonts/DMSans-700.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "HausaHooks"; src: url(fonts/HausaHooks-400.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "HausaHooks"; src: url(fonts/HausaHooks-700.ttf) format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --forest: #22C55E; --forest-deep: #116A33; --mint: #E9F7EF; --saffron: #F2B632; --saffron-ink: #8A5A00;
  --ink: #191716; --muted: #6B6460; --line: #E1E3DB; --surface: #FFFFFF; --canvas: #F7F8F5; --soft: #EFEEE8;
  --emerald-tint: #D3F0DE; --gold-tint: #FBEFCF; --right: #16A34A; --wrong: #DC2626; --chosen: #2563EB;
  --ledge: 4px; /* the darker bottom edge of buttons and cards, as on the landing page (LedgeBorder in the app) */
  --title-lg: 28px; --title-md: 22px; --title-sm: 18px; --text-lg: 16px; --text-md: 14px; --text-sm: 13px; --text-xs: 12px;
  --radius-s: 8px; --radius-m: 12px; --radius-l: 18px; --radius-xl: 24px; --radius-pill: 999px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --gutter: 20px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: "DM Sans", "HausaHooks", system-ui, sans-serif; font-size: var(--text-lg); line-height: 1.5;
}
html[data-lang="ha"] [data-l="en"], html:not([data-lang="ha"]) [data-l="ha"] { display: none !important; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--forest); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) 0; }
.brand { font-weight: 700; font-size: var(--text-md); color: var(--forest-deep); }
.lang { display: inline-flex; background: var(--soft); border-radius: var(--radius-pill); padding: 3px; }
.lang button {
  border: 0; background: transparent; border-radius: var(--radius-pill); padding: var(--s1) var(--s3);
  font-size: var(--text-sm); font-weight: 700; color: var(--muted); cursor: pointer; min-height: 32px;
}
.lang button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }

#hero { padding: var(--s4) 0 var(--s5); }
h1 { font-size: clamp(var(--title-lg), 4.4vw, 52px); line-height: 1.1; margin: 0; font-weight: 700; letter-spacing: -0.01em; max-width: 20ch; }
#hero p { color: var(--muted); max-width: 36em; margin: var(--s3) 0 0; font-size: var(--text-lg); }
h2 { font-size: clamp(var(--title-md), 3vw, 40px); line-height: 1.15; margin: 0 0 var(--s2); }
h3, .card h2 { font-size: var(--title-md); margin: 0 0 var(--s2); line-height: 1.25; }
p { margin: 0 0 var(--s3); }

#simulator { padding-bottom: var(--s6); }
.sim { display: grid; gap: var(--s4); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 980px) {
  .sim { grid-template-columns: 360px minmax(0, 1fr); }
}
/* on tall screens the controls stay in view while the drawing, table and graph scroll past */
@media (min-width: 980px) and (min-height: 900px) { .sim > .stack:first-child { position: sticky; top: var(--s4); } }
.stack { display: grid; gap: var(--s4); min-width: 0; }
.card {
  background: var(--surface); border: 1.5px solid var(--line); box-shadow: inset 0 -3px 0 var(--line);
  border-radius: var(--radius-l); padding: var(--s4) var(--s4) calc(var(--s4) + 3px); min-width: 0;
}
.card > h2:first-child { margin-top: 0; }
.muted { color: var(--muted); font-size: var(--text-md); }
.small { font-size: var(--text-sm); }
.label { font-size: var(--text-sm); font-weight: 700; margin: 0 0 var(--s2); display: block; }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.between { justify-content: space-between; }
.gap { height: var(--s3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px;
  padding: var(--s2) var(--s4) calc(var(--s2) + var(--ledge)); border-radius: var(--radius-m); border: 1.5px solid var(--line);
  box-shadow: inset 0 calc(-1 * var(--ledge)) 0 rgba(0, 0, 0, 0.12); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: var(--text-md); cursor: pointer; text-align: center;
}
.btn:active { box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12); transform: translateY(3px); }
.btn.primary { background: var(--forest-deep); border-color: var(--forest-deep); box-shadow: inset 0 calc(-1 * var(--ledge)) 0 rgba(0, 0, 0, 0.2); color: var(--surface); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--forest-deep); font-weight: 700; cursor: pointer; font-size: var(--text-md); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: var(--radius-pill);
  padding: var(--s1) var(--s3); min-height: 36px; font-size: var(--text-md); font-weight: 700; cursor: pointer; color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--forest-deep); border-color: var(--forest-deep); color: var(--surface); }
.chip.done { background: var(--mint); border-color: var(--emerald-tint); color: var(--forest-deep); }

select, input[type="number"], input[type="text"] {
  width: 100%; min-height: 44px; border: 1.5px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface); padding: var(--s2) var(--s3); font-size: var(--text-lg);
}
select:focus, input:focus { border-color: var(--forest); } /* the ring comes from :focus-visible above */
input[type="range"] { width: 100%; accent-color: var(--forest-deep); min-height: 32px; }
.range-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.range-head strong { font-variant-numeric: tabular-nums; }

.note { background: var(--mint); border-radius: var(--radius-m); padding: var(--s3) var(--s4); font-size: var(--text-md); }
.note.gold { background: var(--gold-tint); }
.note strong { color: var(--forest-deep); }
.note.gold strong { color: var(--saffron-ink); }
.ok { color: var(--right); font-weight: 700; }
.bad { color: var(--wrong); font-weight: 700; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: var(--text-md); }
th, td { text-align: left; padding: var(--s2); border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--text-sm); color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stage { width: 100%; height: auto; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage text { font-family: "DM Sans", "HausaHooks", system-ui, sans-serif; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--s3) var(--s4); }
.stat { border-top: 1px solid var(--line); padding-top: var(--s2); }
.stat span { display: block; font-size: var(--text-xs); color: var(--muted); font-weight: 700; }
.stat strong { font-size: var(--title-sm); font-variant-numeric: tabular-nums; }

#guide { padding: var(--s6) 0; border-top: 1.5px solid var(--line); }
#guide ol { list-style: none; padding: 0; margin: var(--s5) 0 0; display: grid; gap: var(--s4); }
#guide ol > li { display: grid; grid-template-columns: 44px 1fr; gap: var(--s4); }
.num-badge {
  width: 44px; height: 44px; border-radius: var(--radius-m); background: var(--gold-tint); color: var(--saffron-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--title-sm);
}
#guide p, #guide ul, .foot { max-width: 36em; }
.card p, .card .note, #insight, #result { max-width: 38em; }
#guide ul { margin: var(--s2) 0 0; padding-left: var(--s5); color: var(--muted); font-size: var(--text-md); display: grid; gap: var(--s1); }
.foot { color: var(--muted); font-size: var(--text-sm); padding: var(--s5) 0 var(--s6); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* the 3D bench (bench3d.js): the picture with what to do next on top and the one thing to do now at the bottom.
   The picture is a dark studio (the glass and flames need it), so its own overlays are light on dark. */
.bench { position: relative; border-radius: var(--radius-m); overflow: hidden; background: #080D10; margin: var(--s2) 0 var(--s3); }
.bench canvas { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.bench .bench-hud {
  position: absolute; top: var(--s3); left: var(--s3); margin: 0; max-width: 46%;
  background: rgba(25, 23, 22, 0.82); color: var(--surface); padding: var(--s2) var(--s3); border-radius: var(--radius-m);
  font-size: var(--text-md); line-height: 1.4;
}
.bench-actions { position: absolute; right: var(--s3); bottom: var(--s3); max-width: 46%; display: flex; flex-direction: column; align-items: stretch; gap: var(--s2); }
.bench-actions:empty { display: none; }
.bench-actions .btn { touch-action: none; user-select: none; -webkit-user-select: none; }
.bench-actions .btn small { display: block; font-weight: 400; font-size: var(--text-xs); opacity: 0.85; }
.bench-look {
  position: absolute; top: var(--s3); right: var(--s3); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-pill); padding: var(--s1) var(--s3); min-height: 36px; font-weight: 700; font-size: var(--text-sm); cursor: pointer;
}
.bench-look[aria-pressed="true"] { background: var(--forest-deep); border-color: var(--forest-deep); color: var(--surface); }
@media (max-width: 560px) {
  .bench { display: flex; flex-direction: column; }
  .bench .bench-hud { position: static; order: 2; border-radius: 0; max-width: none; background: #191716; }
  .bench-actions { position: static; order: 3; padding: var(--s3); background: #191716; max-width: none; }
  .bench-look { top: var(--s2); right: auto; left: var(--s2); }
}
/* without 3D: the same bench as a flat drawing on the page's own light background */
.bench.flat { display: flex; flex-direction: column; background: var(--canvas); border: 1.5px solid var(--line); }
.bench.flat .bench-hud { position: static; order: 2; border-radius: 0; max-width: none; background: #191716; }
.bench.flat .bench-actions { position: static; order: 3; padding: var(--s3); max-width: none; }
/* a bench that fills the height its card gives it (class "fill"): the canvas takes what the hint and button leave */
.bench.fill { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin: var(--s2) 0; }
.bench.fill canvas { flex: 1 1 0; min-height: 0; width: 100%; }
.bench.fill.flat .stage { flex: 1 1 0; min-height: 0; width: 100%; height: auto; }

/* One screen on phones. In the apps the page title goes (the app's bar shows it); on any phone the hero's sentence
   goes, so the simulator starts high on the screen. Pages whose two columns are controls and a drawing (food tests,
   genetics, glass block, graph plotter) put the drawing on top and the controls under it, each scrolling on its own,
   so the picture and every button share the screen. The 3D benches (#cardBench) and the practical graph
   (#cardPaper) lay out their own one-screen cards. */
html.in-app #hero { display: none; }
@media (max-width: 979.98px) {
  #hero p { display: none; }
  .sim:not(:has(#cardBench, #cardPaper)) {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 2 * var(--s3));
    height: calc(100svh - 2 * var(--s3));
    min-height: 480px;
    gap: var(--s3);
  }
  .sim:not(:has(#cardBench, #cardPaper)) > .stack {
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    gap: var(--s3);
    scrollbar-width: thin;
  }
  .sim:not(:has(#cardBench, #cardPaper)) > .stack:last-child { order: -1; flex: 1 1 56%; }
  .sim:not(:has(#cardBench, #cardPaper)) > .stack:first-child { flex: 1 1 44%; }
}
