@charset "utf-8";
/* CSS Document */


/*
Template: deer
Theme Name:deer_child
Theme URI:https://fanfare-co-ltd.com/deer/
Description:WordPressテーマ『deer』の子テーマです
Author:JUNICHI
Version:1.0.0
*/ 

/*コードを追加する場合はこの下からお願いします↓*/

// ============================================
// 住医やたべ カスタム関数（子テーマ用）
// ============================================

// Noto Sans JP をサイト全体で読み込む
add_action( 'wp_enqueue_scripts', 'juuiyatabe_enqueue_fonts' );
function juuiyatabe_enqueue_fonts() {
    wp_enqueue_style(
        'noto-sans-jp',
        'https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap',
        array(),
        null
    );
}

// ヘッダーにフリーダイヤルCSSを挿入
add_action( 'wp_head', 'juuiyatabe_header_phone_css' );
function juuiyatabe_header_phone_css() {
    echo '<style>
    .wp-block-columns.is-layout-flex .wp-block-column { display: flex !important; flex-direction: column !important; }
    .wp-block-columns.is-layout-flex .wp-block-column figure.wp-block-image { flex: 1; margin: 0; }
    .wp-block-columns.is-layout-flex .wp-block-column figure.wp-block-image img { width: 100%; height: 100%; min-height: 220px; object-fit: cover; border-radius: 4px; display: block; }
    .wp-block-columns.is-layout-flex .wp-block-column > div[style*="background"] { flex: 1; min-height: 220px !important; }
    .jy-header-phone, .jy-header-phone a, .jy-header-phone .jy-phone-number, .jy-header-phone .jy-phone-label { font-family: "Noto Sans JP", sans-serif !important; }
    #logo, #change-logo { display: flex; align-items: center; }
    .jy-header-phone { display: flex; align-items: center; gap: 6px; margin-left: 20px; }
    .jy-header-phone a { display: flex; align-items: center; gap: 6px; text-decoration: none; color: #2e7d32; font-weight: 700; font-size: 1.25rem; line-height: 1; white-space: nowrap; }
    .jy-header-phone a:hover { opacity: 0.75; }
    .jy-header-phone .jy-phone-icon { width: 20px; height: 20px; fill: #2e7d32; flex-shrink: 0; }
    .jy-header-phone .jy-phone-label { font-size: 0.65rem; font-weight: 400; color: #555; display: block; line-height: 1; margin-bottom: 2px; }
    .jy-header-phone .jy-phone-number { display: block; font-size: 1.25rem; font-weight: 700; color: #2e7d32; line-height: 1; }
    @media (max-width: 768px) {
        .jy-header-phone a { font-size: 1rem; }
        .jy-header-phone .jy-phone-number { font-size: 1rem; }
        .jy-header-phone .jy-phone-label { display: none; }
    }
    </style>';
}

// ヘッダーのロゴ直後に電話番号をJS挿入
add_action( 'wp_footer', 'juuiyatabe_inject_phone_js' );
function juuiyatabe_inject_phone_js() {
    echo '<script>
    document.addEventListener("DOMContentLoaded", function () {
        var targets = [
            document.querySelector("#logo p.sitename"),
            document.querySelector("#change-logo p.change-sitename")
        ];
        targets.forEach(function(logo) {
            if (!logo) return;
            var phoneHtml = "<div class=\"jy-header-phone\">"
            + "<a href=\"tel:0120741880\">"
            + "<svg class=\"jy-phone-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">"
            + "<path d=\"M6.62 10.79a15.053 15.053 0 006.59 6.59l2.2-2.2a1 1 0 011.01-.24c1.12.37 2.33.57 3.58.57a1 1 0 011 1V20a1 1 0 01-1 1C10.61 21 3 13.39 3 4a1 1 0 011-1h3.5a1 1 0 011 1c0 1.25.2 2.46.57 3.58a1 1 0 01-.24 1.01l-2.21 2.2z\"/>"
            + "</svg>"
            + "<span><span class=\"jy-phone-label\">フリーダイヤル（8:00〜19:00）</span>"
            + "<span class=\"jy-phone-number\">0120-7-41880</span></span>"
            + "</a>"
            + "</div>";
            logo.insertAdjacentHTML("afterend", phoneHtml);
        });
    });
    </script>';
}
