/*!
 * Rhino Code Snippet block — front-end styling.
 * Light grey surface, NodeMaven palette syntax tokens.
 * @author Salama Malek
 */

.rhino-code-snippet {
    position: relative;
    margin: 1.75rem 0;
    padding: 1.25rem 1.25rem 1.25rem 3.25rem;
    background: var(--gray-cool-50, #f5f6f6);
    color: var(--gray-900, #333);
    border: 1px solid var(--gray-cool-200, #e5e7e8);
    border-radius: 14px;
    box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.6) inset,
                0 6px 18px -12px rgba(31, 41, 55, 0.18);
    overflow: hidden;
}

/* Signature NM blue→green accent bar across the top. */
.rhino-code-snippet::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(
        --gradient-brand-500-green-400-45-deg,
        linear-gradient(90deg, rgba(74, 136, 238, 0.95), rgba(35, 230, 168, 0.95))
    );
    opacity: 1;
}

.rhino-code-snippet pre[class*="language-"],
.rhino-code-snippet pre.line-numbers {
    margin: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.875rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre;
    text-shadow: none;
    tab-size: 4;
    letter-spacing: 0;
}

.rhino-code-snippet code[class*="language-"] {
    background: transparent;
    color: inherit;
    text-shadow: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-style: inherit;
    line-height: inherit;
}

/*
 * Defensive scope: theme article-content typography (h1-h6, strong, b, em, i)
 * has no Gutenberg-block exclusion selector, so it bleeds into Prism's
 * <span class="token ..."> children. Pin every descendant's typography here.
 * Italics only come back via the explicit .token.comment rule below.
 */
.rhino-code-snippet pre *,
.rhino-code-snippet code * {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-style: normal;
    line-height: inherit;
    letter-spacing: inherit;
    text-transform: none;
    margin: 0;
    padding: 0;
}

/* Line numbers gutter. */
.rhino-code-snippet pre.line-numbers {
    position: relative;
    padding-left: 0;
    counter-reset: linenumber;
}

.rhino-code-snippet pre.line-numbers > code {
    position: relative;
    white-space: inherit;
}

.rhino-code-snippet .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -2.5rem;
    width: 2rem;
    letter-spacing: -1px;
    user-select: none;
    border-right: 1px solid var(--gray-cool-200, #e5e7e8);
}

.rhino-code-snippet .line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.rhino-code-snippet .line-numbers-rows > span::before {
    content: counter(linenumber);
    color: var(--gray-cool-400, #82878e);
    display: block;
    padding-right: 0.5rem;
    text-align: right;
}

/*
 * Token palette: darker shades of NM tokens for readability on the light surface.
 * All AA contrast against gray-cool-50.
 */
.rhino-code-snippet pre .token.comment,
.rhino-code-snippet pre .token.prolog,
.rhino-code-snippet pre .token.doctype,
.rhino-code-snippet pre .token.cdata {
    color: var(--gray-cool-500, #676c73);
    font-style: italic;
}

.rhino-code-snippet .token.punctuation {
    color: var(--gray-700, #4f4f4f);
}

.rhino-code-snippet .token.keyword,
.rhino-code-snippet .token.operator,
.rhino-code-snippet .token.atrule,
.rhino-code-snippet .token.important {
    color: var(--brand-700, #1c55b3);
    font-weight: 600;
}

.rhino-code-snippet .token.string,
.rhino-code-snippet .token.char,
.rhino-code-snippet .token.attr-value,
.rhino-code-snippet .token.inserted {
    color: var(--green-700, #008663);
}

.rhino-code-snippet .token.number,
.rhino-code-snippet .token.boolean,
.rhino-code-snippet .token.regex {
    color: var(--orange-700, #b93815);
}

.rhino-code-snippet .token.function,
.rhino-code-snippet .token.class-name,
.rhino-code-snippet .token.selector {
    color: var(--purple-700, #4a3bc7);
}

.rhino-code-snippet .token.variable,
.rhino-code-snippet .token.attr-name,
.rhino-code-snippet .token.property,
.rhino-code-snippet .token.url,
.rhino-code-snippet .token.entity {
    color: var(--teal-700, #1d6668);
}

.rhino-code-snippet .token.tag,
.rhino-code-snippet .token.symbol,
.rhino-code-snippet .token.constant,
.rhino-code-snippet .token.builtin,
.rhino-code-snippet .token.deleted {
    color: var(--rose-700, #c01048);
}

.rhino-code-snippet .token.bold { font-weight: 700; }
.rhino-code-snippet .token.italic { font-style: italic; }

/* Copy button. */
.rhino-code-snippet__copy {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--gray-cool-200, #e5e7e8);
    border-radius: 8px;
    color: var(--gray-700, #4f4f4f);
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 2px rgba(31, 41, 55, 0.06);
    -webkit-tap-highlight-color: transparent;
    appearance: none;
    font: inherit;
    line-height: 1;
}

.rhino-code-snippet__copy:hover {
    background: var(--brand-50, #f0f6fe);
    border-color: var(--brand-500, #4a88ee);
    color: var(--brand-700, #1c55b3);
    box-shadow: 0 2px 6px rgba(74, 136, 238, 0.18);
}

.rhino-code-snippet__copy:focus-visible {
    outline: 2px solid var(--brand-500, #4a88ee);
    outline-offset: 2px;
}

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

.rhino-code-snippet__copy svg {
    width: 1rem;
    height: 1rem;
    pointer-events: none;
}

.rhino-code-snippet__copy .rhino-code-snippet__icon-check { display: none; }

.rhino-code-snippet.is-copied .rhino-code-snippet__copy {
    color: var(--green-700, #008663);
    background: var(--green-50, #eafff6);
    border-color: var(--green-400, #23e6a8);
}

.rhino-code-snippet.is-copied .rhino-code-snippet__copy .rhino-code-snippet__icon-copy { display: none; }
.rhino-code-snippet.is-copied .rhino-code-snippet__copy .rhino-code-snippet__icon-check { display: inline-block; }

/* Visually-hidden live region for screen readers. */
.rhino-code-snippet__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 768px) {
    .rhino-code-snippet {
        padding-left: 2.75rem;
        margin: 1.25rem 0;
        border-radius: 12px;
    }
    .rhino-code-snippet .line-numbers-rows {
        left: -2rem;
    }
    .rhino-code-snippet__copy {
        width: 1.875rem;
        height: 1.875rem;
    }
}
