/* Hack is vendored in fonts/ (MIT, see LICENSE.md there) so the
   editor renders identically offline. Regular weight only: nothing
   in the stylesheet requests bold monospace. */
@font-face {
  font-family: "Hack";
  src: url("fonts/hack-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0e0e10;
  --panel: #18181b;
  --panel-edge: #26262b;
  --text: #efeff1;
  --muted: #8f8f96;
  --accent: #a970ff;
  --accent-dim: #6441a5;
  --error: #ff6b6b;
  --ok: #57d98d;
  --string: #e6b455;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--panel-edge);
}

.logo { width: 32px; height: 32px; }

h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }
h1 .tag { color: var(--accent); font-weight: 400; }

.status { margin-left: auto; font-size: 0.8rem; color: var(--muted); }
.status.ready { color: var(--ok); }
.status.error { color: var(--error); }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Cap the row at main's height so long source scrolls inside the
     editor (keeping the gutter pinned) instead of stretching the page. */
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.25rem;
  min-height: 0;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: none; }
  .pane { min-height: 240px; max-height: 60vh; }
  #editor, #output { max-height: 45vh; }
}

@media (min-width: 901px) {
  /* min-height alone leaves body height content-driven, so a long
     source stretches the page instead of scrolling inside the editor
     (which would drag the gutter off screen). A definite height lets
     flex/grid bound the panes. */
  body { height: 100vh; }
}

.pane {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  overflow: hidden;
  min-height: 320px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.pane-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-edge);
}
.pane-title button {
  text-transform: none;
  letter-spacing: 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
}
.pane-title .examples {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
}
.examples select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.editor-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

/* Numbers must share the editor's font metrics and top padding or the
   rows drift apart. */
#gutter {
  overflow: hidden;
  padding: 0.9rem 0.6ch 0.9rem 0.9rem;
  text-align: right;
  color: var(--muted);
  background: #141416;
  border-right: 1px solid var(--panel-edge);
  user-select: none;
  cursor: default;
  font-family: "Hack", ui-monospace, "Cascadia Code", "JetBrains Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
}

#editor {
  flex: 1;
  padding: 0.9rem;
  overflow: auto;
  /* pre, not pre-wrap: a wrapped line would occupy several rows and
     desynchronize the gutter numbers. */
  white-space: pre;
  font-family: "Hack", ui-monospace, "Cascadia Code", "JetBrains Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  outline: none;
  caret-color: var(--accent);
  cursor: text;
}

#editor:focus { background: #1c1c21; }

#editor .str { color: var(--string); }
#editor .com { color: var(--muted); }

#editor img.emote,
#output img.emote {
  height: 1.35em;
  vertical-align: text-bottom;
  margin: 0 0.05em;
}

#autocomplete {
  display: none;
  position: fixed;
  z-index: 20;
  min-width: 240px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(31, 31, 35, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.75rem;
  font-family: "Hack", ui-monospace, "Cascadia Code", "JetBrains Mono", monospace;
  font-size: 0.9rem;
  cursor: pointer;
}

.ac-item.selected { background: var(--accent-dim); }
.ac-item:hover { background: #2a2a30; }
.ac-item.selected:hover { background: var(--accent-dim); }

.ac-item img {
  height: 1.6em;
  width: auto;
}

.ac-placeholder {
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  background: var(--panel-edge);
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-top: 1px solid var(--panel-edge);
}

button {
  background: var(--accent-dim);
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Secondary button for non-destructive utilities. */
#clear-btn {
  background: transparent;
  border: 1px solid var(--panel-edge);
  color: var(--muted);
}
#clear-btn:hover:not(:disabled) { background: var(--panel-edge); color: var(--text); }

/* Keyboard focus must be visible; default outlines were removed
   for the editor, so restore them for interactive controls. */
button:focus-visible,
.examples select:focus-visible,
#editor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#output {
  flex: 1;
  padding: 0.9rem;
  overflow-y: auto;
  font-family: "Hack", ui-monospace, "Cascadia Code", "JetBrains Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
#output .err { color: var(--error); }
#output .meta { color: var(--muted); font-style: italic; }

/* Friendly empty state so the right pane never looks broken. */
#output:empty::before {
  content: "run your code to see output here";
  color: var(--muted);
  font-style: italic;
}

footer {
  padding: 0.5rem 1.25rem 0.9rem;
  color: var(--muted);
  font-size: 0.8rem;
}
footer a { color: var(--accent); }
footer code {
  background: var(--panel);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
