/*
Theme Name: Lightning Child
Theme URI: 
Template: lightning
Description: 
Author: 
Tags: 
Version: 0.6.0
*/

// wp-content/themes/lightning-child/functions.php

<?php
// 既存のコードの下に追加

/**
 * 投稿ページの本文リンク色カスタマイズ
 * バージョン: 1.0
 */
function custom_post_content_link_styles() {
    // 投稿ページのみ適用
    if ( ! is_singular( 'post' ) ) {
        return;
    }
    ?>
    <style id="custom-post-link-style">
        /* CSS変数を上書き */
        .single-post .entry-content {
            --vk-color-text-link: #005AAB;
        }
        
        /* 本文内のリンクスタイル */
        body.single-post article .entry-content p > a,
        body.single-post article .entry-content li > a,
        body.single-post article .entry-content td > a,
        body.single-post article .entry-content dd > a,
        body.single-post article .entry-content blockquote > a {
            color: #005AAB !important;
            font-weight: 700 !important;
            text-decoration: underline !important;
            transition: all 0.3s ease;
        }
        
        /* ホバー時 */
        body.single-post article .entry-content p > a:hover,
        body.single-post article .entry-content li > a:hover,
        body.single-post article .entry-content td > a:hover {
            color: #003d7a !important;
            text-decoration: none !important;
        }
        
        /* ボタンブロックは除外 */
        body.single-post article .entry-content .wp-block-button__link,
        body.single-post article .entry-content .vk-button,
        body.single-post article .entry-content [class*="btn"] {
            color: inherit !important;
            font-weight: inherit !important;
            text-decoration: none !important;
        }
    </style>
    <?php
}
add_action( 'wp_head', 'custom_post_content_link_styles', 9999 );

/**
 * Autoptimizeから除外
 */
add_filter( 'autoptimize_filter_css_exclude', function( $exclude ) {
    return $exclude . ', custom-post-link-style';
});