/* PrismJS - Custom Dark Theme for Ghost Blog
 * Based on One Dark theme with custom modifications
 * ---------------------------------------------------------- */

/* Code blocks */
code[class*="language-"],
pre[class*="language-"] {
    color: #abb2bf;
    background: none;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 1.6rem;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.6;
    tab-size: 4;
    hyphens: none;
}

/* Code blocks styling */
pre[class*="language-"] {
    padding: 1.5rem;
    margin: 2rem 0;
    overflow: auto;
    border-radius: 8px;
    background: #282c34;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    position: relative;
}

/* Custom code block structure - pre connects seamlessly with header */
.custom-code-block > pre[class*="language-"] {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    white-space: normal;
    background: #282c34;
    color: #abb2bf;
}

/* Selection */
pre[class*="language-"]::-moz-selection,
pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection {
    text-shadow: none;
    background: #3e4451;
}

pre[class*="language-"]::selection,
pre[class*="language-"] ::selection,
code[class*="language-"]::selection,
code[class*="language-"] ::selection {
    text-shadow: none;
    background: #3e4451;
}

/* Tokens */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #5c6370;
    font-style: italic;
}

.token.punctuation {
    color: #abb2bf;
}

.token.namespace {
    opacity: 0.7;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
    color: #e06c75;
}

.token.boolean,
.token.number {
    color: #d19a66;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #98c379;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
    color: #56b6c2;
}

.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
    color: #e6c07b;
}

.token.keyword {
    color: #c678dd;
}

.token.regex,
.token.important {
    color: #e06c75;
}

.token.important,
.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

.token.entity {
    cursor: help;
}

/* Custom Code Block Structure - Permanent Header Bar */
.custom-code-block {
    position: relative;
    margin: 2rem 0;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Header Bar - Always visible, sits above code */
.custom-code-block .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #3e4451;
    padding: 8px 12px;
    border-bottom: 1px solid #2d3748;
    font-size: 12px;
    min-height: 48px;
}

/* Language Label (LEFT SIDE) - text element in dark pill */
.custom-code-block .code-header .language-label {
    background: #4a5568;
    color: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Copy Button (RIGHT SIDE) - icon only */
.custom-code-block .code-header .copy-code-btn {
    background: transparent url('../icons/file_copy_34dp_000000_FILL0_wght400_GRAD0_opsz40.svg') no-repeat center;
    background-size: 16px 16px;
    border: 1px solid #4a5568;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    filter: brightness(0) saturate(100%) invert(67%) sepia(8%) saturate(1268%) hue-rotate(180deg) brightness(96%) contrast(88%);
    flex-shrink: 0;
}

.custom-code-block .code-header .copy-code-btn:hover,
.custom-code-block .code-header .copy-code-btn:focus {
    background-color: #4a5568;
    background-image: url('../icons/file_copy_34dp_000000_FILL0_wght400_GRAD0_opsz40.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
    border-color: #5a6578;
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(93deg) brightness(103%) contrast(103%);
    outline: none;
}

/* Copy success state */
.custom-code-block .code-header .copy-code-btn.copy-success {
    background-color: #48bb78;
    border-color: #48bb78;
    filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(93deg) brightness(103%) contrast(103%);
}



/* Line numbers plugin */
pre[class*="language-"].line-numbers {
    position: relative;
    padding-left: 3.8em;
    counter-reset: linenumber;
}

pre[class*="language-"].line-numbers > code {
    position: relative;
    white-space: inherit;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #3e4451;
    user-select: none;
}

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

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #5c6370;
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* Scrollbar styling for code blocks */
pre[class*="language-"]::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

pre[class*="language-"]::-webkit-scrollbar-track {
    background: #1e2127;
    border-radius: 5px;
}

pre[class*="language-"]::-webkit-scrollbar-thumb {
    background: #3e4451;
    border-radius: 5px;
}

pre[class*="language-"]::-webkit-scrollbar-thumb:hover {
    background: #4b5263;
}

/* Mobile responsive */
@media (max-width: 768px) {
    code[class*="language-"],
    pre[class*="language-"] {
        font-size: 1.4rem;
    }
    
    pre[class*="language-"] {
        padding: 1rem;
    }
    
    .custom-code-block .code-header {
        padding: 6px 8px;
        font-size: 11px;
        min-height: 40px;
    }
    
    .custom-code-block .code-header .language-label {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .custom-code-block .code-header .copy-code-btn {
        width: 28px;
        height: 28px;
        background-size: 14px 14px;
    }
}

/* Tablet responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .custom-code-block .code-header {
        padding: 7px 10px;
    }
    
    .custom-code-block .code-header .copy-code-btn {
        width: 30px;
        height: 30px;
        background-size: 15px 15px;
    }
}

/* Override Ghost defaults cleanly */
.gh-content pre[class*="language-"],
.gh-canvas pre[class*="language-"] {
    background: #282c34;
    border: none;
    font-size: 1.6rem;
}

.gh-content code[class*="language-"],
.gh-canvas code[class*="language-"] {
    background: #282c34;
    color: #abb2bf;
    border: none;
}

/* Animation for copy feedback */
@keyframes copySuccess {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

div.code-toolbar > .toolbar > .toolbar-item > button.copy-success {
    animation: copySuccess 0.3s ease;
}