/*
 * Code: a dark panel with one or more tabs. Without script the panels stack,
 * each under its own title; the script adds the tab bar (`code--tabs`).
 */

.code {
    position: relative;
    margin: 0 0 28px;
    border-radius: 16px;
    background: var(--ink);
    color: #e9e7e2;
    overflow: hidden;
}

.code__caption {
    padding: 14px 22px 0;
    font-size: 13px;
    color: #8e8b96;
}

.code__body {
    margin: 0;
    padding: 20px 22px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.75;
    tab-size: 2;
}

.code__caption + .code__body {
    padding-top: 10px;
}

.code__panel + .code__panel {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.code__tablist {
    display: flex;
    gap: 4px;
    padding: 8px 14px 0;
    overflow-x: auto;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code__tab {
    flex: none;
    padding: 8px 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #8e8b96;
    transition: color 0.15s, border-color 0.15s;
}

.code__tab:hover {
    color: #e9e7e2;
}

.code__tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.code__tab--active {
    border-bottom-color: #a99dff;
    color: #fff;
}

/* With tabs the titles are the tab labels, so the panels drop their own. */
.code--tabs .code__caption {
    display: none;
}

.code--tabs .code__panel + .code__panel {
    border-top: 0;
}

.code--tabs .code__body {
    padding-top: 20px;
}

.code__copy {
    position: absolute;
    top: 8px;
    right: 10px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    font-size: 12px;
    color: #c9c6d0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.code__copy:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.code__copy:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.code__copy--done {
    border-color: rgba(134, 224, 183, 0.5);
    color: #86e0b7;
}

/* Keep the first line and the tab bar clear of the button. */
.code--copy .code__body,
.code--copy .code__tablist {
    padding-right: 84px;
}

@media (max-width: 767px) {
    .code__body { font-size: 12.5px; }
}
