/* The visitor's theme (theme.js), and what came with it: the engine badge, End session, Reset, the terms
   notice and the home cards' pictures. tour.css's dark rules apply in a dark system unless light was
   chosen; these repeat them for a chosen dark theme. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --bg: #16181c; --fg: #e6e8eb; --muted: #9aa1ab; --line: #2c3037; --panel: #1d2025; --code: #23272d; --accent: #3cc4e4; }
:root[data-theme="dark"] #envbar { background: #3a3217; color: #f1e3b0; border-color: #5d5124; }
:root[data-theme="dark"] #home { background: #1b1a19; color: #eeebea; --card: #242322; --cline: #353332; --chover: #57534f; --text2: #cfcbc8; }
#theme { position: fixed; z-index: 5; top: calc(8px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); width: 64px; padding: 4px 0; }
body > header { padding-right: calc(84px + env(safe-area-inset-right)); }

/* Engine badge: green browser, blue sandbox, grey not run here, amber and pulsing while something runs. */
#pill.badge { display: inline-flex; gap: 6px; align-items: center; color: var(--fg); font-size: 12px; background: var(--bg); cursor: default; }
.badge i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.badge.browser i { background: #2a9d4a; }
.badge.sandbox i { background: #2f7fd8; }
.badge.busy i { background: #e8a400; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

#end { white-space: nowrap; }
#terms { flex: none; margin: 0; padding: 6px max(14px, env(safe-area-inset-left)); font-size: 11px; line-height: 1.4; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }
.art img { width: 100%; height: 100%; object-fit: cover; border-radius: .5rem; }
.art:has(img) { background: none; aspect-ratio: 2 / 1; }

/* A lesson's <div data-engine="browser"> or "sandbox" (docs/authoring.md) shows only where Run takes the code. */
body[data-engine="browser"] [data-engine="sandbox"], body[data-engine="sandbox"] [data-engine="browser"] { display: none; }

#nav button.sub { /* toc.js: the lesson's sections; .here is the one read */ padding: 4px 14px 4px 28px; font-size: 13px; font-weight: normal; color: var(--muted); }
#nav button.sub.here { color: var(--fg); border-left-color: var(--line); }
header .who { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }

@media (max-width: 700px) {
  header .who { display: none; } /* the home page says it; the header has no room */
  #pill.badge { display: inline-flex; font-size: 0; gap: 0; padding: 7px; } /* the dot only; its title says the rest */
  #end .wide, header h1 { display: none; } /* the lesson's title gets the room */
  #theme { top: calc(8px + env(safe-area-inset-top)); min-height: 40px; }
  #bar #reset { flex: 0 0 auto; font-size: 15px; }
  body[data-page="playground"] #terms { display: none; }
}
@media (prefers-reduced-motion: reduce) { .badge.busy i { animation: none; } }
