/*
 * SZ Code Block — Frontend & Editor CSS
 * Matches TechNews child theme premium code block style
 */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ================================================================
   Code Block Outer Wrapper
   ================================================================ */
.tn-code-block-wrap,
.sz-code-block {
    margin: 20px 0;
    border-radius: 10px;
    background: #090d16;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px -4px rgba(2, 6, 23, 0.45), 0 0 0 1px rgba(255,255,255,0.04);
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
    max-width: 100%;
    box-sizing: border-box;
}

.tn-code-block-wrap:hover,
.sz-code-block:hover {
    box-shadow: 0 12px 32px -4px rgba(2,6,23,0.6), 0 0 0 1px rgba(37,99,235,0.28);
    border-color: rgba(96,165,250,0.22);
}

/* Top gradient accent */
.tn-code-block-wrap::before,
.sz-code-block::before {
    content: '';
    display: block;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6 0%, #06b6d4 35%, #8b5cf6 70%, #ec4899 100%);
    width: 100%;
}

/* ================================================================
   Header bar (macOS style)
   ================================================================ */
.tn-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #151d2a 0%, #0f1521 100%);
    padding: 5px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    user-select: none;
    gap: 8px;
    min-height: 30px;
    box-sizing: border-box;
}

/* Traffic light dots */
.tn-code-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.tn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.3);
    transition: transform 0.15s;
}
.tn-code-dots:hover .tn-dot { transform: scale(1.12); }
.tn-dot.red    { background: #ff5f56; border: 1px solid #e0443e; }
.tn-dot.yellow { background: #ffbd2e; border: 1px solid #dea123; }
.tn-dot.green  { background: #27c93f; border: 1px solid #1aab29; }

/* Language label badge */
.tn-code-label {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 10.5px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 2px 8px;
    border-radius: 12px;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    flex: 1;
}

/* Copy button */
.tn-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(37, 99, 235, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(37,99,235,0.3);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    outline: none;
    line-height: 1.5;
}

.tn-copy-btn:hover {
    background: rgba(37,99,235,0.3);
    border-color: rgba(37,99,235,0.6);
    color: #bfdbfe;
}

.tn-copy-btn.copied {
    background: rgba(5, 150, 105, 0.2);
    border-color: rgba(5, 150, 105, 0.45);
    color: #6ee7b7;
}

/* ================================================================
   Code content area
   ================================================================ */
.tn-code-pre,
.sz-code-block pre {
    margin: 0;
    padding: 18px 20px;
    background: #090d16;
    color: #cbd5e1;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, Monaco, monospace;
    font-size: 13.5px;
    line-height: 1.75;
    overflow-x: auto;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    tab-size: 4;
    scrollbar-width: thin;
    scrollbar-color: #2d3748 #090d16;
    max-width: 100%;
    box-sizing: border-box;
}

.tn-code-pre::-webkit-scrollbar,
.sz-code-block pre::-webkit-scrollbar { height: 5px; }
.tn-code-pre::-webkit-scrollbar-track,
.sz-code-block pre::-webkit-scrollbar-track { background: #0f1521; border-radius: 4px; }
.tn-code-pre::-webkit-scrollbar-thumb,
.sz-code-block pre::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.tn-code-pre::-webkit-scrollbar-thumb:hover,
.sz-code-block pre::-webkit-scrollbar-thumb:hover { background: #475569; }

.tn-code-pre code,
.sz-code-block pre code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: inherit !important;
    font-family: inherit !important;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
    display: block;
}

/* ================================================================
   Basic syntax color hints (no extra library needed)
   ================================================================ */
.sz-code-block pre .kw  { color: #c084fc; }   /* keyword */
.sz-code-block pre .st  { color: #86efac; }   /* string */
.sz-code-block pre .cm  { color: #64748b; font-style: italic; }  /* comment */
.sz-code-block pre .nm  { color: #67e8f9; }   /* number */
.sz-code-block pre .fn  { color: #60a5fa; }   /* function */
.sz-code-block pre .op  { color: #f9a8d4; }   /* operator */

/* ================================================================
   Mobile responsive
   ================================================================ */
@media (max-width: 640px) {
    .tn-code-pre,
    .sz-code-block pre {
        font-size: 12px;
        padding: 14px 12px;
    }
    .tn-code-label { max-width: 100px; font-size: 9.5px; }
    .tn-copy-btn span { display: none; }
    .tn-copy-btn { padding: 3px 7px; }
}
