/* ==========================================================
   HMH Exams：検査内容の最低限の見た目
   - 施設のテーマで上書きする前提の土台。見た目の指定は「:where(.hmhex) .クラス」の形で、
     強さはクラス1つ分にしてある。テーマの要素向けのリセット（span, section { border:0 } など）には勝ち、
     テーマでクラスを使って書いた指定とは同じ強さになる（テーマの CSS があとに読まれるのでテーマが勝つ）
   - 色・線は CSS 変数で変えられる（例：.hmhex { --hmhex-accent: #b8964e; }）
   - テーマで全部書いていて不要なら、テーマの functions.php で
     add_filter( 'hmh_exams_enqueue_css', '__return_false' );
   ========================================================== */

:where(.hmhex) {
    --hmhex-text: inherit;
    --hmhex-sub: #555;
    --hmhex-accent: #0b5cad;
    --hmhex-line: rgba(0, 0, 0, 0.14);
    --hmhex-bg: #fff;
    --hmhex-soft: #f4f6f8;
    --hmhex-warn-bg: #f8ecea;
    --hmhex-warn: #9a3d33;
    --hmhex-info-bg: #e8eef6;
    --hmhex-info: #2e5280;
    color: var(--hmhex-text);
}
/* 本文が中央揃えのテーマでも左揃えにする。
   下には常に余白を付け、後ろに続く本文やテーマの次のセクションとくっつかないようにする
   （テーマの div { margin: 0 } などのリセットに負けないよう、クラス1つ分の強さ） */
.hmhex {
    margin-bottom: 2em;
    text-align: left;
}
/* 切り替え表示の中の表示（入れ子）には余白を付けない */
.hmhex .hmhex {
    margin-bottom: 0;
}

/* ----------------------------------------------------------
   本文（固定ページ・お知らせ）の中に置いたときの打ち消し
   テーマの本文用スタイル（.entry-content ul li など）に負けると崩れる部分だけ、
   .hmhex を付けて少し強めにしてある
   ---------------------------------------------------------- */
.hmhex :is(.op-group__list, .dh-exam__list, .op-item__notes) {
    margin-bottom: 0;
    padding-left: 0;
    list-style: none;
}
.hmhex :is(.op-group__list, .dh-exam__list, .op-item__notes) > li {
    margin-bottom: 0;
    list-style: none;
}
.hmhex :is(.op-group__title, .dh-exam__group) {
    margin-top: 0;
}
.hmhex .dh-exam__group {
    padding-bottom: 0;
    border-bottom: 0;
}
.hmhex :is(.dh-exam__img) {
    max-width: none;
    height: auto;
}

/* ----------------------------------------------------------
   オプション検査一覧（[hmh_exam_options]・[hmh_exam style="list"]）
   ---------------------------------------------------------- */
:where(.hmhex) .op-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 20px;
    align-items: start;
}
:where(.hmhex) .op-group {
    padding: 16px 20px 6px;
    border: 1px solid var(--hmhex-line);
    background: var(--hmhex-bg);
}
:where(.hmhex) .op-group__title {
    margin: 0 0 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hmhex-line);
    font-size: 1.1em;
}
:where(.hmhex) .op-item + .op-item {
    border-top: 1px dashed var(--hmhex-line);
}
:where(.hmhex) .op-item__summary {
    display: block;
    padding: 12px 0;
    list-style: none;
}
:where(.hmhex) summary.op-item__summary {
    cursor: pointer;
}
:where(.hmhex) summary.op-item__summary::-webkit-details-marker {
    display: none;
}
:where(.hmhex) .op-item__row {
    display: flex;
    align-items: center;
    gap: 10px;
}
/* 説明のない検査も料金の位置を揃える（「?」の幅だけ空ける） */
:where(.hmhex) div.op-item__summary .op-item__row::after {
    content: "";
    width: 22px;
    flex-shrink: 0;
}
:where(.hmhex) .op-item__name {
    flex: 1;
    min-width: 0;
    font-weight: 700;
    line-height: 1.6;
}
:where(.hmhex) .op-item__price {
    flex-shrink: 0;
    max-width: 50%;          /* 長い料金（「3,300円 → キャンペーン価格 1,650円」など）で検査名がつぶれないように */
    text-align: right;
    word-break: keep-all;    /* 空白のある所でだけ折り返す。「19,800円」は改行しない */
    overflow-wrap: normal;
}
:where(.hmhex) .op-item__q {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
}
:where(.hmhex) .op-item__details[open] > summary .op-item__q {
    background: var(--hmhex-accent);
    border-color: var(--hmhex-accent);
    color: #fff;
}
:where(.hmhex) .op-item__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
/* 部位ごとの表示では、一覧の行の受診条件のラベルを隠し、「?」で開いた説明の中に出す（視認性のため）。
   一覧表（op-table）のラベルはそのまま。一覧の行にも出したいテーマは .hmhex .op-item__summary .op-item__tags を上書きする */
.hmhex .op-item__summary .op-item__tags {
    display: none;
}
:where(.hmhex) .op-item__detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}
:where(.hmhex) .op-tag {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.75em;
    line-height: 1.7;
}
:where(.hmhex) .op-tag.is-warn {
    background: var(--hmhex-warn-bg);
    color: var(--hmhex-warn);
}
:where(.hmhex) .op-tag.is-info {
    background: var(--hmhex-info-bg);
    color: var(--hmhex-info);
}
:where(.hmhex) .op-item__detail {
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--hmhex-soft);
    font-size: 0.9em;
    line-height: 1.8;
}
:where(.hmhex) .op-item__detail p {
    margin: 0;
}
:where(.hmhex) .op-item__detail p + p {
    margin-top: 6px;
}
:where(.hmhex) .op-item__notes {
    margin-top: 8px;
    color: var(--hmhex-sub);
    font-size: 0.9em;
}
:where(.hmhex) .op-item__notes li {
    position: relative;
    padding-left: 1.2em;
}
:where(.hmhex) .op-item__notes li::before {
    content: "\203B";
    position: absolute;
    left: 0;
}
:where(.hmhex) .op-item__link {
    margin-top: 8px;
}
/* 画面読み上げ用の「（説明を表示）」 */
:where(.hmhex) .op-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ----------------------------------------------------------
   検査のカード（コースページの検査内容・[hmh_exam]）
   ---------------------------------------------------------- */
:where(.hmhex) .dh-exam + .dh-exam {
    margin-top: 32px;
}
:where(.hmhex) .dh-exam__group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
    font-size: 1em;
    font-weight: 700;
}
:where(.hmhex) .dh-exam__group::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--hmhex-line);
}
:where(.hmhex) .dh-exam__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 12px;
}
:where(.hmhex) .dh-exam__item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--hmhex-line);
    background: var(--hmhex-bg);
}
:where(.hmhex) .dh-exam__item--wide {
    grid-column: 1 / -1;
}
:where(.hmhex) .dh-exam__img {
    flex-shrink: 0;
    width: 88px;
    aspect-ratio: 6 / 5;
    object-fit: contain;
}
:where(.hmhex) .dh-exam__body {
    flex: 1;
    min-width: 0;
}
:where(.hmhex) .dh-exam__name {
    margin: 0;
    font-weight: 700;
    line-height: 1.6;
}
:where(.hmhex) .dh-exam__tag {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 6px;
    background: var(--hmhex-accent);
    color: #fff;
    font-size: 0.7em;
    font-weight: 700;
    vertical-align: middle;
}
:where(.hmhex) .dh-exam__detail {
    margin: 4px 0 0;
    color: var(--hmhex-accent);
    font-size: 0.85em;
    font-weight: 700;
}
:where(.hmhex) .dh-exam__text {
    margin: 6px 0 0;
    color: var(--hmhex-sub);
    font-size: 0.9em;
    line-height: 1.8;
}

/* 内訳（血液検査など） */
:where(.hmhex) .dh-blood {
    margin-top: 12px;
    border: 1px solid var(--hmhex-line);
}
:where(.hmhex) .dh-blood__summary {
    position: relative;
    padding: 8px 40px 8px 12px;
    font-size: 0.9em;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
:where(.hmhex) .dh-blood__summary::-webkit-details-marker {
    display: none;
}
:where(.hmhex) .dh-blood__summary::after {
    content: "+";
    position: absolute;
    top: 50%;
    right: 12px;
    color: var(--hmhex-accent);
    transform: translateY(-50%);
}
:where(.hmhex) .dh-blood[open] .dh-blood__summary::after {
    content: "\2212";
}
:where(.hmhex) .dh-blood__list {
    margin: 0;
    padding: 4px 12px 10px;
}
:where(.hmhex) .dh-blood__row {
    display: grid;
    grid-template-columns: 6em minmax(0, 1fr);
    gap: 12px;
    padding: 6px 0;
    font-size: 0.85em;
    line-height: 1.7;
}
:where(.hmhex) .dh-blood__row + .dh-blood__row {
    border-top: 1px dashed var(--hmhex-line);
}
:where(.hmhex) .dh-blood__row dt {
    font-weight: 700;
}
:where(.hmhex) .dh-blood__row dd {
    margin: 0;
    color: var(--hmhex-sub);
}

/* ----------------------------------------------------------
   一覧表（[hmh_exam_options view="table"]）
   ---------------------------------------------------------- */
:where(.hmhex) .op-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--hmhex-bg);
    font-size: 0.95em;
}
/* テーマの th / td 向けの余白の指定（padding: 0 など）に負けないよう、余白だけ少し強くする */
.hmhex .op-table th,
.hmhex .op-table td {
    padding: 10px 12px;
}
:where(.hmhex) .op-table th,
:where(.hmhex) .op-table td {
    border: 1px solid var(--hmhex-line);
    text-align: left;
    vertical-align: top;
    line-height: 1.7;
}
:where(.hmhex) .op-table thead th {
    background: var(--hmhex-soft);
    font-weight: 700;
    white-space: nowrap;
}
:where(.hmhex) .op-table__cat th {
    background: var(--hmhex-soft);
    color: var(--hmhex-accent);
    font-weight: 700;
}
:where(.hmhex) .op-table__name {
    width: 28%;
    font-weight: 700;
}
:where(.hmhex) .op-table__name .op-item__tags {
    font-weight: 400;
}
:where(.hmhex) .op-table__price {
    width: 8em;
    text-align: right;
    word-break: keep-all;
    overflow-wrap: normal;
}
:where(.hmhex) .op-table thead .op-table__price,
:where(.hmhex) .op-table td.op-table__price {
    text-align: right; /* テーマの td { text-align: left } などに負けないよう少し強くする */
}
:where(.hmhex) .op-table__detail p {
    margin: 0;
}
:where(.hmhex) .op-table__detail p + p {
    margin-top: 6px;
}
/* テーマが th の前後に飾り（::before / ::after）を付けている場合に消す */
.hmhex .op-table th::before,
.hmhex .op-table th::after {
    content: none;
}
/* スマホ：1行目に検査名と料金、2行目に説明 */
@media (max-width: 640px) {
    .hmhex .op-table,
    .hmhex .op-table tbody,
    .hmhex .op-table tr,
    .hmhex .op-table th,
    .hmhex .op-table td {
        display: block;
        width: auto;
    }
    .hmhex .op-table thead {
        display: none;
    }
    .hmhex .op-table .op-table__row { /* 上の tr { display: block } より強くする */
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        border: 1px solid var(--hmhex-line);
        border-top: 0;
    }
    .hmhex .op-table__cat th {
        border-top-width: 1px;
    }
    .hmhex .op-table__row > * {
        border: 0;
    }
    /* HTML の並びは 検査名・説明・料金。スマホでは料金を1行目の右に出す */
    .hmhex .op-table__row .op-table__name {
        grid-column: 1;
        grid-row: 1;
    }
    .hmhex .op-table__row .op-table__price {
        grid-column: 2;
        grid-row: 1;
        max-width: 12em; /* 長い料金で検査名がつぶれないように（空白の所で折り返す） */
    }
    .hmhex .op-table .op-table__row .op-table__detail {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-top: 0;
    }
}

/* ----------------------------------------------------------
   見る人が切り替える表示（[hmh_exam_options view="switch"]）
   どちらを表示するかの仕組みは、テーマのリセットに負けないようクラスの強さで書く
   ---------------------------------------------------------- */
.hmhex .hmhex-switch__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.hmhex-switch .hmhex-switch__panel {
    display: none;
}
.hmhex-switch .hmhex-switch__input--category:checked ~ .hmhex-switch__panel--category,
.hmhex-switch .hmhex-switch__input--table:checked ~ .hmhex-switch__panel--table {
    display: block;
}
:where(.hmhex) .hmhex-switch__tabs {
    display: flex;
    margin-bottom: 16px;
}
:where(.hmhex) .hmhex-switch__tab {
    padding: 8px 18px;
    border: 1px solid var(--hmhex-accent);
    background: var(--hmhex-bg);
    color: var(--hmhex-accent);
    font-weight: 700;
    line-height: 1.5;
    cursor: pointer;
}
:where(.hmhex) .hmhex-switch__tab + .hmhex-switch__tab {
    border-left: 0;
}
.hmhex-switch .hmhex-switch__input--category:checked ~ .hmhex-switch__tabs .hmhex-switch__tab--category,
.hmhex-switch .hmhex-switch__input--table:checked ~ .hmhex-switch__tabs .hmhex-switch__tab--table {
    background: var(--hmhex-accent);
    color: #fff;
}
.hmhex-switch .hmhex-switch__input--category:focus-visible ~ .hmhex-switch__tabs .hmhex-switch__tab--category,
.hmhex-switch .hmhex-switch__input--table:focus-visible ~ .hmhex-switch__tabs .hmhex-switch__tab--table {
    outline: 2px solid var(--hmhex-accent);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    :where(.hmhex) .dh-exam__img {
        width: 64px;
    }
    :where(.hmhex) .dh-blood__row {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }
}
