/**
 * Nexfolio Code Block - Frontend Styles
 *
 * Catppuccin Mocha inspired color scheme
 *
 * @package Nexfolio
 * @since 1.5.0
 */

/* Google Fonts - JetBrains Mono */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==================================
   CODE BLOCK CONTAINER
   ================================== */

.nexfolio-code-block {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', monospace !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background: #1e1e2e !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
    margin: 2rem 0 !important;
}

/* 테마 스타일 오버라이드 */
.entry-content .nexfolio-code-block,
.post-content .nexfolio-code-block,
article .nexfolio-code-block {
    background: #1e1e2e !important;
}

/* ==================================
   HEADER
   ================================== */

.nexfolio-code-block__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #181825 !important;
    border-bottom: 1px solid #313244 !important;
}

/* Mac-style dots */
.nexfolio-code-block__dots {
    display: flex;
    gap: 8px;
}

.nexfolio-code-block__dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.nexfolio-code-block__dots .dot:nth-child(1) {
    background: #f38ba8;
}

.nexfolio-code-block__dots .dot:nth-child(2) {
    background: #f9e2af;
}

.nexfolio-code-block__dots .dot:nth-child(3) {
    background: #a6e3a1;
}

/* File info */
.nexfolio-code-block__info {
    flex: 1;
    text-align: center;
}

.nexfolio-code-block__filename {
    color: #cdd6f4;
    font-size: 13px;
    font-weight: 500;
}

.nexfolio-code-block__language {
    display: inline-block;
    padding: 3px 12px;
    background: #313244;
    color: #89b4fa;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Copy button */
.nexfolio-code-block__copy {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #313244;
    border: none;
    border-radius: 6px;
    color: #a6adc8;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nexfolio-code-block__copy:hover {
    background: #45475a;
    color: #cdd6f4;
}

.nexfolio-code-block__copy.copied {
    background: #a6e3a1;
    color: #1e1e2e;
}

.nexfolio-code-block__copy svg {
    width: 14px;
    height: 14px;
}

/* ==================================
   CODE BODY
   ================================== */

.nexfolio-code-block__body {
    display: flex;
    overflow-x: auto;
}

/* Line numbers */
.nexfolio-code-block__lines {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    background: #181825 !important;
    border-right: 1px solid #313244 !important;
    user-select: none;
    flex-shrink: 0;
}

.nexfolio-code-block__lines .line-number {
    display: block;
    padding: 0 16px;
    color: #6c7086;
    font-size: 14px;
    line-height: 1.7;
    text-align: right;
    min-width: 50px;
}

.nexfolio-code-block__lines .line-number.highlighted {
    background: rgba(137, 180, 250, 0.1);
    color: #89b4fa;
}

/* Code content */
.nexfolio-code-block__pre {
    margin: 0 !important;
    padding: 16px 20px !important;
    overflow-x: auto;
    flex: 1;
    background: #1e1e2e !important;
    border: none !important;
}

.nexfolio-code-block__code {
    display: block;
    color: #cdd6f4 !important;
    font-size: 14px !important;
    line-height: 1.7 !important;
    white-space: pre;
    tab-size: 4;
    background: transparent !important;
    padding: 0 !important;
}

.nexfolio-code-block__code span {
    display: block;
}

.nexfolio-code-block__code .line-highlight {
    background: rgba(137, 180, 250, 0.1);
    margin: 0 -20px;
    padding: 0 20px;
    border-left: 3px solid #89b4fa;
}

/* ==================================
   SYNTAX HIGHLIGHTING (Basic)
   ================================== */

/* Comments */
.nexfolio-code-block__code .comment,
.nexfolio-code-block__code .hljs-comment {
    color: #6c7086;
    font-style: italic;
}

/* Strings */
.nexfolio-code-block__code .string,
.nexfolio-code-block__code .hljs-string {
    color: #a6e3a1;
}

/* Keywords */
.nexfolio-code-block__code .keyword,
.nexfolio-code-block__code .hljs-keyword {
    color: #cba6f7;
}

/* Functions */
.nexfolio-code-block__code .function,
.nexfolio-code-block__code .hljs-function {
    color: #89b4fa;
}

/* Numbers */
.nexfolio-code-block__code .number,
.nexfolio-code-block__code .hljs-number {
    color: #fab387;
}

/* ==================================
   SCROLLBAR
   ================================== */

.nexfolio-code-block__body::-webkit-scrollbar,
.nexfolio-code-block__pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.nexfolio-code-block__body::-webkit-scrollbar-track,
.nexfolio-code-block__pre::-webkit-scrollbar-track {
    background: #181825;
}

.nexfolio-code-block__body::-webkit-scrollbar-thumb,
.nexfolio-code-block__pre::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}

.nexfolio-code-block__body::-webkit-scrollbar-thumb:hover,
.nexfolio-code-block__pre::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}

/* ==================================
   RESPONSIVE
   ================================== */

@media (max-width: 768px) {
    .nexfolio-code-block {
        border-radius: 8px;
        margin: 1.5rem -1rem;
    }

    .nexfolio-code-block__header {
        padding: 10px 12px;
    }

    .nexfolio-code-block__dots .dot {
        width: 10px;
        height: 10px;
    }

    .nexfolio-code-block__copy .copy-text {
        display: none;
    }

    .nexfolio-code-block__lines .line-number {
        padding: 0 10px;
        font-size: 12px;
        min-width: 35px;
    }

    .nexfolio-code-block__pre {
        padding: 12px 14px;
    }

    .nexfolio-code-block__code {
        font-size: 13px;
    }
}

/* ==================================
   PRINT STYLES
   ================================== */

@media print {
    .nexfolio-code-block {
        background: #f4f4f5 !important;
        box-shadow: none !important;
        border: 1px solid #e4e4e7;
    }

    .nexfolio-code-block__header {
        background: #e4e4e7 !important;
    }

    .nexfolio-code-block__code {
        color: #18181b !important;
    }

    .nexfolio-code-block__copy {
        display: none !important;
    }
}

/* ==================================
   WORDPRESS DEFAULT CODE BLOCKS
   기존 <pre><code> 태그에도 스타일 적용
   ================================== */

/* 워드프레스 기본 코드 블록 */
.entry-content pre:has(code),
.post-content pre:has(code),
article pre:has(code),
.wp-block-code {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', monospace !important;
    background: #1e1e2e !important;
    color: #cdd6f4 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    margin: 2rem 0 !important;
    overflow-x: auto !important;
    font-size: 14px !important;
    line-height: 1.7 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
    border: none !important;
}

.entry-content pre code,
.post-content pre code,
article pre code,
.wp-block-code code {
    font-family: inherit !important;
    background: transparent !important;
    color: #cdd6f4 !important;
    padding: 0 !important;
    font-size: inherit !important;
    line-height: inherit !important;
    white-space: pre !important;
    border: none !important;
    border-radius: 0 !important;
}

/* 인라인 코드 */
.entry-content code:not(pre code),
.post-content code:not(pre code),
article code:not(pre code) {
    font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
    background: #313244 !important;
    color: #f38ba8 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    font-size: 0.9em !important;
}

/* 스크롤바 */
.entry-content pre:has(code)::-webkit-scrollbar,
.post-content pre:has(code)::-webkit-scrollbar,
article pre:has(code)::-webkit-scrollbar,
.wp-block-code::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.entry-content pre:has(code)::-webkit-scrollbar-track,
.post-content pre:has(code)::-webkit-scrollbar-track,
article pre:has(code)::-webkit-scrollbar-track,
.wp-block-code::-webkit-scrollbar-track {
    background: #181825;
    border-radius: 4px;
}

.entry-content pre:has(code)::-webkit-scrollbar-thumb,
.post-content pre:has(code)::-webkit-scrollbar-thumb,
article pre:has(code)::-webkit-scrollbar-thumb,
.wp-block-code::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}

.entry-content pre:has(code)::-webkit-scrollbar-thumb:hover,
.post-content pre:has(code)::-webkit-scrollbar-thumb:hover,
article pre:has(code)::-webkit-scrollbar-thumb:hover,
.wp-block-code::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}
