/* Scale of the Solar System */

:root {
  --accent:       #004445;
  --accent-light: #006668;
  --focus-glow:   #FFD166;
  --ink:          #2C3E3E;
  --muted:        #5A6E6E;
  --panel-bg:     #F5F1E5;
  --space-bg:     #10141d;
  --rocky:        #D88A4A;
  --icy:          #7FC8E8;
  --gas:          #E8C46A;
  --wrong:        #E24B4A;
  --ok:           #2E7D32;
}

*, *::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%;
}

#main-row {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
}

#stage-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--space-bg);
  min-width: 0;
}

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

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

/* ── Stage chrome ── */
#zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
}

#zoom-controls button {
  min-width: 34px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: rgba(16, 20, 29, 0.82);
  color: #EAF0F6;
  font: 500 15px Roboto, Arial, sans-serif;
  cursor: pointer;
  padding: 0 10px;
}

#zoom-controls button:hover { background: rgba(50, 60, 80, 0.9); }

#zoom-controls button:focus-visible {
  outline: 3px solid var(--focus-glow);
  outline-offset: 2px;
}

#fit-all { font-size: 13px; }

#scale-note {
  position: absolute;
  left: 12px;
  top: 12px;
  font: 400 12px Roboto, Arial, sans-serif;
  color: #C7D2DC;
  background: rgba(16, 20, 29, 0.82);
  border-radius: 6px;
  padding: 4px 8px;
  pointer-events: none;
}

.hidden { display: none !important; }

/* ── Keyboard focus proxies over canvas bodies ── */
#body-proxies { position: absolute; inset: 0; pointer-events: none; }

.body-proxy {
  position: absolute;
  pointer-events: none;
  background: transparent;
  border: none;
  border-radius: 50%;
  padding: 0;
}

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

/* ── Suspicion pill (no values, ever) ── */
#suspect-pill {
  position: absolute;
  width: 252px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  color: var(--ink);
  font-size: 13px;
  z-index: 40;
}

#suspect-pill h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  padding-right: 24px;
}

#suspect-pill .type-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid #D8D2C2;
  border-radius: 10px;
  padding: 1px 8px;
  margin-bottom: 8px;
}

#pill-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}

#pill-close:hover { background: #EFEAD9; color: var(--ink); }

.pill-text {
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.pill-blurb {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  margin: 2px 0 8px;
}

.type-chip.chip-verified {
  color: #0F6E56;
  border-color: #5DCAA5;
  margin-left: 4px;
}

.compare-row { margin-top: 6px; }

.pill-btn.compare-add {
  border-style: dashed;
  font-size: 11.5px;
  padding: 3px 9px;
  min-height: 24px;
}

.pill-ok { color: var(--ok); font-weight: 600; font-size: 13px; margin-bottom: 4px; }

.pill-feedback {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
  background: #FFF7DF;
  border: 1px solid #EAD48F;
  border-radius: 6px;
  padding: 5px 8px;
  margin-top: 8px;
}

.pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.pill-btn {
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: #ffffff;
  color: var(--accent);
  font: 500 12.5px Roboto, Arial, sans-serif;
  padding: 5px 11px;
  cursor: pointer;
  min-height: 28px;
}

.pill-btn:hover { background: #E9F2F2; }

.pill-btn.ok { border-color: #5c8a4e; color: #2E5D24; }

.pill-btn.ok:hover { background: #EDF5E7; }

.pill-btn.nudge {
  min-width: 36px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
}

.pill-btn.swatch::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--swatch, #999);
  margin-right: 6px;
  vertical-align: -1px;
}

.pill-btn.swatch.current,
.pill-btn.current { outline: 2px dashed #B8860B; outline-offset: 1px; }

.pill-hintlabel { font-size: 11px; color: var(--muted); }

#suspect-pill button:focus-visible,
#side-panel button:focus-visible,
#plot-band button:focus-visible {
  outline: 3px solid #B8860B;
  outline-offset: 2px;
}

/* ── Side panel (controls only) ── */
#side-panel {
  width: 190px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--panel-bg);
  border-left: 1px solid #DCD5C3;
  overflow-y: auto;
}

#panel-spacer { flex: 1; }

.panel-block {
  background: #ffffff;
  border: 1px solid #E2DCCB;
  border-radius: 8px;
  padding: 8px 10px;
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

#tier-buttons { display: flex; gap: 6px; }

.tier-btn {
  flex: 1;
  min-height: 30px;
  border: 1px solid #C9C2B0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: 600 14px Roboto, Arial, sans-serif;
  cursor: pointer;
}

.tier-btn:hover { border-color: var(--accent); }

.tier-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

#error-counter {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

#error-counter .of-total { font-size: 13px; font-weight: 400; color: var(--muted); }

#suspicion-count {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.panel-btn {
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent);
  font: 600 13px Roboto, Arial, sans-serif;
  cursor: pointer;
  padding: 6px 10px;
}

.panel-btn:hover { background: #E9F2F2; }

.panel-btn.primary {
  background: var(--accent);
  color: #ffffff;
}

.panel-btn.primary:hover:not(:disabled) { background: var(--accent-light); }

#audit-report {
  font-size: 12px;
  font-weight: 500;
  color: var(--ok);
  text-align: center;
  background: #EDF5E7;
  border: 1px solid #BBD3AE;
  border-radius: 6px;
  padding: 6px 8px;
}

.panel-btn:disabled {
  border-color: #B9C4C4;
  background: #E9E4D5;
  color: #7A8888;
  cursor: not-allowed;
}

/* ── Compare band: student-built reference tray ── */
#compare-band {
  flex-shrink: 0;
  background: var(--panel-bg);
  border-top: 1px solid #DCD5C3;
  padding: 6px 12px 10px;
}

#compare-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#compare-header .panel-label { margin-bottom: 0; }

#compare-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 500 12px Roboto, Arial, sans-serif;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #C9C2B0;
  border-radius: 12px;
  padding: 2px 4px 2px 10px;
}

.compare-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  line-height: 1;
}

.compare-chip button:hover { background: #EFEAD9; color: var(--ink); }

#compare-clear {
  margin-left: auto;
  border: 1px solid #C9C2B0;
  border-radius: 5px;
  background: #ffffff;
  color: var(--muted);
  font: 500 11px Roboto, Arial, sans-serif;
  padding: 2px 10px;
  min-height: 24px;
  cursor: pointer;
}

#compare-close {
  border: 1px solid #C9C2B0;
  border-radius: 5px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  min-width: 26px;
  min-height: 24px;
  cursor: pointer;
}

#compare-alert {
  font-size: 12px;
  color: #7A4A12;
  background: #FFF3DC;
  border: 1px solid #EAD48F;
  border-radius: 6px;
  padding: 5px 9px;
  margin-top: 6px;
}

#compare-canvas {
  width: 100%;
  height: 150px;
  display: block;
  background: #181d29;
  border-radius: 6px;
  margin-top: 6px;
}

@media (max-width: 530px) {
  #compare-canvas { height: 120px; }
}

/* ── Plot band: the pattern instrument ── */
#plot-band {
  flex-shrink: 0;
  background: var(--panel-bg);
  border-top: 1px solid #DCD5C3;
  padding: 6px 12px 10px;
  transition: box-shadow 0.4s;
}

#plot-band.flash { box-shadow: inset 0 0 0 3px #B8860B; }

#plot-band.collapsed { padding-bottom: 6px; }

#plot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#plot-header .panel-label { margin-bottom: 0; }

#plot-caption {
  font-size: 11px;
  color: var(--muted);
}

#plot-legend { display: flex; gap: 10px; font-size: 11.5px; color: var(--ink); }

#plot-legend span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: -1px;
}

.leg-rocky::before { background: var(--rocky); }
.leg-icy::before   { background: var(--icy); }
.leg-gas::before   { background: var(--gas); }

#plot-toggle {
  margin-left: auto;
  border: 1px solid #C9C2B0;
  border-radius: 5px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  min-width: 30px;
  min-height: 24px;
  cursor: pointer;
}

#plot-body { margin-top: 6px; position: relative; }

#plot-proxies { position: absolute; inset: 0; pointer-events: none; }

#plot-proxies .body-proxy { border-radius: 50%; }

#plot-canvas {
  width: 100%;
  height: 158px;
  display: block;
  background: #FCFAF3;
  border: 1px solid #EEE8D8;
  border-radius: 6px;
  cursor: pointer;
}

/* ── Narrow reflow (~530px) ── */
@media (max-width: 530px) {
  #main-row { flex-direction: column; }
  #stage-panel { flex: 1; min-height: 0; }
  #side-panel {
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    border-left: none;
    border-top: 1px solid #DCD5C3;
    padding: 8px;
    gap: 8px;
    overflow-y: visible;
  }
  #panel-spacer { display: none; }
  #tier-block { flex: 1.3; }
  #status-block { flex: 1; }
  #hint-btn { flex: 1; min-height: 0; }
  #publish-btn { flex: 1.2; min-height: 0; }
  #error-counter { font-size: 17px; }
  #plot-canvas { height: 120px; }
  #plot-caption { display: none; }
  #suspect-pill { width: min(252px, calc(100vw - 24px)); }
}

/* ── 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 (house chrome — keep in sync with toolbar.js injection) ── */
#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;
}

/* ── Overlays (intro + reset confirm) ── */
#intro-overlay, #reset-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, #reset-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);
}

#reset-overlay h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 10px;
}

#reset-overlay p {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 18px;
}

#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;
  flex-wrap: wrap;
}

#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;
}
