/*
 * 画面幅が 1300px 未満のときだけ読み込む（base.njk の <link media="...">）。
 * PC 幅（1300px 以上）の見た目は style2.css のまま変わらない。
 * 固定幅の画像で描いている枠（grey_* / info_* / sub_bg）は、伸縮できるように CSS で同じ見た目に描き直す。
 */

/* ---------- 共通（タブレット・スマホ） ---------- */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.body {
    width: 100%;
    min-height: 0;
}
#header {
    float: none;
    width: 100%;
    height: auto;
    aspect-ratio: 1296 / 403;
    background-size: 100% 100%;
}
#main {
    float: none;
    width: 100%;
    box-sizing: border-box;
    padding: 0 1.2% 0 1%;
    background-size: 100% auto;
}
.grey {
    float: none;
    width: auto;
    margin: -5px 0 0;
    padding: 0;
}
.grey_top,
.grey_bottom {
    display: none;
}
.grey_mid {
    float: none;
    width: auto;
    display: flow-root;
    margin: 0;
    padding: 14px 10px 16px;
    background: #f3f3f1;
    border-radius: 14px;
}
#main_menu #menu {
    margin-top: 0;
}
#info {
    float: none;
    width: auto;
    margin: 0 0 0 230px;
}
/* フッター：画像の Copyright は縮むと読めないので、文字を消した画像に本物の文字を重ねる */
#footer {
    float: none;
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 1296 / 110;
    background-image: url(images/foot_bg_notext.png);
    background-size: 100% 100%;
}
#footer .copyright {
    display: block;
    position: absolute;
    left: 9.2%;
    bottom: 20%;
    max-width: 55%;
    margin: 0;
    color: #444;
    font-family: Arial, Helvetica, sans-serif;
    font-size: max(10px, 1vw);
    line-height: 1.25;
    text-align: left;
}
#footer .copyright span {
    white-space: nowrap;
}

/* 白い枠（見出し・本文・下端） */
.info_top {
    height: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    box-shadow: 2px 0 2px -1px rgba(0, 0, 0, .15);
}
.info_header {
    padding: 13px 20px 8px;
}
.info_mid {
    background: #fff;
    border-left: 1px solid #d6d6d6;
    border-right: 1px solid #d6d6d6;
    box-shadow: 2px 0 2px -1px rgba(0, 0, 0, .15);
    overflow-x: auto;
}
.info_bottom {
    width: auto;
    height: 30px;
    margin-bottom: 14px;
    background:
        linear-gradient(#d2d3ce, #d2d3ce) no-repeat 10px 0 / calc(100% - 20px) 1px,
        linear-gradient(#fff 40%, #f5f5f5);
    border: 1px solid #d6d6d6;
    border-top: 0;
    border-radius: 0 0 6px 6px;
    box-shadow: 2px 2px 3px rgba(0, 0, 0, .18);
}

/* 緑のサブメニュー（特定症状の件数 | トピックス など） */
.sub, .sub_shorter {
    width: auto;
    max-width: 465px;
    height: auto;
    min-height: 23px;
    box-sizing: border-box;
    padding: 6px 15px 0;
    margin-bottom: 4px;
    background: #7ec02c;
    border-radius: 9px;
    display: flow-root;
}

/* 院内感染予防の取り組み（メニューのない別レイアウト）：説明文 → 写真 → 配置図 の 1 列にする */
.kansen-yobo #info {
    margin: 0;
}
.sub_shorter {
    padding: 5px 15px 6px;
}
.sub_shorter a {
    margin-top: 0 !important;
    height: auto !important;
}
.kansen-yobo #text,
.kansen-yobo #image {
    float: none !important;
    width: auto !important;
    max-width: 690px;
    margin: 8px 0 0 !important;
}
.kansen-yobo #text {
    padding: 0 6px;
    font-size: 10pt !important;
    line-height: 1.7;
}
.kansen-yobo #image img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 !important;
}
.kansen-yobo #pointer_div {
    width: 100% !important;
    max-width: 690px;
    height: auto !important;
    aspect-ratio: 690 / 611;
    margin: 12px 0 0 !important;
    background-size: 100% auto !important;
}

/* メニューを開くボタン（スマホだけ表示） */
#menu_toggle {
    display: none;
}

/* ---------- スマホ ---------- */
@media (max-width: 767px) {
    #main {
        padding: 0 1.5% 0 1.2%;
    }
    .grey_mid {
        padding: 10px 8px 12px;
        border-radius: 10px;
    }
    #main_menu {
        float: none;
        width: auto;
        margin: 0 0 10px;
    }
    #menu_toggle {
        display: block;
        width: 100%;
        padding: 10px 14px;
        border: 0;
        border-radius: 9px;
        background: #7ec02c;
        color: #fff;
        font-size: 15px;
        font-weight: bold;
        text-align: left;
        cursor: pointer;
    }
    #menu_toggle::before {
        content: "\2630";
        margin-right: 8px;
    }
    #main_menu #menu {
        display: none;
        margin-top: 8px;
    }
    #main_menu.open #menu {
        display: grid;
        grid-template-columns: repeat(auto-fill, 219px);
        justify-content: center;
        column-gap: 8px;
    }
    #info {
        margin: 0;
    }
    .info_header {
        padding-left: 14px;
    }
    .info_mid {
        padding-left: 14px;
        padding-right: 14px;
        font-size: 10pt;
        line-height: 1.7;
    }

    /* 1 文字だけ次の行に落ちないように：表のセルや Topics のタイトルのような短い文は各行の長さをそろえる。
       文章（.info_mid 全体）には text-wrap: pretty を使わない。iPhone の Safari では行を早めに折り返し、
       長い行と短い行が混ざって見える（三井先生のご指摘）ため。表のセルと Topics は短いので pretty で問題ない */
    .info_mid td,
    ul.newNews li {
        text-wrap: pretty;
    }
    /* ただし、レイアウト用の表（トップの写真と説明文、病院概要）の中は文章なので pretty を使わない
       （Safari で「〜症状や目／的に〜」のように早めに折り返す。三井先生のご指摘 2026-11-22） */
    .info_mid > div > table > tbody > tr > td,
    table#hos td {
        text-wrap: wrap;
    }
    /* 乳幼児健診の表は balance：pretty だと Safari で「一般医／療機関」のように早めに折り返す */
    .info_mid th,
    table#clock td,
    table#tbl td,
    ul.newNews li a {
        text-wrap: balance;
    }

    /* 本文の画像がはみ出さないように（表は .info_mid の中で横スクロール） */
    .info_mid img {
        max-width: 100%;
        height: auto;
    }

    /* トップページ・病院概要：写真と説明文を縦に並べる */
    .info_mid > div > table > tbody > tr > td,
    table#hos td {
        display: block;
    }
    table#hos {
        width: auto;
        margin-bottom: 10px;
    }

    /* 診療時間：時刻を 1 行で。「午前／午後」のあとに 1 文字分あける（「午後　休診」） */
    table#clock td[width] {
        width: auto;
    }
    table#clock td:nth-child(2) {
        padding-right: 1em;
    }

    /* 予防接種の表：ワクチン名の列を狭めて【対象年齢】を広げる（三井先生のご要望）。
       「四種混合ワクチン」などは「ワクチン」を隠し、「麻疹・風疹混合ワクチン」は 2 行にする。PC はそのまま */
    .sp-hide {
        display: none;
    }
    .sp-block {
        display: block;
    }

    /* スマホだけの文章の調整（三井先生のご要望 2026-11-18）：
       .sp-hide … 隠す（説明文の先頭の空白、乳幼児健診の表の「健診」）
       .sp-only … スマホだけに出す（予防接種の「ロタウイルスワクチン」などの頭の「☆」、
                  予防接種の表のスマホ用の文言と改行 2026-11-26）
       .pc-only … スマホでは出さない（予防接種の「〜可能ですが、」のあとの改行、表の PC 用の文言） */
    .sp-only {
        display: inline;
    }
    .pc-only {
        display: none;
    }
    /* 予防接種の表のスマホ用の文言は、先生が指定した位置でだけ改行する。
       ただし表の右端の列（推奨年齢・接種時期）は、画面が狭くて入らないときだけ折り返す */
    table.tbl .sp-only {
        white-space: nowrap;
    }
    /* 麻疹・風疹の「2期　5～7歳未満で小学校入学前の1年間」は 1 行で（先生のご要望 2026-12-02）。
       幅 370px 未満（一部の小さい Android）では入りきらないので折り返す */
    @media (min-width: 370px) {
        table.tbl .sp-nowrap {
            white-space: nowrap;
        }
    }
    table.tbl td:last-child .sp-only {
        white-space: normal;
        word-break: keep-all;   /* 折り返すときは「初回(2回)」と「3歳」の間の空白などで */
    }

    /* 改行させない列：診療時間の「午前／午後」と時刻、外来担当医の「副院長」、予防接種のワクチン名 */
    table#clock td:nth-child(2),
    table#clock td:last-child,
    table.day td:first-child,
    table#tbl td:first-child,
    table.tbl:first-of-type tr th:first-child {
        white-space: nowrap;
    }

    /* 予防接種・乳幼児健診などの表：ページ内の <style> の固定幅（550px・600px・列幅）を外して画面に収める */
    .info_mid table.tbl,
    .info_mid table#tbl {
        width: auto !important;
        max-width: 100%;
    }
    .info_mid table.tbl tr th,
    .info_mid table.tbl tr td,
    .info_mid table#tbl tr th,
    .info_mid table#tbl tr td {
        width: auto !important;
        padding: 4px;
    }
    /* 予防接種の表は左右を少し詰める（先生が指定した改行のまま、なるべく画面に収める） */
    .info_mid table.tbl tr th,
    .info_mid table.tbl tr td {
        padding: 4px 3px;
    }

    /* Topics の一覧：日付とタイトルを詰める */
    ul.newNews li {
        width: auto;
        height: auto !important;
        margin-bottom: 8px;
    }
    ul.newNews li table td[width] {
        width: auto;
        white-space: nowrap;
    }
}
