@charset "UTF-8";

/*!
Theme Name: Cocoon Child
Description: Cocoon専用の子テーマ
Theme URI: https://wp-cocoon.com/
Author: わいひら
Author URI: https://nelog.jp/
Template:   cocoon-master
Version:    1.1.3
*/

/************************************
** 子テーマ用のスタイルを書く
************************************/
/*必要ならばここにコードを書く*/

/************************************
** レスポンシブデザイン用のメディアクエリ
************************************/
/*1023px以下*/
@media screen and (max-width: 1023px){
  /*必要ならばここにコードを書く*/
}

/*834px以下*/
@media screen and (max-width: 834px){
  /*必要ならばここにコードを書く*/
}

/*480px以下*/
@media screen and (max-width: 480px){
  /*必要ならばここにコードを書く*/
}
/* =========================================================
   汎用ページ（記事本文）内の見出しデザイン（h1〜h4）
   ベースの「Zen Maru Gothic」とテーマカラーに合わせた優しい丸みのある装飾
========================================================= */
/* =========================================================
   トラブル事例：新着記事一覧グリッド（カード型デザイン）
========================================================= */

/* 全体の枠組み（PCで横並び、スマホで縦並びを自動調整） */
/* 修正後（スマホで確実に収まるように） */
.custom-trouble-grid {
    display: grid;
    /* minmaxを小さくし、画面からはみ出さないように設定 */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
    gap: 16px; /* スマホ用に余白を少し詰める */
    margin-top: 20px;
    width: 100%;
    /* 強制的に画面幅に収める */
    max-width: 100vw; 
    overflow-x: hidden;
}

/* 記事カード1枚1枚のデザイン */
.custom-trouble-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    border: 1px solid #f0f0f0;
}

/* マウスホバー時の浮き上がり効果 */
.custom-trouble-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* サムネイル画像エリア（16:9比率） */
.custom-trouble-thumb {
    width: 100%;
    aspect-ratio: 16 / 9; 
    background: #f8fafc;
    position: relative;
    overflow: hidden;
}

.custom-trouble-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 0.5s ease;
}

/* マウスホバーで画像を少しズーム */
.custom-trouble-card:hover .custom-trouble-thumb img {
    transform: scale(1.05);
}

/* 画像がない場合のダミー表示 */
.custom-trouble-noimage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.9rem;
    position: absolute;
    font-weight: bold;
}

/* テキストエリア */
.custom-trouble-content {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 日付 */
.custom-trouble-date {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 8px;
}

/* タイトル（2行以上は...で省略） */
.custom-trouble-title {
    font-size: 1rem !important;
    font-weight: 700;
    color: #334155;
    line-height: 1.5;
    margin: 0 !important;
    padding: 0 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 記事がなかった場合のメッセージ */
.custom-trouble-nopost {
    text-align: center;
    width: 100%;
    color: #888;
}





/* =========================================================
   スマホ画面でコンテンツが左に縮むバグの修正
========================================================= */
@media screen and (max-width: 834px) {

    /* 1. 全体の土台（コンテナ）のグリッドを解除して幅100%に強制固定 */
    #container {
        display: block !important; /* PC用の grid 表示を解除して縦並びにする */
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden;
    }

    /* 2. メインコンテンツエリアの幅も100%にする */
    #main-content {
        width: 100% !important;
        max-width: 100% !important;
        padding-top: 100px !important; /* ヘッダーとの被り調整（お好みで） */
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 3. 背景画像のあるセクションと、中の白い箱を画面幅にフィットさせる */
    section.bg-greeting {
        width: 100% !important;
        padding-left: 10px !important;  /* スマホ画面の最外側のうっすらとした余白 */
        padding-right: 10px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 白い記事ブロック */
    .article-block {
        width: 100% !important;
        max-width: 100% !important;
        margin: 20px 0 !important;    /* 左右中央寄せのバグを防ぐためマージンをリセット */
        padding: 25px 15px !important; /* スマホで見やすいスッキリした余白に調整 */
        box-sizing: border-box !important;
    }

    /* 4. 最下部の出口ボタン（.bg1）の横幅をスマホ幅ぴったりに同期 */
    .article-block .bg1 {
        margin-left: -15px !important;   /* 上の .article-block の padding 分を打ち消す */
        margin-right: -15px !important;  /* 同上 */
        width: calc(100% + 30px) !important; /* 画面の端から端までぴったり密着 */
    }
}

/* =========================================================
   3つの原因エリア（.grid-box）のテキスト縮みを直すCSS
========================================================= */
@media screen and (max-width: 834px) {
    
    /* 1. 横並びの土台を解除して、強制的に縦並びにする */
    .grid-box section {
        display: block !important;
        width: 100% !important;
        clear: both !important;
        padding: 0 !important;
        margin-bottom: 30px !important; /* 各原因ごとの上下のすき間 */
    }

    /* 2. パソコン用の「幅60%」などの制限をリセットし、横幅いっぱいに広げる */
    .grid-box .text-01,
    .grid-box .image-01 {
        width: 100% !important;
        float: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    /* 3. 画像の横幅もスマホの画面幅にぴったりフィットさせる */
    .grid-box .image-01 img {
        width: 100% !important;
        height: auto !important;
        margin-top: 15px !important; /* 文字と画像の間のすき間 */
    }
}

/* =========================================================
   見出しの階層（h2・h3）とグループの区切りを明確にする
========================================================= */

/* 1. 大カテゴリ（h2）を「章の切り替え」として圧倒的に目立たせる */
#container h2 {
    position: relative;
    background: #f1f6f3 !important; /* 植物に合う優しい薄緑（テーマ色に合わせて変更可） */
    color: #2d443b !important;      /* 濃い緑系の文字色 */
    padding: 16px 20px !important;
    margin-top: 5rem !important;    /* 上のコンテンツとしっかり距離をあけて別グループにする */
    margin-bottom: 2rem !important;
    border-left: 6px solid var(--primary-color) !important; /* 左側にテーマカラーの太線 */
    border-radius: 6px 14px 14px 6px !important;            /* 角に優しい丸みを持たせる */
    font-size: 1.25rem !important;
    line-height: 1.5;
}

/* h2の中の英語（MAIN CAUSESなど）を下にちょこんと配置 */
#container h2 .small {
    display: block !important;
    font-size: 0.75rem !important;
    opacity: 0.6;
    margin-top: 4px !important;
    letter-spacing: 0.05em;
}

/* 2. 小カテゴリ（h3）は、h2の中身だと分かるように一歩引いたデザインに */
#container h3 {
    font-size: 1.1rem !important;
    color: #334155 !important;
    background: none !important;     /* 背景は塗らずに引き算する */
    padding: 0 0 0 12px !important;  /* 左側にだけ余白 */
    border-left: 3px solid #cbd5e1 !important; /* h2より細く控えめなグレーか薄緑の線 */
    border-bottom: none !important;
    margin-top: 2.5rem !important;
    margin-bottom: 1rem !important;
    border-radius: 0 !important;
}

/* 3. スマホでスクロールした時に「塊（セクション）」の終わりをハッキリさせる */
@media screen and (max-width: 834px) {
    #container > section {
        margin-bottom: 5rem !important;    /* 次のh2が始まる前にガッツリ空間を空ける */
        border-bottom: 1px dashed #e2e8f0; /* うっすら破線を入れて「ここで一旦終わり」を演出 */
        padding-bottom: 4rem !important;
    }
    
    /* 一番最後のセクション（FAQや監修者プロフの上）は線を消す */
    #container > section:last-of-type {
        border-bottom: none !important;
        margin-bottom: 2rem !important;
        padding-bottom: 0 !important;
    }
}

/* =========================================================
   モバイル用 テーブルCSS（完全修正版）
========================================================= */
@media screen and (max-width: 834px) {
    
    /* テーブル全体の表示崩れを防ぐ土台リセット */
    .ta1 {
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: none !important;
        box-sizing: border-box !important;
    }

    /* 1. 縦に潰れていたキャプション（表のタイトル）を横幅100%で綺麗に復活 */
    .ta1 caption {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        font-size: 1rem !important;
        font-weight: bold !important;
        color: #334155 !important;
        background: #f1f5f9 !important; /* スッキリした薄いグレーの帯に変更 */
        padding: 12px !important;
        margin-top: 0 !important;
        margin-bottom: 20px !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
    }

    /* パソコン用のヘッダー行（thead）は非表示 */
    .ta1 thead {
        display: none !important;
    }

    /* 中身の要素をすべて100%幅の縦並びブロック化 */
    .ta1 tbody, 
    .ta1 tr, 
    .ta1 th, 
    .ta1 td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
        white-space: normal !important;
    }

    /* 2. 1つの行（tr）を独立した「綺麗な白いカード」にする */
    .ta1 tr {
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;
        padding: 20px !important;
        margin-bottom: 25px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02) !important;
    }

    /* 3. 症状（th）の見出し部分の調整 */
    .ta1 th {
        border: none !important;
        padding: 0 0 10px 0 !important;
        margin-bottom: 15px !important;
        text-align: left !important;
        background: none !important;
    }
    
    /* 先ほどの「h3共通ルール」がここで暴走するのを強制的にリセット */
    .ta1 th h3 {
        margin: 0 !important;         /* 上の不自然な空白をゼロに */
        padding: 0 0 0 10px !important;
        font-size: 1.1rem !important;
        line-height: 1.4 !important;
        color: #1e293b !important;
        background: none !important;
        border-top: none !important;
        border-right: none !important;
        border-bottom: none !important;
        border-left: 4px solid var(--primary-color) !important; /* カード専用の細い左線 */
        border-radius: 0 !important;
    }

    /* 4. 各データ（td）の調整 */
    .ta1 td {
        border: none !important;
        padding: 0 !important;
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
        color: #334155 !important;
    }

    /* 1つ目のセル：原因の見極め方 */
    .ta1 td:nth-of-type(1) {
        margin-bottom: 15px !important;
        padding-bottom: 15px !important;
        border-bottom: 1px dashed #e2e8f0 !important; /* 中の区切り線 */
    }
    .ta1 td:nth-of-type(1)::before {
        content: "【原因の見極め方】" !important;
        display: block !important;
        font-weight: bold !important;
        color: #64748b !important;
        font-size: 0.8rem !important;
        margin-bottom: 6px !important;
    }

    /* 2つ目のセル：対処のワンポイント */
    .ta1 td:nth-of-type(2)::before {
        content: "【対処のワンポイント】" !important;
        display: block !important;
        font-weight: bold !important;
        color: #b45309 !important;
        font-size: 0.8rem !important;
        margin-bottom: 6px !important;
    }
}

/***************************************************
 * ACF連動用 リンク切り替え選択（本番確定版）
 *************************************************************************/

function get_custom_cta_data($post_id = null) {
    // 1. ACFからデータを取得
    $slug = get_field('出口ボタン', $post_id);
    
    // 2. 配列で取得されている場合の安全対策
    if (is_array($slug)) {
        if (isset($slug['value'])) {
            $slug = $slug['value'];
        } else {
            $slug = reset($slug);
        }
    }

    // 文字列に変換して前後の空白を削除
    $slug = trim((string)$slug);

    // 3. 各ボタンのデータを定義（余計なデバッグ装飾を完全削除）
    $cta_list = [
        'sodatekata' => [
            'url'   => 'https://example.com/sodatekata-tool/',
            'title' => 'プロ直伝の育て方をマスターしませんか？',
            'btn'   => 'あなたに最適の育成プランを診断する'
        ],
        'kankyou' => [
            'url'   => 'https://example.com/kankyou-check/',
            'title' => 'あなたのお部屋の環境に合う植物をチェック！',
            'btn'   => 'お部屋の日当たり・環境診断を試す'
        ],
        'toraburu' => [
            'url'   => 'https://example.com/trouble-shindan/',
            'title' => 'その「枯れ」「虫」の悩み、今すぐ解決！',
            'btn'   => '緊急：植物のトラブル復活診断を試す'
        ],
        'tokusyu' => [
            'url'   => 'https://example.com/special-gift/',
            'title' => '特別な一鉢をお探しですか？',
            'btn'   => '限定：希少品種の入荷情報をチェックする'
        ]
    ];

    // 4. 部分一致判定（正しいスラッグ名：toraburu で判定）
    if (!empty($slug)) {
        if (strpos($slug, 'toraburu') !== false || strpos($slug, 'トラブル') !== false) {
            return $cta_list['toraburu'];
        }
        if (strpos($slug, 'sodatekata') !== false || strpos($slug, '育て方') !== false) {
            return $cta_list['sodatekata'];
        }
        if (strpos($slug, 'kankyou') !== false || strpos($slug, '栽培環境') !== false) {
            return $cta_list['kankyou'];
        }
        if (strpos($slug, 'tokusyu') !== false || strpos($slug, '特殊') !== false) {
            return $cta_list['tokusyu'];
        }
    }

    // 5. どれにもマッチしなかった場合のデフォルト（総合ツール）
    return [
        'url'   => 'https://aki-ie.com/important/sougou-tool/',
        'title' => 'あなたにぴったりの植物、見つけませんか？',
        'btn'   => '無料：AI観葉植物マッチング診断を試す'
    ];
}
/***************************************************
/* 1. WordPressの強制整形からデザインを守る */
 /*************************************************************************/
.entry-content p, .entry-content div {
    margin-bottom: 0 !important; /* 勝手な余白を消す */
}

/* 2. 「ふっとぶ」現象の強制リセット */
#container, #main-content {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important; /* 横にはみ出さないよう封印 */
}

/* 3. 入れ子による「ちじこまり」を解消 */
#container section {
    width: 100% !important;
    margin: 0 !important;
    padding: 20px 5% !important; /* 8%から5%に下げて余裕を持たせる */
    box-sizing: border-box !important;
}

/* 4. グリッド内セクションの独立化 */
.grid-box section {
    padding: 10px 0 !important;
}

/* 右に落ち込むバグを強制解除 */
@media screen and (max-width: 834px) {
    /* grid-box 内の float を全て無効化 */
    .grid-box section, 
    .grid-box .text-01, 
    .grid-box .image-01 {
        display: block !important;
        float: none !important;
        width: 100% !important;
        clear: both !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 画像とテキストの間に少し隙間を作る */
    .grid-box .image-01 {
        margin-top: 20px !important;
        margin-bottom: 20px !important;
    }
}

/* スマホ版でテーブルをスクロールさせず、折り返して収める設定 */
@media screen and (max-width: 834px) {
    .ta1 {
        width: 100% !important;     /* 画面幅いっぱいに */
        table-layout: fixed;        /* 列幅を強制固定して崩れを防ぐ */
        min-width: auto !important; /* スクロール指定のmin-widthを無効化 */
    }

    .ta1 th, .ta1 td {
        width: auto !important;     /* 幅の固定を解除 */
        white-space: normal !important; /* 改行を許可 */
        word-wrap: break-word !important; /* 長い単語も折り返す */
        padding: 10px 8px !important;    /* 余白を少し詰める */
        font-size: 0.85rem !important;  /* スマホ用に少し文字を小さく */
    }

    /* 横スクロール枠（div）の制限を解除 */
    .ta1_wrapper, 
    div:has(> .ta1) {
        overflow-x: visible !important;
    }
}





/***************************************************
 * スマホ版でリストを縦一列（1・2・3）にする設定
 *************************************************************************/

@media screen and (max-width: 834px) {
    .list-grid.square {
        display: block !important; /* グリッドを解除してブロック（縦積み）にする */
    }

    .list-grid.square .list {
        width: 100% !important; /* 横幅を100%に */
        margin-bottom: 2rem !important; /* リスト同士の縦の隙間 */
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}
/* =========================================================
   修正：モバイル表示の崩れを根本解決するためのクリーンコード
   ※この下にある以前の修正CSSはすべて削除してください
========================================================= */

@media screen and (max-width: 834px) {
    /* 1. コンテナの幅を強制的に100%に固定 */
    #container, #main-content {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow-x: hidden !important;
    }

    /* 2. sectionの入れ子による「ちじこまり」を解除 */
    #container section {
        width: 100% !important;
        padding: 20px 15px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    /* 3. grid-box内のfloat・右落ちバグを強制解除 */
    .grid-box, .grid-box section {
        display: block !important;
        width: 100% !important;
        float: none !important;
        clear: both !important;
        padding: 0 !important;
    }
    
    .grid-box .text-01, .grid-box .image-01 {
        width: 100% !important;
        float: none !important;
    }

    /* 4. テーブルの幅崩れを修正 */
    .ta1 {
        width: 100% !important;
        table-layout: fixed !important;
    }
    .ta1 th, .ta1 td {
        white-space: normal !important;
        word-wrap: break-word !important;
    }

    /* 5. 挿し木リストの縦並び */
    .list-grid.square {
        display: block !important;
    }
    .list-grid.square .list {
        width: 100% !important;
        margin-bottom: 2rem !important;
    }
}



/* 記事下CSS（追加部分） */
.grid-box {
  display: grid;
  gap: 2rem;
  margin: 2rem 0;
}
.grid-item {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
@media(min-width: 768px) {
  .grid-item {
    flex-direction: row;
    align-items: stretch;
  }
  .grid-item.reverse {
    flex-direction: row-reverse;
  }
}
.text-01 {
  padding: 2rem;
  flex: 1;
}
.text-01 h3 {
  margin-top: 0;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
}
.text-01 h3 span {
  display: block;
  font-size: 0.8rem;
  color: #888;
  letter-spacing: 1px;
}
.image-01 {
  flex: 1;
  min-height: 250px;
}
.image-01 figure {
  margin: 0;
  height: 100%;
}
.image-01 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ta1 {
  width: 100%;
  border-collapse: collapse;
}
.ta1 th, .ta1 td {
  border: 1px solid #ddd;
  padding: 1rem;
  text-align: left;
}
.ta1 th {
  background: #f4f4f4;
}
.grid-mask {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.list.mask2 figure {
  margin: 0 0 1rem 0;
  border-radius: 8px;
  overflow: hidden;
}
.list.mask2 img {
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.furuya-faq-v3 details {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 1rem;
  padding: 1rem;
}
.furuya-faq-v3 summary {
  font-weight: bold;
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 20px;
}
.furuya-faq-v3 summary::-webkit-details-marker {
  display: none;
}
.furuya-faq-v3 .arrow {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}
.furuya-faq-v3 .answer-inner {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #ccc;
  color: #444;
  line-height: 1.8;
}
.tool-container {
  background: #f0f7f4;
  padding: 2rem;
  border-radius: 10px;
  margin: 3rem 0;
  border: 2px solid #a8cba8;
}
.tool-container h3 {
  margin-top: 0;
  color: #2c5e2c;
  text-align: center;
}
.tool-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 500px;
  margin: 0 auto;
}
.tool-form label {
  font-weight: bold;
  margin-bottom: -0.5rem;
}
.tool-form select {
  padding: 0.8rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
}
.btn-diagnose {
  background: #2c5e2c;
  color: #fff;
  padding: 1rem;
  border: none;
  border-radius: 5px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  margin-top: 1rem;
  transition: opacity 0.3s;
}
.btn-diagnose:hover {
  opacity: 0.8;
}
.tool-result {
  margin-top: 2rem;
  padding: 1rem;
  border-radius: 5px;
  display: none;
}
.tool-result.active {
  display: block;
}
.risk-high { background: #ffebee; border: 1px solid #ffcdd2; color: #c62828; }
.risk-med { background: #fff8e1; border: 1px solid #ffecb3; color: #f57f17; }
.risk-low { background: #e8f5e9; border: 1px solid #c8e6c9; color: #2e7d32; }