/* the easl playground — shares the docs site's palette tokens */

:root {
  --bg: #fdfcfa;
  --bg-raised: #f4f1ec;
  --text: #26282e;
  --text-dim: #6d6f78;
  --accent: #7048c8;
  --accent-soft: #ede7fa;
  --border: #e3dfd7;
  --code-bg: #f0ebdf;
  --error: #c0392b;
  --ok: #2f7a4d;
  --warn: #a35b1e;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --editor-fraction: 0.5;
  --console-fraction: 0.3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171c;
    --bg-raised: #1e2027;
    --text: #d7dae2;
    --text-dim: #8a8e99;
    --accent: #a98cf0;
    --accent-soft: #2a2440;
    --border: #2a2d36;
    --code-bg: #232733;
    --error: #ff7b72;
    --ok: #7fc79a;
    --warn: #e0a06a;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

button.small {
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---- the bar ---- */

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.page-name {
  color: var(--text-dim);
  margin-left: -0.5rem;
}

/* ---- the example menu ---- */

.example-picker {
  position: relative;
}

.example-button {
  max-width: 18rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.example-button::after {
  content: "▾";
  margin-left: 0.45rem;
  color: var(--text-dim);
}

.menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 20;
  min-width: 11rem;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.menu li {
  position: relative;
}

.menu [role="menuitem"] {
  display: flex;
  width: 100%;
  border: none;
  border-radius: 4px;
  background: none;
  padding: 0.3rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}

.menu [role="menuitem"]:hover,
.menu [role="menuitem"]:focus-visible,
.has-submenu:hover > [role="menuitem"],
.has-submenu.open > [role="menuitem"] {
  background: var(--accent-soft);
  outline: none;
}

.menu [role="menuitem"].current {
  color: var(--accent);
  font-weight: 600;
}

.menu-separator {
  height: 1px;
  margin: 0.25rem 0.3rem;
  background: var(--border);
}

.has-submenu > [role="menuitem"]::after {
  content: "›";
  margin-left: auto;
  padding-left: 1.2rem;
  color: var(--text-dim);
}

/* The submenu touches its item, so the pointer can cross to it without
   leaving the item's hover. */
.submenu {
  display: none;
  top: -0.25rem;
  left: 100%;
  min-width: 7rem;
}

.has-submenu:hover > .submenu,
.has-submenu.open > .submenu {
  display: block;
}

/* On narrow screens a submenu opens below its item rather than beside it. */
@media (max-width: 40rem) {
  .submenu {
    position: static;
    padding: 0 0 0 0.9rem;
    border: none;
    box-shadow: none;
  }
}

.actions {
  display: flex;
  gap: 0.4rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.status {
  font-size: 0.85rem;
  border-color: transparent;
  background: none;
  color: var(--text-dim);
}

.status[data-kind="ok"] {
  color: var(--ok);
}

.status[data-kind="errors"] {
  color: var(--error);
}

.status[data-kind="failure"] {
  color: var(--warn);
}

.status::before {
  content: "●";
  margin-right: 0.35rem;
  font-size: 0.7em;
  vertical-align: 0.1em;
}

.links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

button.icon {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
}

/* ---- the panes ---- */

.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns:
    minmax(0, calc(var(--editor-fraction) * 100%))
    6px
    minmax(0, 1fr);
}

.editor-pane {
  min-width: 0;
  min-height: 0;
  position: relative;
}

.editor {
  position: absolute;
  inset: 0;
  color: var(--text-dim);
}

.splitter {
  cursor: col-resize;
  background: var(--border);
  touch-action: none;
}

.splitter:hover,
.splitter.active {
  background: var(--accent);
}

.splitter.horizontal {
  cursor: row-resize;
}

/* iframes swallow the pointer while dragging */
.dragging iframe {
  pointer-events: none;
}

.output-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  /* the canvas, the console's splitter and bar, and the console, which is
     --console-fraction of the pane (dragging can collapse it to its bar) */
  grid-template-rows:
    minmax(0, 1fr)
    6px
    auto
    minmax(0, calc(var(--console-fraction) * 100%));
  background: var(--bg);
}

.stage {
  position: relative;
  background: #000;
}

.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.stage-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: #8a8e99;
}

.stage-message p {
  display: none;
  max-width: 28rem;
  margin: 0;
}

body[data-run="stopped"] .idle-message,
body[data-run="finished"] .idle-message,
body[data-run="checking"] .checking-message,
body.no-webgpu .no-webgpu-message {
  display: block;
}

body.no-webgpu .idle-message {
  display: none;
}

.console-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0.8rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.console-hint {
  font-weight: normal;
  margin-right: auto;
}

.console-wrap {
  position: relative;
  min-height: 0;
  overflow: auto;
  background: var(--code-bg);
}

.console {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.5rem 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-empty {
  margin: 0;
  padding: 0.5rem 0.8rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.line-link {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.console .error {
  color: var(--error);
}

.console .info {
  color: var(--text-dim);
}

/* ---- the help dialog ---- */

.help {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 1.2rem 1.4rem;
  max-width: 34rem;
}

.help::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.help h2 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
}

.help table {
  border-collapse: collapse;
  width: 100%;
}

.help td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.help td:last-child {
  text-align: right;
  white-space: nowrap;
}

.help kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.help p {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.help form {
  text-align: right;
}

.rename {
  width: min(24rem, calc(100vw - 2rem));
}

.rename input {
  box-sizing: border-box;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
}

.rename input:focus {
  outline: none;
  border-color: var(--accent);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

/* ---- small screens: editor above, output below ---- */

@media (max-width: 52rem) {
  .panes {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows:
      minmax(0, calc(var(--editor-fraction) * 100%))
      6px
      minmax(0, 1fr);
  }

  .splitter {
    cursor: row-resize;
  }

  .links {
    margin-left: 0;
  }
}
