/* style.css — the scheme-rs REPL styles (warez/01-schemers), plus alexandrite additions at the end */

/* ── REPL-specific derived vars ── */

:root {
  --surface-l:     oklch(0.93 0.01  var(--hue));
  --text-bright-l: oklch(0.10 0.02  var(--hue));
  --rule-active-l: oklch(0.74 0.03  var(--hue));
  --on-gold-l:     oklch(1.00 0     0);
  --ok-l:          oklch(0.45 0.14  145);
  --err-l:         oklch(0.50 0.18  25);

  --surface-d:     oklch(0.20 0.02  var(--hue));
  --text-bright-d: oklch(0.92 0.01  var(--hue));
  --rule-active-d: oklch(0.40 0.03  var(--hue));
  --on-gold-d:     oklch(0.15 0.02  var(--hue));
  --ok-d:          oklch(0.65 0.14  145);
  --err-d:         oklch(0.65 0.16  25);

  --surface:     var(--surface-l);
  --text-bright: var(--text-bright-l);
  --rule-active: var(--rule-active-l);
  --on-gold:     var(--on-gold-l);
  --ok:          var(--ok-l);
  --err:         var(--err-l);

  /* ── Syntax tokens ── */
  --hl-comment-l: oklch(0.55 0.02  var(--hue));
  --hl-string-l:  oklch(0.45 0.12  145);
  --hl-number-l:  oklch(0.52 0.14  55);
  --hl-keyword-l: oklch(0.48 0.16  var(--hue));
  --hl-boolean-l: oklch(0.48 0.15  310);
  --hl-paren-l:   oklch(0.60 0.02  var(--hue));

  --hl-comment-d: oklch(0.50 0.02  var(--hue));
  --hl-string-d:  oklch(0.65 0.12  145);
  --hl-number-d:  oklch(0.70 0.13  55);
  --hl-keyword-d: oklch(0.65 0.17  var(--hue));
  --hl-boolean-d: oklch(0.70 0.14  310);
  --hl-paren-d:   oklch(0.50 0.02  var(--hue));

  --hl-comment: var(--hl-comment-l);
  --hl-string:  var(--hl-string-l);
  --hl-number:  var(--hl-number-l);
  --hl-keyword: var(--hl-keyword-l);
  --hl-boolean: var(--hl-boolean-l);
  --hl-paren:   var(--hl-paren-l);

  --editor-font-size: 14px;
  --line-height: 1.65;
}

/* ── Dark swap for REPL vars ── */

@media (prefers-color-scheme: dark) {
  :root {
    --surface:     var(--surface-d);
    --text-bright: var(--text-bright-d);
    --rule-active: var(--rule-active-d);
    --on-gold:     var(--on-gold-d);
    --ok:          var(--ok-d);
    --err:         var(--err-d);

    --hl-comment: var(--hl-comment-d);
    --hl-string:  var(--hl-string-d);
    --hl-number:  var(--hl-number-d);
    --hl-keyword: var(--hl-keyword-d);
    --hl-boolean: var(--hl-boolean-d);
    --hl-paren:   var(--hl-paren-d);
  }
}

:root:has(#t:checked) {
  --surface:     var(--surface-d);
  --text-bright: var(--text-bright-d);
  --rule-active: var(--rule-active-d);
  --on-gold:     var(--on-gold-d);
  --ok:          var(--ok-d);
  --err:         var(--err-d);

  --hl-comment: var(--hl-comment-d);
  --hl-string:  var(--hl-string-d);
  --hl-number:  var(--hl-number-d);
  --hl-keyword: var(--hl-keyword-d);
  --hl-boolean: var(--hl-boolean-d);
  --hl-paren:   var(--hl-paren-d);
}

@media (prefers-color-scheme: dark) {
  :root:has(#t:checked) {
    --surface:     var(--surface-l);
    --text-bright: var(--text-bright-l);
    --rule-active: var(--rule-active-l);
    --on-gold:     var(--on-gold-l);
    --ok:          var(--ok-l);
    --err:         var(--err-l);

    --hl-comment: var(--hl-comment-l);
    --hl-string:  var(--hl-string-l);
    --hl-number:  var(--hl-number-l);
    --hl-keyword: var(--hl-keyword-l);
    --hl-boolean: var(--hl-boolean-l);
    --hl-paren:   var(--hl-paren-l);
  }
}

/* ── Base ── */

html, body {
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid var(--rule);
  background: var(--ground);
  user-select: none;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

h1 {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.02em;
  transition: color var(--duration) var(--ease);
}

h1 span {
  color: var(--gold);
  transition: color var(--duration) var(--ease);
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  transition: color 0.2s;
}

.status.ready   { color: var(--ok); }
.status.running { color: var(--gold); }
.status.error   { color: var(--err); }

button.run {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--on-gold);
  background: var(--gold);
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease),
    transform 0.1s;
  letter-spacing: 0.01em;
}

button.run:hover {
  background: var(--gold-bright);
}

button.run:active {
  transform: scale(0.97);
}

button.run:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 3px;
}

button.run kbd {
  color: var(--on-gold);
  opacity: 0.5;
  margin-left: 8px;
  font-family: system-ui, sans-serif;
  font-size: 11px;
}

/* ── Main Layout ── */

main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Panels ── */

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-editor {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--rule);
  transition: border-color var(--duration) var(--ease);
}

.panel-output {
  flex: 1;
  min-width: 0;
}

h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 20px 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--ground);
  user-select: none;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

/* ── Code Editor ── */

.editor-wrap {
  flex: 1;
  position: relative;
  overflow: auto;
  background: var(--surface);
  transition: background var(--duration) var(--ease);
}

.editor-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.editor-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.editor-wrap::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 4px;
}
.editor-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--rule-active);
}

.editor-container {
  position: relative;
  min-height: 100%;
  display: flex;
}

.line-numbers {
  position: sticky;
  left: 0;
  z-index: 2;
  padding: 16px 0;
  width: 48px;
  min-width: 48px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--line-height);
  color: var(--text-2);
  background: var(--surface);
  user-select: none;
  pointer-events: none;
  opacity: 0.5;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.line-numbers span {
  display: block;
  padding-right: 12px;
}

.code-layers {
  position: relative;
  flex: 1;
  min-width: 0;
}

.highlight-layer, .editor-textarea {
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--line-height);
  padding: 16px 16px 16px 8px;
  white-space: pre;
  word-wrap: normal;
  tab-size: 2;
}

.highlight-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: transparent;
  overflow: hidden;
}

.editor-textarea {
  display: block;
  position: relative;
  width: 100%;
  min-height: 100%;
  resize: none;
  background: transparent;
  caret-color: var(--gold);
  border: none;
  outline: none;
  overflow: hidden;
  z-index: 1;
  color: transparent;
}

.editor-textarea::selection {
  background: oklch(from var(--gold) l c h / 0.25);
  color: transparent;
}

.editor-textarea:focus-visible {
  outline: none;
}

/* ── Syntax highlight tokens ── */

.hl-comment { color: var(--hl-comment); font-style: italic; }
.hl-string  { color: var(--hl-string); }
.hl-number  { color: var(--hl-number); }
.hl-keyword { color: var(--hl-keyword); }
.hl-boolean { color: var(--hl-boolean); }
.hl-paren   { color: var(--hl-paren); }
.hl-plain   { color: var(--text); }

/* ── Output Panel ── */

.output-wrap {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  padding: 16px 20px;
  transition: background var(--duration) var(--ease);
}

.output-wrap::-webkit-scrollbar {
  width: 8px;
}
.output-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.output-wrap::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 4px;
}

.output-content {
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--line-height);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-bright);
  transition: color var(--duration) var(--ease);
}

.output-content.empty {
  color: var(--text-2);
  font-style: italic;
}

.output-content.error {
  color: var(--err);
}

.output-meta {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  transition:
    color var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

/* ── Divider ── */

.divider {
  width: 1px;
  background: var(--rule);
  cursor: col-resize;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}

.divider::after {
  content: '';
  position: absolute;
  inset: 0 -3px;
}

.divider:hover, .divider.active {
  background: var(--rule-active);
}

/* ── Loading state ── */

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ground);
  z-index: 100;
  transition: opacity 0.3s var(--ease);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
}

.loading-text .dot {
  animation: blink 1.2s infinite;
}
.loading-text .dot:nth-child(2) { animation-delay: 0.2s; }
.loading-text .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.2; }
  30% { opacity: 1; }
}

/* ── Responsive ── */

@media (max-width: 700px) {
  main { flex-direction: column; }
  .panel-editor {
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .divider { display: none; }
  .panel-editor, .panel-output { flex: 1; }
}

/* ── alexandrite additions ── */

.examples {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 5px 8px;
  max-width: 16rem;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.examples:hover { border-color: var(--rule-active); }
.examples:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }

button.run.stop {
  background: var(--err);
}

.hl-attr   { color: var(--hl-boolean); }
.hl-type   { color: var(--hl-boolean); }
.hl-symbol { color: var(--hl-number); }

.output-stderr {
  color: var(--err);
}

.output-meta .fast {
  color: var(--gold);
}

@media (max-width: 700px) {
  .examples { max-width: 9rem; }
  nav { gap: 10px; }
}
