/* =========================================================
 * 基本
 * ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans JP",
        sans-serif;

    background: #fff;
    color: #222;
}

body {
    padding-bottom: 70px;
}


/* =========================================================
 * 上部固定
 * ========================================================= */

.top-area {
    position: fixed;

    top: 0;
    left: 0;
    right: 0;

    z-index: 90;

    width: 100%;

    background: #fff;
}


/* ---------- 上部ナビ ---------- */

.top-nav {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: clamp(8px, 3vw, 20px);

    min-height: 54px;

    padding: 6px 10px;
}


.script-button {
    flex-shrink: 0;

    font-size: clamp(22px, 7vw, 34px);

    padding: 4px 14px;

    border: 1px solid #aaa;
    border-radius: 10px;

    background: #e8f6ff;

    cursor: pointer;
}


.mode-link {
    font-size: clamp(11px, 3.2vw, 15px);

    white-space: nowrap;

    color: #245b8a;
}


/* =========================================================
 * 画像
 * ========================================================= */

.image-area {
    height: 33vh;

    min-height: 0;
    max-height: none;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 6px 12px;
}


.image-area img {
    display: block;

    max-width: 100%;
    max-height: 100%;

    object-fit: contain;
}


/* =========================================================
 * 学習領域
 * ========================================================= */

.learning-area {
    width: min(100%, 700px);

    /*
     * 上部ナビ54px + 画像33vh
     */
    margin:
        calc(54px + 33vh)
        auto
        0;

    padding:
        12px
        12px
        85px;
}


/* =========================================================
 * 各学習セクション
 * ========================================================= */

.section {
    margin: 3px 0 5px;
}


.section-title {
    margin: 0 0 3px;

    font-size: clamp(11px, 3.2vw, 15px);

    font-weight: 500;

    white-space: nowrap;
}


/* =========================================================
 * 音声ボタン共通
 * ========================================================= */

.sound-row {
    display: flex;

    flex-wrap: nowrap;

    justify-content: center;
    align-items: center;

    width: 100%;
    max-width: 100%;

    gap: clamp(1px, 0.8vw, 6px);

    overflow: hidden;
}


.sound-button {
    flex: 0 1 auto;

    min-width: 0;
    min-height: 1.35em;

    padding:
        2px
        clamp(2px, 1.5vw, 10px);

    font-size: clamp(14px, 12vw, 60px);

    line-height: 1.15;

    white-space: nowrap;

    border: 1px solid #9cb8c8;
    border-radius: 12px;

    background: #e8f6ff;
    color: #111;

    cursor: pointer;
}


/* =========================================================
 * 基本カテゴリ「もじ」
 * ========================================================= */

.basic-mora-row .sound-button {
    /*
     * ね・こ等は従来どおり大きく横書き。
     */
    writing-mode: horizontal-tb;
}


/* =========================================================
 * 詳細カテゴリ「もじ」
 *
 * 1モーラを1ボタンとしたまま、
 * ウェー・ジャ・フォ・キャッ等を縦方向にする。
 * ========================================================= */

.detail-mora-row {
    align-items: center;

    gap: clamp(1px, 0.5vw, 4px);
}


.detail-mora-row .detail-mora-button {
    writing-mode: vertical-rl;

    /*
     * 日本語・小書き文字も1文字ずつ正立させる。
     */
    text-orientation: upright;

    flex: 0 1 auto;

    min-width: 1.25em;
    min-height: 1.4em;

    padding: 4px 3px;

    line-height: 1;

    white-space: nowrap;
}


/* =========================================================
 * 「ことば」
 * ========================================================= */

.word-button {
    display: block;

    width: auto;
    max-width: 100%;

    margin-left: auto;
    margin-right: auto;

    padding-left: 16px;
    padding-right: 16px;

    font-size: clamp(14px, 12vw, 60px);

    white-space: nowrap;

    overflow: hidden;
}


/* =========================================================
 * JavaScript自動サイズ調整
 * ========================================================= */

.auto-fit-text {
    white-space: nowrap;
}


/* =========================================================
 * 変更プルダウン
 * ========================================================= */

.select-row {
    display: flex;

    flex-direction: column;

    gap: 10px;
}


.select-row select {
    width: 100%;

    min-height: 44px;

    padding: 5px 8px;

    font-size: clamp(16px, 5vw, 22px);
}


/* =========================================================
 * 下部ナビ
 * ========================================================= */

hr {
    border: 0;

    border-top: 1px solid #bbb;

    margin: 24px 0;
}


.bottom-links {
    display: flex;

    justify-content: center;
    flex-wrap: wrap;

    gap: 8px 16px;

    text-align: center;
}


.bottom-links a,
.license-links a {
    color: #245b8a;
}


.license-links {
    text-align: center;

    line-height: 1.9;
}


/*
 * 固定フッターに隠れない位置へ
 */
#license {
    scroll-margin-bottom: 120px;
}


/* =========================================================
 * 最下部固定
 * ========================================================= */

.fixed-footer {
    position: fixed;

    left: 0;
    right: 0;
    bottom: 0;

    z-index: 100;

    background: rgba(255, 255, 255, 0.97);

    border-top: 1px solid #aaa;

    padding: 2px 6px 3px;

    text-align: center;
}


.license-note {
    max-width: 700px;

    margin: 0 auto 1px;

    font-size: clamp(6px, 1.8vw, 8px);

    line-height: 1.1;
}


.copyright {
    margin: 0;

    font-size: clamp(10px, 3vw, 13px);

    line-height: 1.1;
}


/* =========================================================
 * 横画面
 * ========================================================= */

@media (orientation: landscape) {

    .image-area {
        height: 28vh;
    }

    .learning-area {
        margin-top: calc(54px + 28vh);
    }

}


/* =========================================================
 * 前の動物 ← / → 次の動物
 * ========================================================= */

.pet-step-navigation {
    display: grid;

    grid-template-columns:
        minmax(52px, 72px)
        minmax(0, 1fr)
        minmax(52px, 72px);

    align-items: center;

    gap: 8px;

    width: 100%;
}


.pet-step-button {
    display: flex;

    align-items: center;
    justify-content: center;

    min-height: 46px;

    border: 1px solid #9cb8c8;
    border-radius: 12px;

    background: #e8f6ff;
    color: #111;

    text-decoration: none;

    font-size: clamp(28px, 8vw, 42px);
    line-height: 1;
}


.pet-step-current {
    min-width: 0;

    text-align: center;

    font-size: clamp(12px, 3.5vw, 17px);

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================================================
 * 詳細カテゴリ「もじ」だけ縦書き
 * ========================================================= */

.detail-mora-row .sound-button {
    writing-mode: vertical-rl;
    text-orientation: upright;

    /* モーラが2～3文字でも縦に並べる */
    white-space: normal;

    /* ボタン幅を細くする */
    width: auto;
    min-width: 1.35em;

    /* 縦方向には文字数分の高さを許可 */
    min-height: 1.35em;
    height: auto;

    padding: 4px 3px;

    line-height: 1;
}


/*
 * 詳細カテゴリのモーラ数が多くても
 * 横1列を維持する
 */
.detail-mora-row {
    display: flex;
    flex-wrap: nowrap;

    justify-content: center;
    align-items: flex-start;

    gap: clamp(1px, 0.8vw, 6px);

    width: 100%;
    max-width: 100%;

    overflow: hidden;
}


/*
 * 詳細カテゴリでは横幅を均等に縮められるようにする
 */
.detail-mora-row .sound-button {
    flex: 0 1 auto;

    padding-left: 2px;
    padding-right: 2px;

    font-size: clamp(14px, 8vw, 46px);
}


/* =========================================================
 * 幼児操作向け：誤ドラッグ・文字選択防止
 *
 * タップ             : 有効
 * 画像ドラッグ       : 無効
 * 文字選択           : 無効
 * ページ縦スクロール : 有効
 * ========================================================= */

/*
 * ページ上の文字を選択させない。
 *
 * touch-action は none にしない。
 * 縦スクロールは通常どおり残す。
 */
html,
body,
button,
a,
select,
option,
.page {
    -webkit-user-select: none;
    user-select: none;
}


/*
 * 画像のドラッグ禁止。
 *
 * 画像自体にはクリック処理がないため、
 * pointer-events:none で画像を直接つかめなくする。
 */
.image-area img {
    -webkit-user-drag: none;
    user-drag: none;

    -webkit-user-select: none;
    user-select: none;

    pointer-events: none;
}


/*
 * タッチ操作はブラウザ標準の縦スクロールを許可。
 *
 * pan-y:
 *   上下方向の指移動 = ページスクロール
 *
 * ボタンの通常タップはそのまま有効。
 */
body {
    touch-action: pan-y;
}


/*
 * ボタン・リンク類もドラッグ対象にしない。
 */
button,
a {
    -webkit-user-drag: none;
}

