/* SequelFables: the styles this game adds to FablesCore. The code and option styles are the
   family's (CodeFables, ScaleFables); the tables, NULLs and SQL colors are this game's own. */

.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; }
}

/* SequelFables additions */
.cf-lines.static .cf-line { cursor: default; }
.cf-line.sq-hl { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left-color: var(--accent); }
.sq-query { margin: 12px 0 0; }
.sq-prompt { margin: 14px 0 0; font-weight: 600; }

/* SQL: keywords in the game color, strings and numbers set apart, NULL gray. */
.sq-kw { color: var(--accent); font-weight: 600; }
.sq-str { color: #a16207; }
.sq-num { color: #7c3aed; }
.sq-nullkw { color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .sq-str { color: #fcd34d; }
  .sq-num { color: #c4b5fd; }
}

/* The data: small tables, side by side when there is room. */
.sq-data { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.sq-table-wrap { max-width: 100%; overflow-x: auto; }
.sq-table { border-collapse: collapse; font-size: 0.88rem; background: var(--surface); }
.sq-table caption { caption-side: top; text-align: left; font: 600 0.85rem var(--mono); padding: 0 0 4px; color: var(--ink); }
.sq-table th, .sq-table td { padding: 3px 9px; border: 1px solid var(--line); text-align: left; white-space: nowrap; }
.sq-table th { font: 600 0.8rem var(--mono); color: var(--muted); background: var(--paper); }
.sq-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sq-null { display: inline-block; padding: 0 5px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); font: 600 0.72rem/1.5 var(--mono); letter-spacing: 0.02em; }
.sq-empty { color: var(--muted); font-style: italic; text-align: center; }
.sq-table-wrap.small .sq-table { font-size: 0.82rem; }
.sq-notes { margin: 8px 0 0; padding-left: 1.1em; color: var(--muted); font-size: 0.85rem; }
.sq-intent { margin: 12px 0 0; padding: 8px 12px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; font-weight: 600; }
.sq-fixnote { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }

/* Choices */
.sq-counts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sq-counts .sq-option { grid-template-columns: 1fr; justify-items: center; }
.sq-count { font: 700 1.25rem var(--mono); }
.sq-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sq-option { align-items: start; }
.sq-option .sq-table { background: transparent; }
.cf-option.tried .sq-table { text-decoration: line-through; }
.sq-choice-query { margin: 0; font: 0.82rem/1.5 var(--mono); white-space: pre; overflow-x: auto; }
.sq-fine { margin-top: 12px; }
.sq-fine.is-answer { border-color: var(--good); background: var(--good-soft); }
.sq-fine.tried { opacity: 0.6; text-decoration: line-through; }

@media (max-width: 480px) {
  .sq-table { font-size: 0.8rem; }
  .sq-table th { font-size: 0.72rem; }
  .sq-table th, .sq-table td { padding: 3px 5px; white-space: normal; }
  .sq-table td.num { white-space: nowrap; }
}

@media (max-width: 560px) {
  .sq-results { grid-template-columns: 1fr; }
  .sq-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A shown query is not tappable: no hover. On a phone, long lines wrap under themselves. */
.cf-lines.static .cf-line:hover { background: none; border-left-color: transparent; }
.cf-lines.static .cf-line.sq-hl:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); border-left-color: var(--accent); }
@media (max-width: 480px) {
  .sq-query .cf-line { white-space: pre-wrap; overflow-wrap: anywhere; }
  .sq-choice-query { white-space: pre-wrap; overflow-wrap: anywhere; }
}
