/* The SQL widget of /learn-sql/: editors, results, the transaction bar and the table list. The
   colors come from the site's tokens in style.css. */

.lsql-status {
    font-size: var(--type-300);
    color: var(--ui-muted);
}
.lsql-status[data-state="busy"]::before {
    content: "";
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-right: 0.5em;
    border: 2px solid var(--ui-accent);
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.1em;
    animation: lsql-spin 0.8s linear infinite;
}
.lsql-status[data-state="ready"]::before {
    content: "";
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: #6fd08c;
    box-shadow: 0 0 6px #6fd08c;
}
.lsql-status[data-state="error"] {
    color: #ff8a80;
}
@keyframes lsql-spin {
    to { transform: rotate(360deg); }
}

/* CodeMirror, in the site's dark theme */
.lsql-codemirror.CodeMirror {
    height: auto;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: var(--ui-sunk);
    color: var(--ui-heading);
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 0.92rem;
    line-height: 1.55;
}
.lsql-codemirror .CodeMirror-scroll {
    min-height: 3.5em;
}
.lsql-codemirror .CodeMirror-gutters {
    background: var(--ui-ground);
    border-right: 1px solid var(--ui-line-soft);
}
.lsql-codemirror .CodeMirror-linenumber {
    color: var(--ui-muted);
}
.lsql-codemirror .CodeMirror-cursor {
    border-left-color: var(--ui-heading);
}
.lsql-codemirror .CodeMirror-selected,
.lsql-codemirror.CodeMirror-focused .CodeMirror-selected {
    background: var(--ui-line);
}
.lsql-codemirror.CodeMirror-focused {
    box-shadow: 0 0 0 1px var(--ui-accent);
}
.lsql-codemirror .cm-keyword { color: var(--ui-accent-bright); }
.lsql-codemirror .cm-string { color: #e6c07b; }
.lsql-codemirror .cm-number { color: #d19a66; }
.lsql-codemirror .cm-comment { color: var(--ui-muted); }
.lsql-codemirror .cm-builtin, .lsql-codemirror .cm-type { color: #c792ea; }
.lsql-codemirror .cm-operator { color: var(--ui-text); }
.lsql-codemirror .cm-variable-2,
.lsql-codemirror .cm-variable-3 { color: #9cdcfe; }
/* inside a lesson the editor sits in markdown, whose pre style must not reach CodeMirror's lines */
.lsql-codemirror pre.CodeMirror-line,
.lsql-codemirror pre.CodeMirror-line-like {
    margin: 0;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    white-space: pre-wrap;
}
.lsql-error-mark {
    background: rgba(255, 82, 82, 0.35);
    border-bottom: 2px solid #ff5252;
}

/* the SQL as the page shows it before the editor replaces it, and without JavaScript */
pre.lsql-sql {
    margin: 0 0 1rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: var(--ui-sunk);
    color: var(--ui-heading);
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.lsql-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin: 0.6rem 0;
}
.lsql-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font: inherit;
    font-weight: 600;
    font-size: var(--type-300);
    padding: 0.4rem 1.1rem;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid var(--ui-accent);
    background: var(--ui-accent);
    color: var(--ui-ground);
    text-decoration: none;
}
.lsql-btn:hover {
    color: var(--ui-ground);
}
.lsql-btn-ghost {
    background: transparent;
    color: var(--ui-accent-bright);
}
.lsql-btn-ghost:hover {
    color: var(--ui-heading);
}
.lsql-btn-small {
    padding: 0.2rem 0.7rem;
    font-size: var(--type-200);
}
.lsql-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.lsql-shortcut {
    font-size: var(--type-200);
    color: var(--ui-muted);
}

.lsql-results p {
    margin: 0.4rem 0;
}
.lsql-before-run {
    font-size: var(--type-300);
    color: var(--ui-muted);
    border: 1px dashed var(--ui-line);
    border-radius: 8px;
    padding: 0.7rem 1rem;
}
.lsql-table-wrapper {
    overflow: auto;
    max-height: 21rem;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
}
.lsql-table-wrapper table {
    border-collapse: collapse;
    width: 100%;
    margin: 0;
    font-size: var(--type-300);
    font-variant-numeric: tabular-nums;
}
.lsql-table-wrapper th,
.lsql-table-wrapper td {
    padding: 0.28rem 0.75rem;
    border: 0;
    border-bottom: 1px solid var(--ui-line-soft);
    text-align: left;
    white-space: nowrap;
    font-size: var(--type-300);
    line-height: 1.5;
    color: var(--ui-text);
    background: transparent;
}
/* the site gives every table header a teal background with !important */
.lsql-table-wrapper th {
    position: sticky;
    top: 0;
    background: var(--ui-ground) !important;
    color: var(--ui-heading) !important;
    font-weight: 600;
}
.lsql-null,
.lsql-table-wrapper td.lsql-null {
    color: var(--ui-muted);
    font-style: italic;
}
.lsql-note {
    font-size: var(--type-200);
    color: var(--ui-muted);
}
.lsql-error {
    color: #ff8a80;
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    font-size: var(--type-300);
    white-space: pre-wrap;
}
.lsql-aborted {
    font-size: var(--type-300);
    color: #e8b04a;
}

/* the observation under a Try it example shows once the example has run */
.lsql-observation {
    display: none;
}
.lsql-ran .lsql-observation {
    display: block;
    margin: 0 0 0.6rem;
    color: var(--ui-heading);
}

/* buttons that run SQL the slide shows */
.lsql-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin: 0.6rem 0 1rem;
}
.lsql-action-result {
    font-size: var(--type-300);
    color: var(--ui-muted);
}
.lsql-action-result[data-state="error"] {
    color: #ff8a80;
}

/* the open-transaction bar */
.lsql-txbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.9rem;
    margin-bottom: 0.9rem;
    border-radius: 8px;
    border: 1px solid rgba(232, 176, 74, 0.45);
    background: rgba(232, 176, 74, 0.1);
    font-size: var(--type-300);
    color: var(--ui-heading);
}
.lsql-txbar[hidden] {
    display: none;
}
.lsql-txbar[data-state="aborted"] {
    border-color: rgba(255, 138, 128, 0.5);
    background: rgba(255, 138, 128, 0.08);
}
.lsql-txbar[data-state="done"] {
    border-color: rgba(111, 208, 140, 0.45);
    background: rgba(111, 208, 140, 0.08);
}
.lsql-txbar-text {
    margin: 0;
    flex: 1 1 16rem;
}

.lsql-tables {
    font-size: var(--type-300);
    padding-left: 1.1rem;
    margin: 0;
}
.lsql-tables li {
    margin-bottom: 0.4rem;
}
.lsql-tables strong {
    color: var(--ui-heading);
}

/* ---------- a lesson: a deck of slides ---------- */

.lsql-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.6rem 1.5rem;
    background: rgba(10, 22, 40, 0.94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--ui-line-soft);
    font-size: var(--type-300);
}
.lsql-brand {
    color: var(--ui-heading);
    font-weight: 700;
    font-size: var(--type-500);
    text-decoration: none;
}
.lsql-brand:hover {
    color: var(--ui-heading);
}
.lsql-crumbs,
.lsql-crumbs a {
    color: var(--ui-muted);
}
.lsql-grow {
    flex: 1;
}

.lsql-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1.5rem 0;
}
.lsql-deck {
    width: 100%;
    max-width: 1000px;
    min-width: 0;
    flex: 1;
}
.lsql-slide {
    position: relative;
    background: var(--ui-surface);
    border: 1px solid var(--ui-line);
    border-radius: 14px;
    padding: 2rem 2.5rem 2.25rem;
    margin-bottom: 1.5rem;
    min-height: 560px;
    color: var(--ui-text);
    font-size: 1.0625rem;
    line-height: 1.65;
}
.lsql-js .lsql-slide {
    display: none;
    margin-bottom: 0;
}
.lsql-js .lsql-slide.lsql-current {
    display: block;
    animation: lsql-fade 0.25s ease-out;
}
@keyframes lsql-fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
.lsql-slide h1,
.lsql-slide h2 {
    color: var(--ui-heading);
    line-height: 1.25;
    font-weight: 600;
}
.lsql-slide h2 {
    font-size: var(--type-700);
    margin: 0 0 1rem;
    padding-right: 5rem;
}
.lsql-slide p,
.lsql-slide li {
    max-width: 46rem;
}
.lsql-slide p {
    margin: 0 0 0.9rem;
}
.lsql-slide .markdown-body {
    font-size: inherit;
    color: inherit;
}
.lsql-slide code {
    font-size: 0.9em;
    color: var(--ui-heading);
    background: var(--ui-sunk);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}
.lsql-slide pre code {
    padding: 0;
    background: transparent;
}
.lsql-slide .markdown-body > pre {
    margin: 0 0 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: var(--ui-sunk);
    font-size: 0.92rem;
    line-height: 1.55;
    white-space: pre-wrap;
}
.lsql-slide strong {
    color: var(--ui-heading);
}
.lsql-kicker {
    font-size: var(--type-200);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ui-accent-bright);
    margin: 0 0 0.4rem !important;
}
.lsql-tables-button {
    position: absolute;
    top: 1.4rem;
    right: 1.5rem;
}

/* a result table that a slide shows, written in markdown; the site gives every table header a
   teal background with !important */
.lsql-slide .markdown-body table {
    width: auto;
    margin: 0 0 1rem;
    border-collapse: collapse;
    font-size: var(--type-300);
    font-variant-numeric: tabular-nums;
}
.lsql-slide .markdown-body th,
.lsql-slide .markdown-body td {
    padding: 0.28rem 0.75rem;
    border: 0;
    border-bottom: 1px solid var(--ui-line-soft);
    text-align: left;
    white-space: nowrap;
    font-size: var(--type-300);
}
.lsql-slide .markdown-body th {
    background: var(--ui-ground) !important;
    color: var(--ui-heading) !important;
    font-weight: 600;
}

.lsql-figure {
    margin: 0 0 1.25rem;
}
.lsql-figure img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 10px;
}
/* the width attribute is the diagram at 1.13 times its units; a wider diagram shrinks to the slide */
.lsql-figure svg.dbs-diagram {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}
/* the table diagram of a slide sits above its editor, so it stays short */
.lsql-figure-tables {
    margin-bottom: 1rem;
}
/* tooltips need a pointer that hovers, so a touch screen leaves the hint out */
@media (hover: none) {
    .lsql-figure-tables figcaption {
        display: none;
    }
}
.lsql-figure-narrow img {
    max-width: 520px;
    margin: 0 auto;
}
.lsql-figure-tiny img {
    max-width: 300px;
    margin: 0 auto;
}
.lsql-figure figcaption {
    font-size: var(--type-200);
    color: var(--ui-muted);
    margin-top: 0.45rem;
    text-align: center;
}
.lsql-split {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
    margin-bottom: 1rem;
}

.lsql-title-slide {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.lsql-js .lsql-title-slide.lsql-current {
    display: flex;
}
.lsql-title-slide h1 {
    font-size: var(--type-900);
    margin: 0 0 1rem;
}
.lsql-for {
    color: var(--ui-muted);
    margin-bottom: 1.5rem !important;
}
.lsql-goal {
    border-left: 4px solid var(--ui-accent);
    background: var(--ui-sunk);
    border-radius: 8px;
    padding: 0.9rem 1.2rem;
    color: var(--ui-heading);
    max-width: 46rem;
    margin-bottom: 1.5rem;
}
.lsql-outline {
    list-style: none;
    padding: 0;
    margin: 0 0 1.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.lsql-outline li {
    font-size: var(--type-300);
    border: 1px solid var(--ui-line);
    border-radius: 999px;
    padding: 0.15rem 0.75rem;
}

.lsql-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}
.lsql-cta .lsql-note {
    margin: 0;
}

/* exercises */
.lsql-ex-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}
.lsql-ex-meta .lsql-kicker {
    margin: 0 !important;
}
.lsql-badge {
    font-size: var(--type-200);
    padding: 0.05rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--ui-line);
    color: var(--ui-muted);
}
.lsql-badge[hidden] {
    display: none;
}
.lsql-badge-solved {
    color: #6fd08c;
    border-color: rgba(111, 208, 140, 0.5);
}
.lsql-badge-order {
    color: #e8b04a;
    border-color: rgba(232, 176, 74, 0.5);
}
.lsql-task {
    color: var(--ui-heading);
    font-size: var(--type-500);
    margin-bottom: 0.8rem;
}
.lsql-task p {
    margin-bottom: 0.5rem;
}
details.lsql-expected,
details.lsql-answer {
    margin: 0 0 0.8rem;
    font-size: var(--type-300);
}
details.lsql-expected summary,
details.lsql-answer summary {
    cursor: pointer;
    color: var(--ui-accent-bright);
}
details.lsql-expected .lsql-table-wrapper {
    margin-top: 0.5rem;
    max-height: 11rem;
}
details.lsql-answer pre {
    margin-top: 0.5rem;
}
.lsql-choices {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.5rem 0 0.8rem;
}
.lsql-choice {
    font: inherit;
    font-size: var(--type-400);
    text-align: left;
    color: var(--ui-heading);
    background: var(--ui-sunk);
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
}
.lsql-choice:hover {
    border-color: var(--ui-accent);
}
.lsql-choice[data-state="right"] {
    border-color: rgba(111, 208, 140, 0.7);
}
.lsql-choice[data-state="wrong"] {
    border-color: rgba(255, 138, 128, 0.7);
}
.lsql-verdict {
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-size: var(--type-300);
    margin-top: 0.7rem;
}
.lsql-verdict[hidden] {
    display: none;
}
.lsql-verdict[data-state="ok"] {
    background: rgba(111, 208, 140, 0.08);
    color: #6fd08c;
    border: 1px solid rgba(111, 208, 140, 0.35);
}
.lsql-verdict[data-state="bad"] {
    background: rgba(255, 138, 128, 0.07);
    border: 1px solid rgba(255, 138, 128, 0.35);
}
.lsql-verdict[data-state="busy"] {
    border: 1px dashed var(--ui-line);
    color: var(--ui-muted);
}
.lsql-verdict p {
    margin: 0 0 0.4rem;
}
.lsql-verdict-title {
    color: #ff8a80;
    font-weight: 600;
}
.lsql-hintbox {
    margin-top: 0.6rem;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(232, 176, 74, 0.4);
    background: rgba(232, 176, 74, 0.08);
    color: var(--ui-heading);
}
.lsql-hintbox b {
    color: #e8b04a;
}
.lsql-privacy {
    font-size: var(--type-200);
    color: var(--ui-muted);
    margin: 0.2rem 0 0 !important;
}

/* the navigation under the slide */
.lsql-deck-nav {
    position: sticky;
    bottom: 0;
    width: 100%;
    max-width: 1000px;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0 1.1rem;
    background: linear-gradient(to top, var(--ui-ground) 70%, transparent);
}
.lsql-deck-nav[hidden] {
    display: none;
}
.lsql-dots {
    flex: 1;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.lsql-dot {
    width: 0.65rem;
    height: 0.65rem;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--ui-line);
    background: transparent;
    cursor: pointer;
}
.lsql-dot-exercise {
    border-radius: 2px;
}
.lsql-dot-seen {
    background: var(--ui-line);
}
.lsql-dot-solved {
    background: #6fd08c;
    border-color: #6fd08c;
}
.lsql-dot-current {
    background: var(--ui-accent);
    border-color: var(--ui-accent);
}
.lsql-dot-separator {
    width: 1px;
    background: var(--ui-line);
    margin: 0 0.3rem;
}
.lsql-counter {
    font-size: var(--type-300);
    color: var(--ui-muted);
    min-width: 7rem;
    text-align: center;
}

/* the drawers: All lessons and Tables */
.lsql-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: min(26rem, 100vw);
    overflow-y: auto;
    padding: 1rem 1.25rem 1.5rem;
    background: var(--ui-surface);
    border-left: 1px solid var(--ui-line);
    box-shadow: -12px 0 32px rgba(0, 0, 0, 0.45);
    font-size: var(--type-300);
}
.lsql-drawer[hidden] {
    display: none;
}
.lsql-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}
.lsql-drawer-head h2 {
    font-size: var(--type-500);
    color: var(--ui-heading);
    margin: 0;
}
.lsql-drawer .lsql-tables {
    margin-bottom: 1rem;
}

.lsql-lesson-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}
.lsql-lesson-part {
    margin: 1rem 0 0.3rem;
    font-size: var(--type-200);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ui-accent-bright);
}
.lsql-lesson-item {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
}
.lsql-lesson-item.lsql-current {
    background: var(--ui-sunk);
}
.lsql-lesson-number {
    color: var(--ui-muted);
    text-align: right;
}
.lsql-lesson-item a {
    color: var(--ui-heading);
}
.lsql-lesson-planned {
    color: var(--ui-muted);
}
.lsql-lesson-progress {
    font-size: var(--type-200);
    color: var(--ui-muted);
    white-space: nowrap;
}
.lsql-complete .lsql-lesson-progress {
    color: #6fd08c;
}

/* a slide has room for a short result only, so a long one scrolls inside its box */
.lsql-slide .lsql-table-wrapper {
    max-height: 15rem;
}

@media (max-width: 820px) {
    /* one row on a phone: the status gives way, cut short */
    .lsql-topbar {
        padding: 0.5rem 1rem;
        flex-wrap: nowrap;
        gap: 0.75rem;
    }
    .lsql-grow {
        display: none;
    }
    .lsql-topbar .lsql-status {
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: var(--type-200);
    }
    .lsql-topbar .lsql-btn {
        flex: none;
    }
    .lsql-crumbs {
        display: none;
    }
    .lsql-main {
        padding: 1rem 1rem 4.5rem;
    }
    .lsql-slide {
        padding: 1.25rem 1.1rem 1.5rem;
        min-height: 0;
    }
    .lsql-slide h2 {
        font-size: var(--type-600);
        padding-right: 0;
    }
    .lsql-title-slide h1 {
        font-size: var(--type-700);
    }
    .lsql-task {
        font-size: var(--type-400);
    }
    .lsql-tables-button {
        position: static;
        float: right;
        margin: 0 0 0.5rem 0.5rem;
    }
    .lsql-split {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }
    .lsql-dots {
        display: none;
    }
    .lsql-counter {
        flex: 1;
        min-width: 0;
    }
    /* on a phone the navigation stays at the bottom of the screen */
    .lsql-deck-nav {
        position: fixed;
        left: 0;
        right: 0;
        padding: 0.7rem 1rem 0.9rem;
        background: var(--ui-ground);
        border-top: 1px solid var(--ui-line-soft);
    }
    /* a diagram shrunk to a phone's width is unreadable, so it keeps a readable size and scrolls sideways */
    .lsql-figure {
        overflow-x: auto;
        scrollbar-color: var(--ui-line) transparent;
    }
    .lsql-figure img {
        min-width: 560px;
    }
    .lsql-figure-tiny img {
        min-width: 280px;
    }
    /* a DbSchema diagram keeps its width attribute up to a cap, and scrolls sideways beyond the phone */
    .lsql-figure svg.dbs-diagram {
        max-width: 760px;
        margin: 0;
    }
}
