/* Palette lifted from the pack (tools/gen_pack.py HEXES) so the editor and the
   in-game tree look like the same thing. */
:root {
  --bg: #0b0c10;
  --panel: #121319;
  --line: #23252e;
  --text: #e6e7ec;
  --dim: #8d92a3;
  --accent: #cfb0ff;
  --accent-dim: #7d63ab;
  --gold: #e2c89b;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, "Segoe UI", Inter, sans-serif;
  overflow: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: #1a1c24;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 10px;
  outline: none;
}

button { cursor: pointer; transition: border-color .15s, background .15s; }
button:hover { border-color: var(--accent-dim); background: #20222c; }
button.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
button.primary:hover { background: #8f74c2; }
button.danger:hover { border-color: #b4566a; color: #ff9aac; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); }

header {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#14151c, #101118);
}

h1 { font-size: 15px; font-weight: 600; letter-spacing: .02em; margin: 0; }
h1 span { color: var(--accent); }
h1 em { color: var(--dim); font-style: normal; font-weight: 400; margin-left: 6px; }

.grow { flex: 1; }

main { display: flex; height: calc(100% - 53px); }

#canvas {
  flex: 1;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(ellipse at 45% 40%, #16171f 0%, var(--bg) 70%);
}
#canvas.panning { cursor: grabbing; }

/* --- the tree ------------------------------------------------------------ */

.link { stroke: #2e3040; stroke-width: 3; }
.hex { stroke-width: 3; }
.hex.normal   { fill: url(#g-normal);  stroke: #8f76bd; }
.hex.keystone,
.hex.root     { fill: url(#g-special); stroke: var(--gold); }
.node.sel .hex { stroke: #fff; filter: url(#glow); }
.node { cursor: pointer; }
.node:hover .hex { filter: url(#glow); }
.icon { fill: #fff; opacity: .92; pointer-events: none; }
.label {
  fill: var(--text);
  font: 500 13px ui-sans-serif, system-ui, sans-serif;
  text-anchor: middle;
  pointer-events: none;
}
.cost { fill: #0e0f14; font: 700 12px ui-monospace, monospace; text-anchor: middle; }
.cost-bg { fill: var(--gold); }
.ghost { fill: transparent; stroke: #2b2e3a; stroke-width: 2; stroke-dasharray: 5 6; cursor: cell; }
.ghost:hover { stroke: var(--accent); fill: rgba(207, 176, 255, .07); }

/* --- side panel ---------------------------------------------------------- */

#panel {
  width: 330px;
  flex: none;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
}

#panel .empty { color: var(--dim); text-align: center; margin-top: 40vh; }
#panel label { display: block; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; margin: 14px 0 5px; }
#panel input, #panel select, #panel textarea { width: 100%; }
#panel textarea { resize: vertical; min-height: 62px; font-family: ui-monospace, "Cascadia Mono", monospace; font-size: 12.5px; }
#panel .row { display: flex; gap: 8px; }
#panel .row > * { flex: 1; }
#panel hr { border: none; border-top: 1px solid var(--line); margin: 18px 0 0; }

.icons { display: flex; flex-wrap: wrap; gap: 6px; }
.icons button { padding: 7px; line-height: 0; }
.icons button.on { border-color: var(--accent); background: #262032; }
.icons svg { width: 18px; height: 18px; fill: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #23202e; border: 1px solid #3a3350; border-radius: 20px;
  padding: 3px 6px 3px 11px; font-size: 12.5px;
}
.chip b { font-weight: 500; }
.chip button { background: none; border: none; padding: 0 4px; color: var(--dim); border-radius: 50%; }
.chip button:hover { color: #ff9aac; background: none; }

/* --- modal --------------------------------------------------------------- */

#modal {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 7, 10, .72); backdrop-filter: blur(3px);
}
#modal[hidden] { display: none; }
.sheet {
  width: min(860px, 92vw); height: min(76vh, 760px);
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.sheet-head { display: flex; gap: 8px; align-items: center; }
#yaml {
  flex: 1; resize: none; white-space: pre; overflow: auto;
  font: 12.5px/1.5 ui-monospace, "Cascadia Mono", monospace;
  background: #0e0f15;
}
#warnings { margin: 0; padding: 0; list-style: none; }
#warnings li { color: #f0c07a; font-size: 12.5px; padding: 2px 0; }
#warnings li::before { content: "! "; opacity: .7; }

#hint {
  position: fixed; bottom: 10px; left: 16px; margin: 0;
  color: #565c6e; font-size: 12px; pointer-events: none;
}
kbd { border: 1px solid #383c4a; border-radius: 4px; padding: 0 4px; font: inherit; }

#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #20222c; border: 1px solid var(--accent-dim); border-radius: 8px;
  padding: 8px 16px; opacity: 0; transition: opacity .25s; pointer-events: none;
}
#toast.show { opacity: 1; }

@media (max-width: 720px) {
  main { flex-direction: column; }
  #panel { width: 100%; height: 45%; border-left: none; border-top: 1px solid var(--line); }
}
