/* Code and CKEditor content: product pages, instructions, editor. */

.ck-content pre,
.ck.ck-editor__editable pre,
.ckeditor-content pre,
.product-description pre {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #0f172a;
    border-radius: 8px;
    padding: 16px 18px;
    margin: 16px 0;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    tab-size: 4;
}

.ck-content pre code,
.ck.ck-editor__editable pre code,
.ckeditor-content pre code,
.product-description pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    font-family: inherit;
}

.ck-content code,
.ckeditor-content code,
.product-description code {
    background: rgba(232, 62, 140, 0.08);
    color: #e83e8c;
    padding: 0.15em 0.45em;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9em;
}

.ck.ck-editor__editable pre[data-language]::after {
    background: #334155;
    color: #cbd5e1;
    border-radius: 0 8px 0 6px;
    font-size: 11px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Article covers: reserved ratio, moderate hero height, no layout shift. */
.article-cover {
    margin: 0 0 1rem;
}

.article-cover--card {
    margin: 0;
}

.article-cover-frame {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #e2e8f0;
}

.article-cover--hero .article-cover-frame {
    aspect-ratio: 4 / 3;
    max-height: min(70vh, 520px);
    border-radius: 10px;
}

.article-cover--card .article-cover-frame {
    aspect-ratio: 4 / 3;
}

.article-cover-frame img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--cover-position, center);
    display: block;
}

.article-cover-caption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
}

.card > .article-cover--card .article-cover-frame {
    border-top-left-radius: calc(0.25rem - 1px);
    border-top-right-radius: calc(0.25rem - 1px);
}

@media (min-width: 768px) {
    .article-cover--hero .article-cover-frame,
    .article-cover--card .article-cover-frame {
        aspect-ratio: 16 / 9;
    }
}

@media (min-width: 992px) {
    .article-cover--hero .article-cover-frame {
        aspect-ratio: 2 / 1;
        max-height: 480px;
    }
}

.instruction-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.instruction-header h2 {
    margin-bottom: 0.75rem;
}

.instruction-description {
    margin: 0 0 0.5rem;
}

.instruction-toc {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    order: 2;
}

.instruction-header {
    order: 1;
}

.instruction-article {
    order: 3;
    min-width: 0;
}

.instruction-toc[hidden] {
    display: none;
}

.instruction-toc-panel {
    margin: 0;
}

.instruction-toc-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #0f172a;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.instruction-toc-title::-webkit-details-marker {
    display: none;
}

.instruction-toc-title::marker {
    content: '';
}

.instruction-toc-title::after {
    content: '';
    width: 0.45em;
    height: 0.45em;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.instruction-toc-panel[open] > .instruction-toc-title::after {
    transform: rotate(-135deg);
    margin-top: 0.35em;
}

.instruction-toc-list {
    margin-top: 10px;
}

.instruction-toc-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.instruction-toc-list li {
    margin: 0.35rem 0;
}

.instruction-toc-list li > ul {
    padding-left: 1.1rem;
    margin-top: 0.2rem;
}

.instruction-toc-list a {
    color: #334155;
    text-decoration: none;
    border-bottom: 1px dashed #cbd5e1;
    overflow-wrap: anywhere;
}

.instruction-toc-list a:hover,
.instruction-toc-list a:focus {
    color: #0f172a;
    border-bottom-color: #0f172a;
}

.ckeditor-content h1,
.ckeditor-content h2,
.ckeditor-content h3,
.ckeditor-content h4,
.ckeditor-content h5,
.ckeditor-content h6 {
    scroll-margin-top: 24px;
}

@media (min-width: 768px) {
    .instruction-layout.has-toc {
        display: grid;
        grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
        grid-template-areas:
            "toc header"
            "toc article";
        gap: 24px 32px;
        align-items: start;
    }

    .instruction-layout.has-toc .instruction-header,
    .instruction-layout.has-toc .instruction-toc,
    .instruction-layout.has-toc .instruction-article {
        order: initial;
    }

    .instruction-layout.has-toc .instruction-header {
        grid-area: header;
    }

    .instruction-layout.has-toc .instruction-toc {
        grid-area: toc;
        position: sticky;
        top: 16px;
        max-height: calc(100vh - 32px);
        overflow: auto;
        overscroll-behavior: contain;
        padding: 16px 18px;
        align-self: start;
    }

    .instruction-layout.has-toc .instruction-article {
        grid-area: article;
    }

    .instruction-toc-title {
        pointer-events: none;
        cursor: default;
    }

    .instruction-toc-title::after {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .instruction-toc-list {
        max-height: 50vh;
        overflow: auto;
        overscroll-behavior: contain;
    }
}
