/* Code card ({{< code >}}) — radii aligned to --radius-code-card in DOC-1324.

   NOTE for phase 4: this component cannot fully match Figma's Code Card yet.
   Figma's card sits on --code/code-bg, but `chroma.css` still hardcodes
   Monokai's #272822 on `.chroma`, which wins over the `pre` background. So the
   surface users actually see is Monokai's, not our --code-surface (#16181d).
   The phase-2 token spec recorded chroma as "fully replaceable, 60 literals ->
   7 tokens"; that work is scheduled for phase 4 and is the blocker for the last
   step of Code Card fidelity. Radius and border are token-driven now; the
   background follows when chroma does. */

.codeblock {
    position: relative;
    border-radius: var(--radius-code-card);
    overflow: hidden;
}

/* Copy button for regular markdown code blocks */
.codeblock > .copy {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    color: var(--pre-color); /* Theme-aware color */
    z-index: 10;
}

.codeblock-header {
    background: var(--code-chrome-bg); /* Slightly lighter than code bg for subtle separation */
    color: var(--code-chrome-text); /* Light gray for good readability */
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--type-code);
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Subtle separator line */
}

.codeblock-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Copy button inside header for shortcode code blocks */
.codeblock-header .copy {
    position: static;
    color: var(--pre-color);
}

/* DOC-1095: the "copy entire file" button sits beside the fragment copy
   button in the header actions. Render it as a secondary affordance. */
.codeblock-header .copy-all {
    opacity: 0.75;
    transition: opacity 0.2s;
}

.codeblock-header .copy-all:hover {
    opacity: 1;
}

.codeblock-filename {
    font-family: var(--font-mono);
    font-weight: 500;
    color: inherit;
}

.codeblock-github-link {
    color: var(--pre-color);
    opacity: 0.7;
    transition: opacity 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.codeblock-github-link:hover {
    opacity: 1;
}

/* Ensure the code block integrates seamlessly */
.codeblock .code {
    border-radius: 0 0 var(--radius-code-card) var(--radius-code-card); /* header is square-bottomed above it */
    margin: 0;
}

.codeblock .code pre {
    border-radius: 0 0 var(--radius-code-card) var(--radius-code-card); /* header is square-bottomed above it */
    margin: 0;
}

.highlight a {
    color: var(--code-link);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.3) !important;
    text-underline-offset: 2px;
}
.highlight a:hover {
    text-decoration-color: rgba(255, 255, 255, 0.8) !important;
}

A > CODE {
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(0, 0, 0, 0.3);
}

/* Minimal protection: Prevent extensions from adding interactive styles */
/* Don't override colors/backgrounds - preserve Hugo's inline styles */
.codeblock .code [onclick] {
    pointer-events: none !important;
    cursor: text !important;
}

/* Prevent extension-added visual decorations without affecting colors */
.codeblock .code [data-1p]:not([data-1p-ignore]),
.codeblock .code [data-bw]:not([data-bwignore]),
.codeblock .code [data-lastpass]:not([data-lastpass-ignore]) {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
}