/* Practice warehouse page */

.practice {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "ask" "tables" "results" "match" "chart" "builder";
  gap: 18px;
  margin-top: 0.6rem;
}
@media (min-width: 1100px) {
  .practice {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas:
      "ask tables"
      "results tables"
      "match tables"
      "chart tables"
      "builder tables";
    align-items: start;
  }
  .practice .tables { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
}
.practice .ask { grid-area: ask; }
.practice .tables { grid-area: tables; }
.practice .results { grid-area: results; }
.practice .chart { grid-area: chart; }
.practice .builder { grid-area: builder; }
.practice .match { grid-area: match; }

/* the heat map's one hue: the low end sits near the page colour, the high end far from it */
:root { --heat-lo: #d7ece8; --heat-hi: #0b4a44; --ok: #0f766e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --heat-lo: #1d3a36; --heat-hi: #8be8da; --ok: #5eead4; }
}
:root[data-theme="dark"] { --heat-lo: #1d3a36; --heat-hi: #8be8da; --ok: #5eead4; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--page);
  min-width: 0;
}
@media (min-width: 640px) { .panel { padding: 20px 22px; } }
.panel > h2:first-child, .panel h2.first { margin-top: 0; }
.hint { color: var(--ink-2); font-size: 0.9rem; }

/* loading */
.loading { margin: 0 0 14px; }
.loading ol { list-style: none; padding: 0; margin: 0; }
.loading li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0 0 8px; font-size: 0.92rem; }
.loading .meter { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.loading .meter span { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width 0.2s; }
.loading .state { color: var(--ink-2); }
.loading.done { display: none; }

/* the query box */
.sql {
  display: block;
  width: 100%;
  min-height: 11em;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--code-bg);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  tab-size: 2;
}
.sql:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }

.scan {
  margin: 10px 0 12px;
  padding: 10px 14px;
  border-left: 6px solid var(--brand);
  background: var(--panel);
  border-radius: 0 8px 8px 0;
}
.scan strong { font-size: 1.02rem; }
.scan .scan-cols { display: block; color: var(--ink-2); font-size: 0.86rem; margin-top: 2px; }

.ask .btn-row { margin-top: 12px; }
@media (hover: none) { .hint.keys { display: none; } }
.examples { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.examples .examples-head { margin: 0 0 4px; font-weight: 700; }
.examples > .hint { margin: 0 0 10px; }
.examples .btn { min-height: 42px; font-size: 0.9rem; padding: 6px 14px; }
.ex-group { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.ex-group:first-of-type { border-top: 0; }
.ex-group h3 { margin: 0; font-size: 0.92rem; color: var(--ink-2); }
.ex-locked { margin: 0; font-size: 0.9rem; color: var(--ink-2); padding: 6px 12px; border: 2px dashed var(--line-strong); border-radius: 8px; }
.ex-locked strong { color: var(--ink); }
@media (max-width: 520px) { .ex-group { grid-template-columns: minmax(0, 1fr); gap: 6px; } }

/* match checker */
.match-pick { display: grid; gap: 4px; margin: 12px 0; max-width: 26em; }
.match-pick label { font-weight: 700; }
.match-pick select, .m-grid select, .m-grid input {
  font: inherit; font-size: 0.95rem;
  min-height: 42px; padding: 6px 10px;
  color: var(--ink); background: var(--page);
  border: 2px solid var(--line-strong); border-radius: 8px;
  width: 100%; min-width: 0;
}
.m-grid input { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.85rem; padding: 6px 6px; }
.m-pair select { font-size: 0.84rem; padding: 6px 2px 6px 6px; }
@media (max-width: 520px) { .m-row { padding: 6px 8px 10px; } }
.match-pick select:focus, .m-grid select:focus, .m-grid input:focus {
  border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);
}
.match-variant { border: 0; padding: 0; margin: 0 0 10px; }
.match-variant legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
.match-variant .seg { flex-wrap: wrap; }
.m-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 12px; margin: 12px 0 14px; }
.m-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; margin: 0; min-width: 0; }
.m-row legend { font-weight: 700; padding: 0 4px; }
.m-grid { display: grid; grid-template-columns: minmax(0, 3.9em) minmax(0, 1fr) minmax(0, 1fr); gap: 6px 8px; align-items: center; }
.m-head { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }
.m-label { font-size: 0.85rem; font-weight: 700; line-height: 1.2; }
.m-label.m-wide { grid-column: 1 / -1; margin-top: 4px; }
.m-pair { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 8px; }
.m-shaded {
  grid-column: span 2; min-height: 42px; display: flex; align-items: center; padding: 0 10px;
  font-size: 0.82rem; color: var(--ink-2); border-radius: 8px; border: 1px dashed var(--line-strong);
  background: repeating-linear-gradient(135deg, transparent 0 6px, var(--panel-2) 6px 8px);
}
.m-grid .m-ok { border-color: var(--ok); }
.m-grid .m-bad { border-color: var(--alert); border-style: dashed; }
.m-verdict { grid-column: 1 / -1; margin: -2px 0 4px; font-size: 0.82rem; line-height: 1.3; padding-left: 10px; border-left: 3px solid var(--line-strong); }
.m-verdict.is-ok { border-left-color: var(--ok); color: var(--ink-2); }
.m-verdict.is-ok::before { content: "\2713  "; color: var(--ok); font-weight: 700; }
.m-verdict.is-bad { border-left-color: var(--alert); font-weight: 700; }
.m-verdict.is-bad::before { content: "\2715  "; color: var(--alert); }
.m-result { margin: 4px 0 12px; }
.m-result:focus { outline: none; }
.m-result.ok { border-left-color: var(--ok); background: var(--ok-panel); }
.m-result h3 { font-size: 1.1rem; }
.m-result p { margin: 0 0 6px; }
.m-first { font-weight: 700; }

/* heat map */
.heat-svg .heat-empty-key { fill: none; stroke: var(--line-strong); stroke-dasharray: 2 2; }
.heat-svg .heat-ring { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }

/* results */
.result-status { font-weight: 700; margin-bottom: 10px; }
.result-table { border: 1px solid var(--line); border-radius: 8px; max-height: 32rem; overflow: auto; width: fit-content; max-width: 100%; }
.result-table table { border-collapse: collapse; font-size: 0.85rem; }
.result-table th, .result-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
}
.result-table th {
  position: sticky; top: 0;
  background: var(--panel-2);
  font-weight: 700;
  border-bottom: 2px solid var(--line-strong);
}
.result-table td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.result-table td.rownum, .result-table th.rownum { color: var(--ink-2); text-align: right; font-family: var(--mono); }
.result-table td.blank { color: var(--ink-2); font-style: italic; }
.results .btn-row { margin-top: 12px; }

.error-box h3 { margin: 0 0 6px; font-size: 1.05rem; }
.error-box details { margin-top: 8px; font-size: 0.85rem; }
.error-box pre { white-space: pre-wrap; font-family: var(--mono); font-size: 0.82rem; margin: 6px 0 0; }

/* tables panel */
.tables details > summary { cursor: pointer; }
.tables summary h2 { display: inline; font-size: 1.3rem; margin: 0; }
.schema-table { margin: 14px 0 18px; }
.schema-table h3 { margin: 0 0 2px; font-size: 1.05rem; font-family: var(--mono); }
.schema-table .about { font-size: 0.88rem; color: var(--ink-2); margin: 0 0 8px; }
.schema-table ul { list-style: none; padding: 0; margin: 0; }
.schema-table li { margin: 0; padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.86rem; line-height: 1.4; }
.col-name {
  font: inherit;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.18em;
}
.col-type { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-2); margin-left: 6px; }
.col-note { display: block; color: var(--ink); }
.rules ol { padding-left: 1.3em; font-size: 0.88rem; }
.rules li { margin-bottom: 4px; }
.tables details.rules { margin-top: 6px; }
.tables details.rules summary { font-weight: 700; }

/* chart */
.chart-controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; margin: 8px 0 14px; }
.chart-controls label { display: grid; gap: 4px; font-weight: 700; font-size: 0.9rem; }
.chart-controls select {
  font: inherit; font-size: 0.95rem; font-weight: 400;
  min-height: 44px; padding: 6px 10px;
  color: var(--ink); background: var(--page);
  border: 2px solid var(--line-strong); border-radius: 8px;
  max-width: 100%;
}
.chart-controls fieldset { border: 0; padding: 0; margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chart-controls legend { font-weight: 700; font-size: 0.9rem; padding: 0; margin-bottom: 4px; float: left; width: 100%; }
.seg { display: inline-flex; border: 2px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: block; padding: 8px 14px; min-height: 40px; cursor: pointer; font-weight: 700; font-size: 0.9rem; }
.seg input:checked + label { background: var(--action); color: var(--action-ink); }
.seg input:focus-visible + label { outline: 3px solid var(--brand); outline-offset: -3px; }

.chart-figure { margin: 0; }
.chart-title {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px dashed var(--line-strong);
  padding: 6px 2px;
  margin-bottom: 10px;
  line-height: 1.3;
  resize: none;
  overflow: hidden;
}
.chart-title:focus { outline: none; border-bottom-style: solid; border-bottom-color: var(--brand); }
.chart-title::placeholder { color: var(--ink-2); font-weight: 400; }
.chart-box { position: relative; width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; font-family: var(--font); }
.chart-svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-svg .tick { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-svg .axis-name { fill: var(--ink-2); font-size: 12px; font-weight: 700; }
.chart-svg .mark { fill: var(--chart-mark); }
.chart-svg .bar:hover .mark, .chart-svg .bar:focus .mark { opacity: 0.75; }
.chart-svg .bar:focus { outline: none; }
.chart-svg .bar:focus .hit { stroke: var(--brand); stroke-width: 2; }
.chart-svg .hit { fill: transparent; }
.chart-svg .line { fill: none; stroke: var(--chart-mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--chart-mark); stroke: var(--page); stroke-width: 2; }
.chart-svg .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  line-height: 1.3;
  pointer-events: none;
  white-space: nowrap;
  display: grid;
}
.chart-tip strong { font-size: 1rem; }
.chart-tip span { color: var(--ink-2); }
.chart-note { color: var(--ink-2); font-size: 0.86rem; margin-top: 6px; }

/* prompt builder */
.fields { display: grid; gap: 14px; margin: 14px 0; }
.field label { display: block; font-weight: 700; font-size: 1.02rem; }
.field .hint { display: block; margin: 0 0 6px; }
.field textarea {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}
.field textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }
.added { margin: 6px 0 14px; padding: 10px 14px; background: var(--panel); border-radius: 8px; font-size: 0.9rem; }
.builder details summary { cursor: pointer; font-weight: 700; margin: 10px 0; }
.copied { font-weight: 700; color: var(--ink); }

.credit { color: var(--ink-2); font-size: 0.86rem; margin-top: 1.6rem; max-width: 52em; }
