@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
}

.question-block,
.course-page-block,
.exercise-block,
.solution-block {
    --code-font-size: 0.9rem;
    --code-line-height: 1.5;
}

/* =========================================================
   БЛОЧНЫЙ КОД
   ========================================================= */

.question-block .question-text pre,
.question-block .answer-text pre,
.course-page-block .course-page-text pre,
.exercise-block .exercise-text pre,
.exercise-block .exercise-answer pre,
.solution-block .solution-content pre {
    background-color: #f3f4f6;

    padding: 1rem 1.15rem;
    margin-top: 0;
    margin-bottom: 1rem;

    border: 1px solid transparent;
    border-radius: 12px;

    overflow-x: auto;

    font-family: "JetBrains Mono", monospace;
    font-size: var(--code-font-size);
    font-weight: 400;
    line-height: var(--code-line-height);

    font-variant-ligatures: none;
    font-feature-settings: "liga" 0;

    white-space: pre;
    tab-size: 4;
}

.question-block .question-text pre > code,
.question-block .answer-text pre > code,
.course-page-block .course-page-text pre > code,
.exercise-block .exercise-text pre > code,
.exercise-block .exercise-answer pre > code,
.solution-block .solution-content pre > code {
    display: block;

    padding: 0;
    margin: 0;

    background: transparent;
    border: none;
    border-radius: 0;

    color: #1f2937;

    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;

    white-space: pre;
}

/* Все токены одного размера */
.question-block .question-text pre code,
.question-block .question-text pre code *,
.question-block .answer-text pre code,
.question-block .answer-text pre code *,
.course-page-block .course-page-text pre code,
.course-page-block .course-page-text pre code *,
.exercise-block .exercise-text pre code,
.exercise-block .exercise-text pre code *,
.exercise-block .exercise-answer pre code,
.exercise-block .exercise-answer pre code *,
.solution-block .solution-content pre code,
.solution-block .solution-content pre code * {
    font-family: "JetBrains Mono", monospace;
    font-size: var(--code-font-size) !important;
    font-weight: 400;
    line-height: var(--code-line-height);
}

/* =========================================================
   INLINE-КОД
   ========================================================= */

.question-block .question-text :not(pre) > code,
.question-block .answer-text :not(pre) > code,
.course-page-block .course-page-text :not(pre) > code,

.exercise-block .exercise-text :not(pre) > code,
.exercise-block .exercise-answer :not(pre) > code,
.solution-block .solution-content :not(pre) > code,

.question-block code.hljs.inline-code-highlighted,
.course-page-block code.hljs.inline-code-highlighted,
.exercise-block code.hljs.inline-code-highlighted,
.solution-block code.hljs.inline-code-highlighted {
    display: inline;

    padding: 0.12rem 0.35rem;

    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;

    font-family: "JetBrains Mono", monospace;
    font-size: var(--code-font-size);
    font-weight: 400;
    line-height: 1.25;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
    vertical-align: baseline;
}

.question-block .inline-code-highlighted,
.question-block .inline-code-highlighted *,
.course-page-block .inline-code-highlighted,
.course-page-block .inline-code-highlighted *,
.exercise-block .inline-code-highlighted,
.exercise-block .inline-code-highlighted *,
.solution-block .inline-code-highlighted,
.solution-block .inline-code-highlighted * {
    font-family: "JetBrains Mono", monospace;
    font-size: var(--code-font-size) !important;
    font-weight: 400;
    line-height: 1.25;
}

/* =========================================================
   СВЕТЛАЯ ТЕМА
   ========================================================= */

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-keyword,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-selector-tag,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-literal {
    color: #9c27b0;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-title.class_,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-title.class_.inherited__,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-type {
    color: #1565c0;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-title.function_,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-built_in {
    color: #795548;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-string,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-char.escape_ {
    color: #2e7d32;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-number {
    color: #1565c0;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-comment,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-quote {
    color: #7b8794;
    font-style: italic;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-meta,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-meta .hljs-keyword {
    color: #b45309;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-variable,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-params {
    color: #1f2937;
}

:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-operator,
:is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-punctuation {
    color: #4b5563;
}

/* =========================================================
   ТЁМНАЯ ТЕМА
   ========================================================= */

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) pre {
    background-color: #111827;
    border-color: #374151;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) pre > code {
    color: #d8dee9;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) :not(pre) > code,
body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .inline-code-highlighted {
    background-color: #111827;
    border-color: #273449;
    color: #d1d5db;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) :is(
    .hljs-keyword,
    .hljs-selector-tag,
    .hljs-literal
) {
    color: #cc7832;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) :is(
    .hljs-title.class_,
    .hljs-title.class_.inherited__,
    .hljs-type,
    .hljs-built_in
) {
    color: #a9b7c6;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-title.function_ {
    color: #ffc66d;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) :is(
    .hljs-string,
    .hljs-char.escape_
) {
    color: #6a8759;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-number {
    color: #6897bb;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) :is(
    .hljs-comment,
    .hljs-quote
) {
    color: #808080;
    font-style: italic;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-meta,
body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) .hljs-meta .hljs-keyword {
    color: #bbb529;
}

body.dark-theme :is(
    .question-block,
    .course-page-block,
    .exercise-block,
    .solution-block
) :is(
    .hljs-variable,
    .hljs-params,
    .hljs-operator,
    .hljs-punctuation
) {
    color: #a9b7c6;
}

/* =========================================================
   СКРОЛЛБАР КОДА
   ========================================================= */

.question-block pre,
.course-page-block pre,
.exercise-block pre,
.solution-block pre {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.question-block pre::-webkit-scrollbar,
.course-page-block pre::-webkit-scrollbar,
.exercise-block pre::-webkit-scrollbar,
.solution-block pre::-webkit-scrollbar {
    height: 6px;
}

.question-block pre::-webkit-scrollbar-track,
.course-page-block pre::-webkit-scrollbar-track,
.exercise-block pre::-webkit-scrollbar-track,
.solution-block pre::-webkit-scrollbar-track {
    background: transparent;
}

.question-block pre::-webkit-scrollbar-thumb,
.course-page-block pre::-webkit-scrollbar-thumb,
.exercise-block  pre::-webkit-scrollbar-thumb,
.solution-block pre::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 999px;
}

.question-block pre::-webkit-scrollbar-thumb:hover,
.course-page-block pre::-webkit-scrollbar-thumb:hover,
.exercise-block pre::-webkit-scrollbar-thumb:hover,
.solution-block pre::-webkit-scrollbar-thumb:hover {
    background-color: #9298a1;
}

body.dark-theme .question-block pre,
body.dark-theme .course-page-block pre,
body.dark-theme .exercise-block pre,
body.dark-theme .solution-block  pre {
    scrollbar-color: #4b5563 transparent;
}

body.dark-theme .question-block pre::-webkit-scrollbar-thumb,
body.dark-theme .course-page-block pre::-webkit-scrollbar-thumb,
body.dark-theme .exercise-block  pre::-webkit-scrollbar-thumb,
body.dark-theme .solution-block pre::-webkit-scrollbar-thumb {
    background-color: #4b5563;
}

body.dark-theme .question-block pre::-webkit-scrollbar-thumb:hover,
body.dark-theme .course-page-block pre::-webkit-scrollbar-thumb:hover,
body.dark-theme .exercise-block pre::-webkit-scrollbar-thumb:hover,
body.dark-theme .solution-block pre::-webkit-scrollbar-thumb:hover {
    background-color: #6b7280;
}

/* =========================================================
   CODE BLOCK TOOLBAR
   ========================================================= */

.code-block {
    margin: 1.5rem 0;

    background-color: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 16px;

    overflow: hidden;
}

.code-block__toolbar {
    min-height: 1.5rem;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0.1rem 0.45rem 0.1rem 1rem;

    background-color: #f3f4f6;
}

.code-block__language {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;

    min-width: 0;
}

.code-block__language-icon {
    width: 20px;
    height: 20px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 20px;

    color: #111827;
}

.code-block__language-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.code-block__language-name {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;

    color: #111827;
}

.code-block__copy {
    width: 30px;
    height: 30px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 30px;

    padding: 0;

    border: none;
    border-radius: 9px;

    background: transparent;
    color: #111827;

    cursor: pointer;

    transition:
        background-color 160ms ease,
        color 160ms ease,
        transform 80ms ease;
}

.code-block__copy:hover {
    background-color: #e5e7eb;
}

.code-block__copy:active {
    transform: scale(0.94);
}

.code-block__copy:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.code-block__copy svg {
    display: block;

    width: 22px;
    height: 22px;
}

.code-block__copy.is-copied {
    color: #111827;
}


/* =========================================================
   PRE ВНУТРИ CODE BLOCK
   ========================================================= */

.question-block .question-text .code-block pre,
.question-block .answer-text .code-block pre,
.course-page-block .course-page-text .code-block pre,
.exercise-block .exercise-text .code-block pre,
.exercise-block .exercise-answer .code-block pre,
.solution-block .solution-content .code-block pre {
    margin: 0;

    padding: 0.75rem 1.15rem 1.15rem;

    background: transparent;
    border: none;
    border-radius: 0;
}


/* =========================================================
   DARK THEME
   ========================================================= */

body.dark-theme .code-block {
    background-color: #111827;
    border-color: #374151;
}

body.dark-theme .code-block__toolbar {
    background-color: #111827;
}

body.dark-theme .code-block__language-icon,
body.dark-theme .code-block__language-name,
body.dark-theme .code-block__copy {
    color: #d1d5db;
}

body.dark-theme .code-block__copy:hover {
    background-color: #1f2937;
}

body.dark-theme .code-block__copy.is-copied {
    color: #d1d5db;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {
    .code-block__toolbar {
        min-height: 3.1rem;
        padding: 0.65rem 0.8rem 0.5rem;
    }

    .code-block__language-icon {
        width: 18px;
        height: 18px;
        flex-basis: 18px;
    }

    .code-block__language-name {
        font-size: 0.9rem;
    }

    .code-block__copy {
        width: 28px;
        height: 28px;
        flex-basis: 28px;
    }

    .code-block__copy svg {
        width: 20px;
        height: 20px;
    }

    .question-block .question-text .code-block pre,
    .question-block .answer-text .code-block pre,
    .course-page-block .course-page-text .code-block pre,
    .exercise-block .exercise-text .code-block pre,
    .exercise-block .exercise-answer .code-block pre,
    .solution-block .solution-content .code-block pre {
        padding: 0.65rem 0.9rem 1rem;
    }
}

.code-block__toolbar {
    border-bottom: 1px solid #e5e7eb;
}

body.dark-theme .code-block__toolbar {
    border-bottom-color: #374151;
}

/* =========================================================
   CODE LAB LIVE EDITOR OVERRIDES
   Code Lab's live <pre> must not inherit the rounded static-code block.
   ========================================================= */

.exercise-block .exercise-answer .code-lab .code-lab__editor-highlight,
.course-page-block .code-lab .code-lab__editor-highlight {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    margin: 0 !important;
    padding-top: 0.8rem !important;
    padding-right: 0.9rem !important;
    padding-bottom: 0.8rem !important;
    padding-left: calc(var(--cl-line-gutter, 2.55rem) + 0.8rem) !important;

    border: 0 !important;
    border-radius: 0 !important;

    background: var(--cl-editor) !important;

    overflow: hidden !important;
    white-space: pre !important;
}

.exercise-block .exercise-answer .code-lab .code-lab__editor-highlight > code,
.course-page-block .code-lab .code-lab__editor-highlight > code,
.exercise-block .exercise-answer .code-lab .code-lab__editor-highlight code *,
.course-page-block .code-lab .code-lab__editor-highlight code * {
    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;

    font-family: "JetBrains Mono", monospace !important;
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    line-height: 1.55 !important;

    font-variant-ligatures: none;
    font-feature-settings: "liga" 0;
}
