/**
 * コードブロック専用スタイル（修正版）
 * 適切なセレクタで限定的に適用
 */

/* コードブロック（記事内のpre > codeのみ対象） */
.entry-content pre.wp-block-code,
.entry-content pre[class*="language-"],
.entry-content .code-wrap pre {
    background: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #333;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    padding: 1.5em;
    overflow-x: auto;
}

/* コードブロック内のcode要素 */
.entry-content pre.wp-block-code > code,
.entry-content pre[class*="language-"] > code,
.entry-content .code-wrap pre > code {
    background: transparent;
    color: #d4d4d4;
    padding: 0;
    display: block;
    line-height: 1.6;
}

/* インラインコード（文章中の`code`） */
.entry-content > p > code,
.entry-content > li > code,
.entry-content > blockquote > code {
    background: #2d2d2d;
    color: #7ec699;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    border: 1px solid #444;
    font-size: 0.9em;
}

/* シンタックスハイライト用（Prism.js対応） */
.entry-content code[class*="language-"] .token.string {
    color: #ce9178;
}

.entry-content code[class*="language-"] .token.keyword {
    color: #569cd6;
}

.entry-content code[class*="language-"] .token.comment {
    color: #6a9955;
    font-style: italic;
}

.entry-content code[class*="language-"] .token.number {
    color: #b5cea8;
}

.entry-content code[class*="language-"] .token.function {
    color: #dcdcaa;
}

/* Cocoonのコピーボタン対応 */
.entry-content .code-copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s;
}

.entry-content pre:hover .code-copy-button {
    opacity: 1;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .entry-content pre.wp-block-code,
    .entry-content pre[class*="language-"] {
        font-size: 14px;
        padding: 1em;
    }
}

/* 目次など他の要素に影響しないよう除外 */
.toc code,
.toc pre,
.widget code,
.widget pre,
.menu code,
.menu pre {
    /* これらの要素はスタイルを適用しない */
    background: initial;
    color: initial;
}