/* Typography and colours: monospace, small, lowercase,
   #333 on white, brown links that turn deeppink and strike through on hover. */

:root {
  --bg: #ffffff;
  --text: #333333;
  --muted: #5f5f5f;
  --rule: #e6e6e6;
  --link: brown;
  --accent: deeppink;
  --mono: 'Roboto Mono', ui-monospace, monospace;
  font: 400 13.6px/1.6 var(--mono);
}

* { box-sizing: border-box; }

::selection { color: white; background: deeppink; }

body {
  --left: 33.3%; /* node canvas : viewport ≈ 1 : 2 */
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: var(--left) 3px 1fr;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ---------------------------------------------------------------- top bar */

#topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 14px 20px 12px;
  flex-wrap: wrap;
  font-size: 16px;
}
#topbar h1 { font: 700 20px/1.4 var(--mono); margin: 0; letter-spacing: 0.02em; }
#topbar label { display: flex; align-items: baseline; gap: 6px; color: var(--muted); }
.group { display: flex; align-items: baseline; gap: 10px; }
.grow { flex: 1; }

/* buttons read as links: /new/ /open/ … */
button {
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button:hover { color: var(--accent); text-decoration: line-through; text-decoration-thickness: 1.2px; }
button:active { color: green; }

select, input {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 0 2px;
}
select { cursor: pointer; }
select:hover, input:hover { border-bottom-color: var(--accent); }
select:focus, input:focus { outline: none; border-bottom-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); border: 0; }
.num { width: 64px; }
#preset { max-width: 300px; color: var(--link); }

/* ---------------------------------------------------------------- node editor */

#graph { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
#graph canvas { display: block; outline: none; } /* focused for key events, not to be outlined */
#graph-hint {
  position: absolute;
  left: 14px;
  bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
#splitter { cursor: col-resize; background: #333; }
#splitter:hover { background: var(--accent); }

/* LiteGraph menus, search box and value prompt: white, same type */
.litegraph, .litegraph .litemenu-entry, .litegraph.litesearchbox, .graphdialog, .graphdialog input {
  font-family: var(--mono) !important;
}
.litegraph.litecontextmenu, .litegraph.litecontextmenu.dark {
  background: #fff !important;
  box-shadow: 0 0 0 1px var(--rule) !important;
  padding: 4px 0 !important;
}
/* value lists (combo widgets) open as a "dark" menu, whose entries LiteGraph
   paints black with a more specific rule */
.litegraph .litemenu-title, .litegraph.litecontextmenu .litemenu-entry, .litegraph.litecontextmenu .litemenu-entry.submenu,
.litegraph.litecontextmenu.dark .litemenu-entry.submenu {
  background: #fff !important;
  color: var(--text) !important;
  font-size: 14px !important;
}
.litegraph .litemenu-entry:hover:not(.disabled):not(.separator) {
  background: #fff !important;
  color: var(--accent) !important;
  text-decoration: line-through;
}
.litegraph .litemenu-entry.separator { background: var(--rule) !important; }
.litegraph.litesearchbox {
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.litegraph.litesearchbox input, .litegraph.litesearchbox select {
  background: #fff !important;
  color: var(--text) !important;
  border: 0 !important;
  border-bottom: 1px solid var(--rule) !important;
}
.litegraph.lite-search-item {
  background: #fff !important;
  color: var(--text) !important;
  font-size: 14px !important;
  padding: 2px 10px !important;
  text-transform: lowercase; /* type ids read like the site's paths: primitive/box */
}
.litegraph.litesearchbox input, .litegraph.litesearchbox .name { font-size: 14px !important; }
.litegraph.lite-search-item.generic_type { color: var(--muted) !important; }
.litegraph.lite-search-item.selected, .litegraph.lite-search-item:hover { color: var(--accent) !important; background: #fff !important; }
.graphdialog, .litegraph .graphdialog {
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.graphdialog .name { color: var(--muted) !important; }
.graphdialog input, .graphdialog .value {
  background: #fff !important;
  color: var(--text) !important;
  border: 0 !important;
  border-bottom: 1px solid #cfcfcf !important;
  border-radius: 0 !important;
}
.graphdialog button { color: var(--link) !important; background: none !important; border: 0 !important; }

/* ---------------------------------------------------------------- viewport */

#viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#viewport canvas { display: block; }
#hud {
  position: absolute;
  left: 16px;
  right: 140px; /* wrap before the /view/ /frame/ links */
  top: 12px;
  pointer-events: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--hud, var(--text));
}
#status.error, #warning { color: var(--accent); }
#warning { max-width: 440px; }
#stop[hidden] { display: none; }

/* links on top of the 3D view use its readable ink colour */
#viewport > button, #stop { color: var(--hud, var(--link)); font-size: 14px; pointer-events: auto; }
#viewport > button:hover, #stop:hover, #view-toggle.on { color: var(--accent); }
#stop { margin-top: 6px; }
#frame { position: absolute; right: 16px; top: 12px; }
#view-toggle { position: absolute; right: 86px; top: 12px; }

#view-panel {
  position: absolute;
  right: 16px;
  top: 40px;
  width: 280px;
  z-index: 2;
  background: #fff;
  color: var(--text);
  padding: 12px 14px 14px;
  font-size: 14px;
}
#view-panel[hidden] { display: none; }
.vp-row { display: flex; align-items: baseline; gap: 8px; margin: 7px 0; }
.vp-row > span { width: 92px; flex: none; color: var(--muted); }
.vp-row select, .vp-row input[type=range] { flex: 1; min-width: 0; }
.vp-row input[type=range] { accent-color: var(--accent); border: 0; align-self: center; }
.vp-row output { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.vp-row input[type=color] { width: 40px; height: 22px; padding: 0; border: 1px solid var(--rule); align-self: center; }
.vp-title { color: var(--muted); margin: 12px 0 6px; }
.vp-swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.vp-swatch { aspect-ratio: 1; padding: 0; border: 1px solid var(--rule); color: #fff; font-weight: 700; }
.vp-swatch:hover { text-decoration: none; border-color: var(--accent); }
.vp-swatch.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.vp-png { margin-top: 12px; }

#legend {
  position: absolute;
  left: 16px;
  bottom: 10px;
  color: var(--hud, var(--text));
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  pointer-events: none;
}
#legend[hidden] { display: none; }
.chip { display: flex; align-items: center; gap: 5px; }
.chip.empty { opacity: 0.35; }
.chip i { width: 8px; height: 8px; display: inline-block; }

@media (max-width: 760px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 45vh 0 1fr; }
  #splitter { display: none; }
}

/* ---------------------------------------------------------------- phones */
/* viewer only (see main.js): examples, seed and colour on top, the 3D view
   below; editing, files and the face limit are left to desktops */

/* minmax(0, …): the 3D canvas must not hold the column open past the screen */
body.phone { height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
body.phone #graph, body.phone #splitter,
body.phone #topbar .group, body.phone #topbar label:has(#limit) { display: none; }
body.phone #topbar { gap: 6px 16px; padding: 10px 16px 8px; font-size: 15px; }
body.phone #topbar h1 { font-size: 18px; }
body.phone #preset { flex: 1 1 160px; min-width: 0; max-width: none; } /* wide enough to push seed to the next line */
body.phone #viewport { grid-row: 2; }
body.phone #hud { right: 130px; font-size: 13px; }
body.phone #view-panel { right: 8px; left: 8px; width: auto; }
#phone-note {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  color: var(--hud, var(--text));
  font-size: 13px;
}
#phone-note button { color: var(--hud, var(--link)); }
