/* SQL runner and practice generator (public/scripts/sql-runner.js, sql-practice.js). Site tokens, both themes. */
.sqlr-toggle { display:inline-flex; align-items:center; gap:.45rem; min-height:44px; margin-block:.35rem .6rem; padding:.45rem 1rem; border:1px solid var(--line); border-radius:999px; background:var(--chip-bg); color:var(--ink); font:inherit; font-size:.92rem; font-weight:700; cursor:pointer; }
.sqlr-toggle::before { content:"▶"; font-size:.7em; color:var(--accent); }
.sqlr-toggle[aria-expanded="true"]::before { content:"▼"; }
.sqlr-toggle:hover, .sqlr-btn:hover { border-color:var(--accent-2); }
.sqlr-holder[hidden] { display:none; }
.sqlr { position:relative; margin-block:.4rem 1.2rem; padding:.9rem; border:1px solid var(--line); border-block-start:3px solid var(--accent-2); border-radius:var(--radius); background:var(--surface-strong); color:var(--ink); }
/* The editor is a transparent textarea over a colored copy of its text, in the colors of the site's code blocks (Shiki github-dark). */
.sqlr-ed { position:relative; border:1px solid #3a4048; border-radius:.6rem; background:#24292e; color:#e1e4e8; }
.sqlr-hl, .sqlr-editor { box-sizing:border-box; inline-size:100%; margin:0; padding:.7rem .85rem; border:0; font:.95rem/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; direction:ltr; text-align:left; tab-size:4; white-space:pre-wrap; overflow-wrap:break-word; word-break:normal; letter-spacing:normal; }
.sqlr-hl { position:absolute; inset:0; overflow:hidden; pointer-events:none; background:transparent; color:#e1e4e8; }
.sqlr-editor { position:relative; display:block; min-height:5rem; border-radius:.6rem; background:transparent; color:transparent; caret-color:#e1e4e8; overflow:hidden; resize:none; }
.sqlr-editor::selection { background:rgba(121,184,255,.35); color:transparent; }
.sqlr-editor::placeholder { color:#8b949e; opacity:1; }
.sqlr-t-k { color:#F97583; } .sqlr-t-n { color:#79B8FF; } .sqlr-t-s { color:#9ECBFF; } .sqlr-t-c { color:#9ba5af; }
@media screen { pre.sqlr-swapped { display:none; } }
.sqlr-ed:focus-within { outline:3px solid var(--accent-2); outline-offset:2px; }
.sqlr-editor:focus-visible, .sqlr :is(button):focus-visible, .sqlr-scroll:focus-visible { outline:3px solid var(--accent-2); outline-offset:2px; }
.sqlr-bar { display:flex; flex-wrap:wrap; gap:.5rem; margin-block:.6rem; }
.sqlr-btn { min-height:44px; padding:.4rem 1rem; border:1px solid var(--line); border-radius:.6rem; background:var(--surface); color:var(--ink); font:inherit; font-size:.92rem; font-weight:700; cursor:pointer; }
.sqlr-btn[hidden] { display:none; }
.sqlr-btn:disabled { opacity:.55; cursor:default; }
.sqlr-primary { border-color:var(--accent); background:var(--accent); color:#fff; }
:root[data-theme="dark"] .sqlr-primary { color:#0c1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sqlr-primary { color:#0c1220; } }
.sqlr-status { margin:.3rem 0; color:var(--muted); font-size:.88rem; }
.sqlr-error { margin:.5rem 0; padding:.6rem .8rem; border:1px solid #c2410c; border-inline-start-width:4px; border-radius:.5rem; background:rgba(194,65,12,.08); color:var(--ink); font-size:.92rem; direction:ltr; text-align:left; }
.sqlr-collapse { margin-block-start:.6rem; }
.sqlr-scroll { max-inline-size:100%; max-block-size:min(24rem,60vh); margin-block:.6rem; overflow-x:auto; overflow-y:auto; border:1px solid var(--line); border-radius:.6rem; }
.sqlr-table { border-collapse:collapse; inline-size:100%; font-size:.85rem; }
.sqlr-table th, .sqlr-table td { padding:.35rem .6rem; border-bottom:1px solid var(--line); white-space:nowrap; text-align:center; }
.sqlr-table th { position:sticky; inset-block-start:0; background:var(--surface); color:var(--muted); font-weight:750; }
.sqlr-num { font-variant-numeric:tabular-nums; }
.course-content .prose .sqlr-table :is(th, td) { text-align:center; vertical-align:middle; } /* beats the lesson-table rule; headings and values share one centre line */
.sqlr-null { color:var(--muted); font-style:italic; }
.sqlr-export { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem .8rem; margin-block:.3rem .6rem; }
.sqlr-name-label { display:inline-flex; align-items:center; gap:.4rem; color:var(--muted); font-size:.88rem; direction:ltr; }
.sqlr-name { inline-size:11rem; max-inline-size:100%; min-height:44px; padding:.3rem .6rem; border:1px solid var(--line); border-radius:.5rem; background:var(--bg); color:var(--ink); font:inherit; font-size:.9rem; }
.sqlr-name:focus-visible { outline:3px solid var(--accent-2); outline-offset:2px; }
@media (max-width:600px) { .sqlr { padding:.65rem; } .sqlr-table { font-size:.8rem; } }
/* the colour layer must have the same font size as the textarea above it (the generic rule for pre in presentation would enlarge it and the caret would drift) */
/* the presentation rules for lesson tables (full width, wrapping cells) must not squeeze a result table: its headers are column names and stay on one line; course-study.ts scales a table that is too wide */
@media screen { html.is-presenting .prose .sqlr-table { inline-size:max-content; min-inline-size:100%; } html.is-presenting .prose .sqlr-table :is(th, td) { white-space:nowrap; overflow-wrap:normal; text-align:center; vertical-align:middle; } }
@media screen { html.is-presenting .sqlr-editor, html.is-presenting :is(.prose, .course-opening) pre.sqlr-hl { font-size:.8rem; } html.is-presenting .sqlr-table { font-size:.75rem; } }
@media print { .sqlr, .sqlr-toggle, .sqlr-holder, .sql-box, .sql-practice { display:none !important; } }

/* completion list */
.sqlr-suggest { position:absolute; z-index:30; inline-size:max-content; min-inline-size:12rem; max-inline-size:min(22rem, 92%); margin:0; padding:.25rem; list-style:none; border:1px solid var(--line); border-radius:.6rem; background:var(--surface-strong); box-shadow:var(--shadow); direction:ltr; text-align:left; }
.sqlr-suggest[hidden] { display:none; }
.sqlr-opt { display:flex; justify-content:space-between; gap:1rem; padding:.3rem .55rem; border-radius:.4rem; font:.88rem ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; color:var(--ink); cursor:pointer; }
.sqlr-opt.is-active, .sqlr-opt:hover { background:var(--accent); color:#fff; }
:root[data-theme="dark"] .sqlr-opt.is-active, :root[data-theme="dark"] .sqlr-opt:hover { color:#0c1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sqlr-opt.is-active, :root:not([data-theme="light"]) .sqlr-opt:hover { color:#0c1220; } }
.sqlr-opt-detail { opacity:.7; font-size:.78rem; }
.sqlr-keyword .sqlr-opt-text { font-weight:700; }
/* practice generator */
.sql-practice { margin-block:1.2rem; }
.sqlp-controls { display:flex; flex-wrap:wrap; align-items:center; gap:.6rem .9rem; margin-block-end:.6rem; }
.sqlp-select { min-height:44px; padding:.3rem .6rem; border:1px solid var(--line); border-radius:.5rem; background:var(--bg); color:var(--ink); font:inherit; font-size:.92rem; }
.sqlp-card { padding:1rem; border:1px solid var(--line); border-block-start:4px solid var(--accent); border-radius:var(--radius); background:var(--surface); }
.sqlp-title { margin:0 0 .5rem; font-size:1rem; color:var(--muted); }
.sqlp-question { margin:.2rem 0 .8rem; font-size:1.08rem; line-height:1.7; }
.sqlp-tools { display:flex; gap:.5rem; margin-block-end:.4rem; }
.sqlp-hints { margin:.4rem 0 .6rem; padding-inline-start:1.4rem; color:var(--ink); }
.sqlp-feedback { margin-block:.5rem; }
.sqlp-feedback:empty { display:none; }
.sqlp-feedback > * { margin-block:.3rem; }
.sqlp-right, .sqlp-wrong, .sqlp-hint { padding:.6rem .9rem; border:1px solid var(--line); border-inline-start-width:5px; border-radius:.5rem; background:var(--surface-strong); }
.sqlp-right { border-inline-start-color:#2e7d32; }
.sqlp-wrong { border-inline-start-color:#c2410c; }
.sqlp-hint { border-inline-start-color:var(--accent-2); }
.sqlp-answer { margin-block:.6rem; padding:.7rem .9rem; border:1px dashed var(--line); border-radius:.5rem; }
.sqlp-sql { margin:.3rem 0; padding:.6rem .8rem; border-radius:.5rem; background:var(--bg); overflow-x:auto; white-space:pre-wrap; word-break:break-word; font-size:.88rem; }
@media screen { html.is-presenting .sqlp-question { font-size:1.2rem; } }
.sqlr-editor:focus-visible { outline:none; }

.sqlp-card[hidden], .sqlp-file[hidden] { display:none; }
.sqlp-file { margin:.6rem 0; padding:.7rem .9rem; border:1px dashed var(--line); border-radius:.6rem; font-size:.92rem; }
.sqlp-file p { margin:.3rem 0; }

/* the check button shows the verdict itself: green when the answer is right, red when it is not (a mark as well as a colour) */
.sqlr-btn.is-right, .py-button.is-right { border-color:#2e7d32; background:color-mix(in srgb, #2e7d32 30%, var(--surface-strong)); }
.sqlr-btn.is-wrong, .py-button.is-wrong { border-color:#c2410c; background:color-mix(in srgb, #c2410c 30%, var(--surface-strong)); }
.sqlr-btn.is-right::before, .py-button.is-right::before { content:'\2713\00a0'; }
.sqlr-btn.is-wrong::before, .py-button.is-wrong::before { content:'\2717\00a0'; }
@media (max-width:600px) { .sqlr { padding:.45rem; } .sqlr-hl, .sqlr-editor { font-size:.76rem; line-height:1.55; padding:.55rem .6rem; } }
