/* =========================================================
  flow.css（画像右側デザイン寄せ）
  - 既存HTMLの class（flow-box / flow-wide / flow-arrow-down）に合わせる
  - 追加クラス不要（Gutenbergの並びを :has() / :first-of-type で判定）
  - 外来受診ボタン：色はブロックエディタで指定（CSSでは指定しない）
========================================================= */

:root{
  --flow-accent: #133a76;
  --flow-accent-soft: #0f2f63;
  --flow-border: rgba(0,0,0,.25);
  --flow-border-strong: rgba(0,0,0,.28);
  --flow-bg: #ffffff;
  --flow-bg-soft: #f5f6f8;
  --flow-radius: 12px;
  --flow-shadow: 0 10px 26px rgba(0,0,0,.08);
}

/* ------------------------------
  Gutenberg columns 余白
------------------------------ */
.wp-block-columns{
  gap: 28px;
  margin: 0 0 22px;
}
@media (max-width: 781px){
  .wp-block-columns{
    gap: 14px;
    margin-bottom: 18px;
  }
}

/* =========================================================
  1) 上段（新患/再来/紹介）だけ：青いカード
  判定：
  - 対象：flow-box が3つ並ぶ columns（選択カード行）
  - :has()対応ブラウザは確実に拾う
  - 非対応は first-of-type をフォールバック
========================================================= */

/* :has() が使える場合（推奨） */
@supports selector(.wp-block-columns:has(.flow-box)){
  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box{
    background: var(--flow-accent);
    color: #fff;
    border: 0;
    border-radius: var(--flow-radius);
    box-shadow: var(--flow-shadow);
    padding: 26px 22px;
    text-align: center;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box > p:first-child{
    margin: 0 0 10px;
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: .02em;
    line-height: 1.25;
  }

  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box ul{
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
    display: inline-block;
  }
  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box li{
    margin: 0;
    padding-left: 1.05em;
    line-height: 1.65;
    font-weight: 600;
    font-size: 0.98rem;
    position: relative;
  }
  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box li + li{
    margin-top: 6px;
  }
  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box li::before{
    content: "・";
    position: absolute;
    left: 0;
    top: 0;
  }

  .wp-block-columns:has(> .wp-block-column.flow-box):has(> .wp-block-column.flow-box:nth-child(3)) .flow-box > p{
    margin: 0;
  }
}

/* :has() 非対応フォールバック */
@supports not selector(.wp-block-columns:has(.flow-box)){
  .wp-block-columns:first-of-type .flow-box{
    background: var(--flow-accent);
    color: #fff;
    border: 0;
    border-radius: var(--flow-radius);
    box-shadow: var(--flow-shadow);
    padding: 26px 22px;
    text-align: center;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .wp-block-columns:first-of-type .flow-box > p:first-child{
    margin: 0 0 10px;
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: .02em;
    line-height: 1.25;
  }

  .wp-block-columns:first-of-type .flow-box ul{
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
    display: inline-block;
  }
  .wp-block-columns:first-of-type .flow-box li{
    margin: 0;
    padding-left: 1.05em;
    line-height: 1.65;
    font-weight: 600;
    font-size: 0.98rem;
    position: relative;
  }
  .wp-block-columns:first-of-type .flow-box li + li{
    margin-top: 6px;
  }
  .wp-block-columns:first-of-type .flow-box li::before{
    content: "・";
    position: absolute;
    left: 0;
    top: 0;
  }

  .wp-block-columns:first-of-type .flow-box > p{
    margin: 0;
  }
}

/* =========================================================
  2) 通常の flow-box：薄グレー枠
========================================================= */
.flow-box{
  background: var(--flow-bg-soft);
  border: 2px solid var(--flow-border-strong);
  border-radius: var(--flow-radius);
  padding: 18px 18px;
  color: #111;
  box-shadow: none;
}
.flow-box p{
  margin: 0;
  line-height: 1.85;
}
.flow-box p + p{
  margin-top: 10px;
}
.flow-box ul{
  margin: 10px 0 0 1.2em;
}
.flow-box li{
  line-height: 1.75;
}

/* =========================================================
  3) 全幅枠（flow-wide）
========================================================= */
.flow-wide{
  background: #fff;
  border: 1px solid var(--flow-border);
  border-radius: var(--flow-radius);
  padding: 18px 18px;
  margin: 20px 0;
  line-height: 1.9;
}
.flow-wide p{ margin: 0; }
.flow-wide p + p{ margin-top: 10px; }

.flow-wide .has-text-align-center{
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .02em;
}

/* =========================================================
  4) 矢印（縦）
========================================================= */
.flow-arrow-down{
  width: 0;
  height: 0;
  margin: 14px auto 18px;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 20px solid var(--flow-accent);
}
.wp-block-columns .flow-arrow-down{
  margin: 10px auto 14px;
}
@media (max-width: 520px){
  .flow-arrow-down{
    border-left-width: 14px;
    border-right-width: 14px;
    border-top-width: 18px;
    margin: 12px auto 14px;
  }
}

/* =========================================================
  5) 仕上げ：ブロックエディタ由来の余白を整える
========================================================= */
.wp-block-column{ min-width: 0; }
.flow-box .wp-block-list{ margin: 0; }
.flow-wide br{ line-height: 1.9; }

/* flow-box をリンク化しても見た目を崩さない */
.flow-box__link{
  display:block;
  color: inherit;
  text-decoration: none;
}
.flow-box__link:focus-visible{
  outline: 3px solid rgba(0, 75, 141, .35);
  outline-offset: 4px;
  border-radius: 12px;
}
.flow-box__title{
  margin: 0 0 10px;
  font-weight: 700;
}
.flow-jump{
  display:inline-block;
  margin: 10px 0 24px;
}

/* アンカー飛び先の位置調整（固定ヘッダー対策） */
.flow-section{
  scroll-margin-top: 90px; /* ヘッダー高さに合わせて調整 */
}

/* =========================================================
  6) 外来受診：Buttonsブロック（確定版・スコープ限定）
  対象：.tch-flow-buttons を付けた Buttons ブロックのみ
========================================================= */

/* Gutenbergが自動付与する flex 指定を、このセットだけ grid に上書き */
.wp-block-buttons.tch-flow-buttons.is-layout-flex{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
  margin-top: 24px;
}

/* 各ボタン */
.wp-block-buttons.tch-flow-buttons > .wp-block-button{
  width: 100%;
  height: 100%;
  margin: 0;
}

/* ボタン本体 */
.wp-block-buttons.tch-flow-buttons .wp-block-button__link{
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;

  height: 100%;
  min-height: 140px;

  padding: 22px 24px 20px;
  background-color: #fff !important;
  border: 1px solid #0f2f5c;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);

  text-align: center;
  line-height: 1.6;
  text-decoration: none;
  color: #0f2f5c !important;
}

/* タイトル行 */
.wp-block-buttons.tch-flow-buttons .wp-block-button__link .btn-title{
  display: block;
  font-size: 20px;
  font-weight: 700;
  margin: -22px -24px 14px;
  padding: 12px 16px 10px;
  background-color: #0f2f5c;
  color: #fff;
  border-radius: 10px 10px 0 0;
}
/* 本文 */
.wp-block-buttons.tch-flow-buttons .wp-block-button__link{
  font-size: 15px;
}

/* hover */
.wp-block-buttons.tch-flow-buttons .wp-block-button__link:hover{
  background-color: #f6fafe !important;
}

/* SP：1列 */
@media (max-width: 768px){
  .wp-block-buttons.tch-flow-buttons{
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .wp-block-buttons.tch-flow-buttons .wp-block-button__link{
    min-height: 0;
    padding: 18px 16px 16px;
  }
  .wp-block-buttons.tch-flow-buttons .wp-block-button__link .btn-title{
    margin: -18px -16px 12px;
    padding: 10px 12px;
    font-size: 18px;
  }
}
