/* ScaleFables: the styles this game adds to FablesCore. */

.cf-code,
.cf-lines,
.cf-option pre {
  margin: 0;
  font: 0.92rem/1.55 var(--mono);
  tab-size: 4;
}

.cf-code {
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: pre;
}

/* Spot the bug: every line is a button, numbered. */
.cf-lines { list-style: none; padding: 6px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow-x: auto; counter-reset: line; }
.cf-lines li { counter-increment: line; }
.cf-line {
  display: block;
  width: 100%;
  min-height: 1.9em;
  padding: 2px 12px 2px 3.2em;
  position: relative;
  border: 0;
  border-left: 3px solid transparent;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  white-space: pre;
  cursor: pointer;
}
.cf-line::before { content: counter(line); position: absolute; left: 0.8em; width: 1.6em; color: var(--muted); text-align: right; }
.cf-line:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 10%, transparent); border-left-color: var(--accent); }
.cf-line:disabled { cursor: default; }
.cf-line.blank { cursor: default; }
.cf-line.tried { text-decoration: line-through; color: var(--muted); }
.cf-line.is-answer { background: var(--good-soft); border-left-color: var(--good); }
.cf-fix { margin: 8px 0 0; font-size: 0.9rem; }
.cf-fix code { font: 0.88rem var(--mono); padding: 1px 4px; border-radius: 4px; background: var(--good-soft); }

/* Trace and pick: options to choose. */
.cf-options { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.cf-options.trace { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cf-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cf-option pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.cf-letter { font: 700 0.85rem/1.6 system-ui, sans-serif; color: var(--muted); }
.cf-option:hover:not(:disabled) { border-color: var(--accent); }
.cf-option:disabled { cursor: default; }
.cf-option.tried { opacity: 0.6; }
.cf-option.tried pre { text-decoration: line-through; }
.cf-option.is-answer { border: 2px solid var(--good); background: var(--good-soft); opacity: 1; }
.cf-option.is-answer pre { text-decoration: none; }

@media (max-width: 480px) {
  .cf-options.trace { grid-template-columns: 1fr; }
  .cf-code, .cf-lines, .cf-option pre { font-size: 0.84rem; }
}

/* ScaleFables additions */
.cf-lines.static .cf-line { cursor: default; }
.cf-line.sf-hl { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left-color: var(--accent); }
.sf-title { margin: 0 0 8px; font-weight: 600; }
.sf-program { margin: 0 0 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sf-prompt { margin: 14px 0 0; font-weight: 600; }

.sf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sf-option { align-items: center; grid-template-columns: auto 1fr; }
.sf-choices:not(.sf-grid) .sf-option { grid-template-columns: 1fr; }
.sf-choice-label { font-weight: 600; }
.sf-curve { display: block; }
.sf-curve .sf-axis { stroke: var(--line); stroke-width: 1.5; }
.sf-curve .sf-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sf-curve .sf-limit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }

.sf-diagram { margin: 0; }
.sf-diagram svg { display: block; width: 100%; max-width: 420px; height: auto; }
.sf-diagram rect { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.sf-diagram text { fill: var(--ink); font: 600 13px system-ui, sans-serif; }
.sf-diagram .sf-arrow { stroke: var(--muted); stroke-width: 1.5; }
.sf-diagram .sf-head { fill: var(--muted); }
.sf-diagram .is-answer rect { fill: var(--good-soft); stroke: var(--good); stroke-width: 2.5; }
.sf-diagram figcaption { margin-top: 6px; color: var(--muted); font-size: 0.85rem; }
.sf-tasklist { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }

.sf-order-list { display: grid; gap: 8px; margin: 12px 0 8px; padding: 0; list-style: none; }
.sf-snippet {
  display: grid; grid-template-columns: 2em 1fr; gap: 10px; align-items: start;
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.sf-snippet pre { margin: 6px 0 0; font: 0.82rem/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.sf-snippet .sf-title { margin: 0; }
.sf-place { display: grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 50%; border: 2px solid var(--accent); font-weight: 700; }
.sf-snippet.placed { border-color: var(--accent); }
.sf-snippet.placed .sf-place { background: var(--accent); color: var(--paper); }
.sf-snippet:disabled { cursor: default; }

@media (max-width: 480px) {
  .sf-grid { grid-template-columns: 1fr; }
}

/* Data movement: a loop as a choice. */
.sf-choice-code { margin: 4px 0 0; font: 0.82rem/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
