/* <!-- TODO: Sim Display Name --> */

:root {
  --accent:       #004445;
  --accent-light: #006668;
  --focus-glow:   #FFD166;
  --ink:          #2C3E3E;
  --muted:        #5A6E6E;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #F5F1E5;
  font-family: Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#sim-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#stage-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#sim-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#sim-canvas:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: -2px;
}

/* ── Accessibility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Info dialog ──
   The dialog is Tuva Sims "chrome", so its accent is the P1 purple (#5c4738),
   NOT the sim's green var(--accent). Header = purple with white text; active
   tab / h3 / footer button = purple; tabs/footer surface = #F8FBFB; body text =
   var(--ink). The shared toolbar stylesheet also injects these purple rules
   (scoped to #info-dialog) so existing green sims reskin automatically — keep
   this block in sync with it; do not redefine per sim. */
#info-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow: hidden;
  margin: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  background: #ffffff;
}

#info-dialog::backdrop {
  background: rgba(30, 16, 48, 0.55);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #5c4738;
  color: #ffffff;
}

.dialog-header h2 {
  font-size: 16px;
  font-weight: 600;
}

#dialog-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#dialog-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

#dialog-close-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

.dialog-tabs {
  display: flex;
  border-bottom: 2px solid #E5EAE9;
  background: #F8FBFB;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 10px 0;
  font-family: Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: #5c4738;
}

.tab-btn.active,
.tab-btn[aria-selected="true"] {
  color: #5c4738;
  border-bottom-color: #5c4738;
}

.tab-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: -3px;
}

.dialog-body {
  padding: 16px 20px;
  overflow-y: auto;
  max-height: calc(100vh - 240px);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.dialog-body h3 {
  font-size: 14px;
  font-weight: 600;
  color: #5c4738;
  margin-top: 14px;
  margin-bottom: 6px;
}

.dialog-body h3:first-child {
  margin-top: 0;
}

.dialog-body p {
  margin-bottom: 8px;
}

.dialog-body ul,
.dialog-body ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.dialog-body li {
  margin-bottom: 4px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid #E5EAE9;
  background: #F8FBFB;
}

.dialog-close-footer {
  background: #5c4738;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-family: Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.dialog-close-footer:hover {
  background: #7d6c60;
}

.dialog-close-footer:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

/* ── Intro slides (optional; house pattern) ──
   Overlay div, not <dialog>.showModal(): the native top layer would sit above
   the shared toolbar; z-index 9990 keeps the top bar clickable (toolbar is
   9999). Enable by filling INTRO_STEPS in the sim JS. The panel is sim
   content, so it uses the sim palette (var(--accent)), not the dialog's
   purple chrome. */
#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

#intro-overlay.hidden { display: none; }

.intro-panel {
  background: #ffffff;
  border-radius: 12px;
  padding: 28px 30px 22px;
  width: min(500px, calc(100vw - 32px));
  color: var(--ink);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

#intro-img {
  display: block;
  max-width: 100%;
  height: 220px;
  object-fit: contain;
  margin: 0 auto 18px;
  border-radius: 8px;
}

#intro-text {
  font-size: 16px;
  line-height: 1.7;
  min-height: 108px;
  margin-bottom: 20px;
}

.intro-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#intro-skip {
  background: transparent;
  border: none;
  color: var(--muted);
  font: 500 14px Roboto, Arial, sans-serif;
  cursor: pointer;
  padding: 8px 4px;
  text-decoration: underline;
}

#intro-skip:hover { color: var(--ink); }

#intro-skip:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

#intro-count {
  margin-left: auto;
  font: 500 12px Roboto, Arial, sans-serif;
  color: var(--muted);
}

.intro-btn {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font: 600 14px Roboto, Arial, sans-serif;
  cursor: pointer;
}

.intro-btn:hover { background: var(--accent-light); }

.intro-btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.intro-btn:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

/* ── Shape the Bell — stage + controls ── */

/* A warm, layered backdrop (not flat white): soft cream with a faint green
   wash toward the base, so the curve reads as sitting on a "stage". */
#stage-panel {
  background:
    radial-gradient(120% 90% at 50% 0%, #FBF8F0 0%, #F3EFE2 55%, #E9E7D6 100%);
}

/* Control panel — a glass card floating over the bottom of the stage. */
#controls {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 28px));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid #DfE4Dd;
  border-radius: 14px;
  box-shadow: 0 6px 22px rgba(20, 45, 40, 0.14);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ctrl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ctrl-row .k {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

#attr-input {
  flex: 1;
  min-width: 150px;
  border: 1px solid #CBD5CE;
  border-radius: 8px;
  padding: 7px 11px;
  font: 500 14px Roboto, Arial, sans-serif;
  background: #FCFEFB;
  color: var(--ink);
}
#attr-input::placeholder { color: #9AA7A0; font-style: italic; font-weight: 400; }
#attr-input:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 1px; }

.slider {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;          /* one slider per row now; grow to fill, max field beside it */
  min-width: 0;
}
.slider b { font-size: 13px; color: var(--accent); min-width: 34px; }

/* small numeric fields (axis min/max, SD max) */
.numfield {
  width: 62px;
  border: 1px solid #CBD5CE;
  border-radius: 7px;
  padding: 6px 8px;
  font: 500 13px Roboto, Arial, sans-serif;
  background: #FCFEFB;
  color: var(--ink);
  text-align: center;
}
.numfield:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 1px; }
.axis-row .to { font-size: 13px; color: var(--muted); }
.maxfield { display: flex; align-items: center; gap: 6px; }
.maxfield .mx { font-size: 12px; color: var(--muted); }

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.check input:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 2px; }
.slider input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 5px;
  background: #D4DED8;
  outline: none;
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; cursor: pointer;
}
.slider input[type=range]:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 4px; }
.slider .val { font-size: 14px; font-weight: 700; color: var(--accent); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
#speed-val { min-width: 58px; white-space: nowrap; }

.stepper { display: flex; align-items: center; gap: 7px; }
.stepper b { font-size: 13px; color: var(--ink); }
.num { display: flex; align-items: center; border: 1px solid #CBD5CE; border-radius: 8px; overflow: hidden; background: #FCFEFB; }
.num button { border: 0; background: transparent; font-size: 16px; width: 28px; height: 32px; cursor: pointer; color: var(--accent); }
.num button:hover { background: #EEF3EF; }
.num input { border: 0; width: 48px; text-align: center; font: 500 14px Roboto, Arial, sans-serif; background: transparent; padding: 6px 0; color: var(--ink); }
.num input:focus-visible { outline: 2px solid var(--focus-glow); outline-offset: -2px; }

#run-btn {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 10px 22px;
  font: 700 15px Roboto, Arial, sans-serif;
  cursor: pointer;
  transition: background .15s;
}
#run-btn:hover { background: var(--accent-light); }
#run-btn:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 2px; }

#mode-hint {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  min-height: 1.1em;
}

@media (max-width: 560px) {
  #run-btn { margin-left: 0; width: 100%; }
}


/* ── Model Distributions — dropdown, groups, binomial controls ── */
#dist-select {
  border: 1px solid #CBD5CE; border-radius: 8px; padding: 7px 11px;
  font: 600 14px Roboto, Arial, sans-serif; background: #FCFEFB; color: var(--ink);
  min-width: 190px; cursor: pointer;
}
#dist-select:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 1px; }
[hidden] { display: none !important; }
.spd-end { font-size: 14px; line-height: 1; }
.outcome-field {
  flex: 1; min-width: 90px; border: 1px solid #CBD5CE; border-radius: 8px;
  padding: 6px 10px; font: 500 14px Roboto, Arial, sans-serif; background: #FCFEFB; color: var(--ink);
}
.outcome-field:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 1px; }
.outcomes-row .to { color: var(--muted); font-size: 13px; }

#normal-controls, #spinner-controls, #poisson-controls { display: flex; flex-direction: column; gap: 10px; }

/* Geometric-only row: single-spin button + expected-value readout */
.geom-row { align-items: center; gap: 14px; }
.ghost-btn {
  border: 1.5px solid var(--handle, #C77D33); color: var(--handle, #C77D33);
  background: #FCFEFB; border-radius: 9px; padding: 7px 16px;
  font: 700 14px Roboto, Arial, sans-serif; cursor: pointer;
}
.ghost-btn:hover { background: #FBF3EA; }
.ghost-btn:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 2px; }
.geo-attr-field {
  flex: 1; min-width: 120px; border: 1px solid #CBD5CE; border-radius: 8px;
  padding: 6px 10px; font: 500 14px Roboto, Arial, sans-serif; background: #FCFEFB; color: var(--ink);
}
.geo-attr-field:focus-visible { outline: 3px solid var(--focus-glow); outline-offset: 1px; }
