/* ===================================================================
   PRIMAL PLAYGROUND
   IDE-specific styles extending the site design system (template.css)
   =================================================================== */

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-code), monospace;
  background-color: var(--color-bg);
}

/* --- Full-height flex layout --- */
.layout {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.noscript-note {
  margin: 0;
  padding: 1rem 1.25rem;
  font-family: var(--bs-body-font-family);
  font-size: 0.95rem;
  color: var(--color-text-2);
  background: rgba(213,171,121,0.08);
  border-bottom: 1px solid rgba(213,171,121,0.2);
}

/* --- Toolbar navbar (override template.css fixed positioning) --- */
.navbar.navbar-container {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  flex-shrink: 0;
  height: 3.25rem;
}

.navbar.navbar-container .navbar-nav {
  margin-left: 0 !important;
}

/* Toolbar entries that perform an action are buttons; these strip the native
   button chrome so they read identically to the links beside them. */
button.nav-link {
  background: none;
  border: 0;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: inherit;
  cursor: pointer;
}

.navbar-icon {
  color: var(--color-text-2);
  font-size: 1.25rem;
  transition: color var(--t-fast);
  transform: translateY(2px);
  margin-right: 0.35rem;
  margin-bottom: 0.15rem;
}

.nav-link:hover .navbar-icon {
  color: var(--color-gold);
}

.navbar-title {
  color: var(--color-text-3);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  margin-right: 8em;
}

/* --- Split panels --- */
.split {
  display: flex;
  flex-direction: row;
}

.split.content {
  height: 0%;
  flex: 1;
}

/* --- Editor panel ---
   A textarea with transparent text sits exactly on top of a highlighted <pre>,
   so the caret, selection, undo stack and IME are all the browser's own. The two
   layers only line up while they share every metric that moves a glyph, which is
   why font, size, line height, tab size and padding are set on both at once. */
#sourceCode {
  height: 100%;
}

.editor {
  display: flex;
  height: 100%;
  overflow: hidden;
  background-color: var(--code-bg);
}

.editor-gutter,
.editor-highlight,
.editor-highlight code,
.editor-input {
  font-family: var(--font-code), monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 4;
  /* body sets letter-spacing: 0.015em, which the <pre> inherits but the
     textarea does not — form controls opt out. Left alone, the two layers drift
     apart by a fraction of a pixel per character, which is invisible on a short
     line and badly misaligned by the end of a long one. */
  letter-spacing: normal;
}

.editor-gutter {
  flex-shrink: 0;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  overflow: hidden;
  text-align: right;
  white-space: pre;
  color: var(--code-line-number);
  user-select: none;
}

/* The dot sits in the gutter's left padding rather than in the flow, so the
   line numbers do not shift sideways when a marker appears. */
.editor-gutter-line {
  position: relative;
}

.editor-gutter-error {
  color: var(--code-error);
}

.editor-gutter-error::before {
  content: '';
  position: absolute;
  left: -0.7rem;
  top: 50%;
  width: 0.375rem;
  height: 0.375rem;
  margin-top: -0.1875rem;
  border-radius: 50%;
  background-color: var(--code-error);
}

/* Only the compiler errors that carry a position can be pointed at, so the
   underline is a hint and never the report — the console has the message. */
.editor-highlight .tok-error {
  text-decoration: underline wavy var(--code-error);
  text-underline-offset: 0.25em;
  text-decoration-skip-ink: none;
}

.editor-surface {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.editor-highlight,
.editor-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.75rem 0.75rem 0.75rem 0;
  border: 0;
  white-space: pre;
}

/* The <pre> comes first in the DOM but paints last, so the textarea's selection
   rectangle lands behind the coloured glyphs instead of hiding them — the same
   order a real editor draws in. Clicks still reach the textarea underneath
   because this layer takes no pointer events. */
.editor-highlight {
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  color: var(--code-fg);
}

.editor-highlight code {
  font-family: inherit;
}

.editor-input {
  overflow: auto;
  resize: none;
  background-color: transparent;
  color: transparent;
  caret-color: var(--code-caret);
  outline: none;
}

.editor-input::selection {
  background-color: var(--code-selection);
}

/* --- Console panel --- */
#split-1 {
  display: flex;
  flex-direction: column;
}

.console {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  background-color: var(--console-bg);
}

.console-input {
  width: 100%;
  height: 2.5em;
  flex-shrink: 0;
  border: none;
  border-top: 1px solid var(--console-border);
  background-color: var(--console-input-bg);
  padding: 0.5rem 0.8rem;
  color: var(--code-fg);
  font-family: var(--font-code), monospace;
  font-size: 0.85rem;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}

.console-input::placeholder {
  color: var(--code-line-number);
}

/* The border is the whole focus indicator here, so it takes the palette's most
   saturated token colour rather than a tint of the background. */
.console-input:focus {
  background-color: var(--code-selection);
  border-top-color: var(--tok-native);
  outline: none;
}

.console-input:disabled {
  background-color: var(--console-bg);
  color: var(--code-line-number);
}

/* --- Gutter (Split.js divider) --- */
.gutter {
  background-color: var(--console-bg);
  background-repeat: no-repeat;
  background-position: 50%;
  transition: background-color var(--t-fast);
}

.gutter:hover {
  background-color: rgba(213, 171, 121, 0.08);
}

.gutter.gutter-horizontal {
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
  cursor: col-resize;
}

/* --- Output messages --- */
.base-output {
  border-bottom: 1px solid var(--console-border);
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.output-warning {
  color: var(--output-warning);
}

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

.output-success {
  color: var(--output-success);
}

/* --- Dropdown (samples menu) --- */
.dropdown-menu {
  background-color: var(--color-bg-elevated);
  border: var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
}

.dropdown-item {
  color: var(--color-text-2);
  font-size: 0.85rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background-color var(--t-fast);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(213, 171, 121, 0.1);
  color: var(--color-gold);
}

/* --- Toast notifications --- */
.toast {
  background-color: var(--color-bg-elevated);
  border: var(--border-card);
  border-radius: var(--radius-md);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
}

.toast .btn-close {
  transform: scale(0.65);
}

/* --- Feedback modal --- */
.modal-content {
  background-color: var(--color-bg);
  border: var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: var(--border-subtle);
}

.modal-title {
  color: var(--color-gold);
  font-weight: 600;
}

.modal-footer {
  border-top: var(--border-subtle);
}

/* template.css pins .btn to the site body font, which this page never loads,
   so the button would fall back to the browser default. Follow the playground. */
.modal .btn {
  font-family: inherit;
}
