/* ==========================================================================
   文字サイズ変更（住民ページ／虎の巻65）
   html の基準 font-size(62.5%=1rem:10px) を段階切替し、rem/em 指定を一括スケール。
   標準では従来と同一（62.5%）。CSSは全て相対単位なので余白も文字と比例して拡大する。
   ========================================================================== */
html.fs-large  { font-size: 75%; }    /* 標準比 +20%（1rem=12px相当） */
html.fs-xlarge { font-size: 87.5%; }  /* 標準比 +40%（1rem=14px相当） */

/* sticky な文字サイズバーの分だけアンカー着地をずらす（エラーサマリの各項目リンク・スキップリンクの
   飛び先が固定バーの裏に隠れないように）。バーは px 実寸なので px 指定。※虎の巻65/66 */
html {
    scroll-padding-top: 56px;
}

/* 文字サイズ変更バー（スクロール追従＝固定） */
.fontsize-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--secondary-color);
    border-bottom: 1px solid var(--border-color);
}
/* バー内部は px 指定＝文字サイズ設定(fs-*)に追従せず常に一定サイズを保つ（虎の巻65）。
   ブラウザズームには追従（px はズームでは拡大する）。 */
.fontsize-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px; /* 全幅バー：左右に約20pxの余白 */
}
/* メインタイトルがスクロールアウトした時だけ、左寄せでフォーム名を表示（控えめにフェード＋微スライド） */
.fontsize-bar-formname {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
    color: var(--text-color);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none; /* 装飾ラベル（aria-hidden）＝操作対象外 */
}
.fontsize-bar.is-scrolled .fontsize-bar-formname {
    opacity: 1;
    transform: none;
}
/* OSの reduced-motion 時：動き(スライド)は止めるが、フェードだけは残す（視差効果の懸念が無い最小演出）。
   共通CSSの広域 transition 抑制(!important)を、この要素に限り上書きする。 */
@media (prefers-reduced-motion: reduce) {
    .fontsize-bar-formname {
        transform: none !important;
        transition: opacity 0.25s ease !important;
    }
}
/* 操作系は常に右寄せ（フォーム名の有無に関わらず） */
.fontsize-bar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex: none;
}
.fontsize-bar-label {
    font-size: 13px;
    color: var(--gray-color);
}
.fontsize-btns {
    display: flex;
    align-items: center;
    gap: 6px;
}
/* ボタンは固定サイズ（高さ一定）。中の文字だけ各段階のサンプルサイズにする。 */
.fontsize-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    min-width: 44px;
    padding: 0 12px;
    font-family: inherit;
    line-height: 1;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--white);
    color: var(--text-color);
    cursor: pointer;
}
.fontsize-btn:hover {
    background-color: var(--primary-color-2);
}
.fontsize-btn.is-active {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}
/* 各ボタンの文字＝そのフォントサイズのサンプル（選択状態に関わらず不変） */
.fontsize-btn[data-fs="normal"] { font-size: 13px; }
.fontsize-btn[data-fs="large"]  { font-size: 16px; }
.fontsize-btn[data-fs="xlarge"] { font-size: 19px; }

/* ==========================================================================
   利用者画面（申込フォーム・修正フォーム）
   ========================================================================== */

/* 利用者画面のフォームは縦積みレイアウト（管理画面の横並びを上書き） */
.form-group {
    display: block;
    padding: 0;
    border-bottom: none;
    margin-bottom: 3.7rem;
}

.form-group > label:first-child {
    width: auto;
    min-width: unset;
    padding-top: 0;
    padding-right: 0;
}

.form-group > .form-hint,
.form-group > .form-error {
    width: auto;
    padding-left: 0;
}

/* フォームアクション（次へ進む・戻るボタン） */
.form-actions {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2rem;
    padding: 2rem;
    margin-top: 4rem;
    background-color: var(--secondary-color);
}
/* 「戻る」は短いので縮ませず改行させない（長い送信ボタンに押し潰されないように） */
.form-actions .btn-secondary {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* 生年月日（年/月/日の3セレクト）。PC/スマホで同じ見た目になるよう flex 行で統一 */
.birthday-input {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.birthday-part {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: nowrap;
}

.birthday-input select {
    width: auto;
    min-width: 6.4rem;
    flex: 0 0 auto;
}

.birthday-input select.birthday-year {
    min-width: 8.8rem;
}

.birthday-sep {
    color: var(--gray-color);
    font-size: 1.3rem;
}

/* レイアウト */
.consumer-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.consumer-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* フォームヘッダー */
.form-header {
    text-align: center;
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid var(--primary-color);
}

.form-title {
    font-size: 2.8rem;
    margin-bottom: 2rem;
}

.consent-title {
    font-size: 2.2rem;
    margin-bottom: 1.2rem;
}

.merchant-name {
    font-size: 1.4rem;
    color: var(--gray-color);
    text-align: left;
}

.badge-edit-request {
    display: inline-block;
    font-size: 1.4rem;
    font-weight: normal;
    padding: 0.4rem 1.2rem;
    background-color: var(--error-color);
    color: var(--white);
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 0.8rem;
}

/* ==========================================================================
   プログレスステッパー（丸＋接続線／虎の巻65）
   入力済＝ブランド背景＋白チェック／入力中＝ブランド背景＋白番号／
   未入力＝白背景＋ブランド枠・文字。ラベルはリボン内に持たず、カレントのタイトルのみ下にセンター表示。
   ========================================================================== */

.progress-bar {
    display: flex;
    align-items: center;
    justify-content: center; /* 少数ステップ時は中央にまとめる（全幅に間延びさせない） */
    margin-bottom: 5.2rem;
}

/* 各ステップは上限幅（円間隔）を一定に保ち、収まらない時だけ縮む。
   ＝4〜9ステップまで、間隔の統一感を保ちつつコンテナ内に収まる（虎の巻65）。 */
.progress-step {
    flex: 0 1 10rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    position: relative;
}

/* 接続線：前の円の中心→現在の円の中心（円の背面に敷く）。
   translateY(-50%) は 1px 線が半ピクセル境界にまたがり滲むため使わず、top: 50% のみで配置（中心から0.5px下＝実質中央）。 */
.progress-step:not(:first-child)::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -50%;
    width: 100%;
    height: 1px;
    background-color: var(--border-color);
}

/* 入力済／入力中に至る線はブランドカラー（通過済みを表す） */
.progress-step.completed::before,
.progress-step.active::before {
    background-color: var(--primary-color);
}

/* 円（未入力の既定）＝白背景・灰色の枠・灰色の文字 */
.step-number {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    height: 3.2rem;
    box-sizing: border-box;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: var(--white);
    color: var(--gray-color);
    font-size: 1.4rem;
    line-height: 1;
}

/* 入力中カレント＝ブランド背景・白文字（現在地を一番目立たせる） */
.progress-step.active .step-number {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--white);
}

/* 入力済＝白背景・ブランド枠・ブランドカラーのチェック（番号は隠す） */
.progress-step.completed .step-number {
    background-color: var(--white);
    border-color: var(--primary-color);
    color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232448a0' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.6rem;
}

/* ラベルはステッパー内に表示しない（カレントのタイトルのみ下にセンター表示） */
.step-label {
    display: none;
}

/* カレントのタイトル（センター表示）。円が現在地を示すので文言はタイトルのみ。
   SR には位置が伝わるよう「ステップ N」を視覚的に隠して読み上げさせる。 */
.progress-current {
    margin: 0 0 3rem;
    text-align: center;
    font-size: 1.5rem;
    color: var(--text-color);
    line-height: 1.5;
}

/* ==========================================================================
   ステップヘッダー
   ========================================================================== */

.step-header {
    padding: 0 0 3rem 0;
    margin-bottom: 3rem;
    border-bottom: 1px solid #ccc;
}

.step-header h2 {
    margin: 0;
    font-size: 2.4rem;
    letter-spacing: 0.03em;
}

.step-header .step-description {
    margin-top: 1rem;
    padding: 0;
    background: none;
    border-radius: 0;
    color: #5a6473;
    font-size: 1.4rem;
    line-height: 1.7;
}

.step-header-note {
    font-size: 1.2rem;
    color: var(--gray-color);
}

.step-description {
    padding: 1rem 1.4rem;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    color: var(--gray-color);
    font-size: 1.4rem;
    line-height: 1.8;
}

/* ==========================================================================
   フォーム入力（利用者側）
   ========================================================================== */

.form-section {
    background-color: var(--white);
    border-radius: 8px;
    padding: 3rem;
    margin-bottom: 3rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.section-title {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--secondary-color);
}

.section-description {
    color: var(--gray-color);
    margin-bottom: 2rem;
    font-size: 1.4rem;
}

/* いずれか必須グループの目印・注記（通常項目・繰り返しの組の中の両方。住民の申込・修正で共用） */
.form-label .form-anyreq-label { font-size: 55%; font-weight: 400; color: var(--error-color, #ca5662); vertical-align: middle; position: relative; top: -4px; left: -1px; }
.js-anyreq-status { display: block; margin-top: 4px; color: inherit; }
/* 満たした（いずれかに入力あり）：緑のチェックと「入力済み」。色だけに頼らず、記号と文字でも伝える */
.js-anyreq-status.is-ok { color: var(--success-color, #4ba861); }
.js-anyreq-status.is-ok::before {
    /* 緑の丸に白いチェック（フォントに頼らず図で描く＝どの端末でも同じ見え方） */
    content: ""; display: inline-block; width: 1.25em; height: 1.25em; margin-right: 0.35em; vertical-align: -0.25em;
    background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='10' fill='%234ba861'/%3E%3Cpath d='M5.5 10.5l3 3 6-6.5' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.js-anyreq-status.is-ok::after { content: "入力済み"; margin-left: 0.6em; }

/* ==========================================================================
   繰り返し入力グループ（複数児童 等）※虎の巻66
   細い罫線でインスタンスを1組ずつ区切る。太字は使わずトンマナを維持。
   ========================================================================== */

.field-group {
    margin: 2.4rem 0 3rem;
}

/* JSクローン用テンプレートは常に不可視（modernは<template>で既定非表示だが、
   IE11等の未対応ブラウザでは通常要素扱いになり空の幻インスタンスが見えるため明示的に隠す）。※虎の巻66 */
.field-group-template {
    display: none !important;
}

.field-group-header {
    margin-bottom: 1.4rem;
}

.field-group-title {
    margin: 0;
    font-size: 1.7rem;
    font-weight: normal;
    color: var(--text-color);
    letter-spacing: 0.02em;
}

.field-group-desc {
    margin: 0.6rem 0 0;
    font-size: 1.3rem;
    line-height: 1.7;
    color: var(--gray-color);
}

/* 1インスタンス（1組）＝細い罫線のカード */
.field-group-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.8rem 2rem 0.6rem;
    margin-bottom: 1.4rem;
    background-color: var(--white);
}

.field-group-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 4.2rem;
    padding: 1rem 0 2.4rem 0;
    border-bottom: 1px solid var(--border-color);
}

.field-group-item-title {
    font-size: 1.4rem;
    color: var(--text-color);
}

/* 「利用児童 2」の連番。色は付けずタイトルと同じ体裁（半角スペース＋半角数字）。 */
.field-group-item-num {
    color: inherit;
    font-size: inherit;
}

.field-group-actions {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-top: 0.4rem;
}

.field-group-add {
    /* .btn を併用。単独指定でも破綻しないよう最低限の見た目を確保 */
    white-space: nowrap;
}

.field-group-limit {
    font-size: 1.2rem;
    color: var(--gray-color);
}

/* ==========================================================================
   同意画面
   ========================================================================== */

.consent-content {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2rem;
    max-height: 30rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.consent-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.8;
}

.consent-content h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 1.6rem;
}

.consent-content h3 {
    font-size: 1.6rem;
    color: var(--text-color);
    margin: 1.6rem 0 0.8rem;
}

.consent-content p {
    margin-bottom: 1.2rem;
    line-height: 1.8;
}

.consent-content ul {
    margin: 1.2rem 0;
    padding-left: 2.4rem;
}

.consent-content li {
    margin-bottom: 0.8rem;
}

/* 同意チェックボックスの配置（デザインは common.css の .checkbox-label を使用） */
.consent-action {
    text-align: center;
}

.consent-action .checkbox-label {
    display: inline-flex;
    white-space: nowrap;
}

/* ==========================================================================
   確認画面
   ========================================================================== */

.confirm-section {
    background-color: var(--white);
    border-radius: 8px;
    padding: 3rem;
    margin-bottom: 2rem;
}

.confirm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 2.4rem;
}
/* タイトルは左寄せで可変幅（長ければ折り返す）、ボタンは縮まず右に固定 */
.confirm-section-header h3 {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    text-align: left;
    word-break: break-word;
}
.confirm-section-header .btn {
    flex: none;
}

.confirm-section h3 {
    font-size: 2rem;
}

.confirm-section th {
    width: 50%;
}

.confirm-row {
    display: flex;
    padding: 1.6rem 0;
    border-bottom: 1px solid var(--border-color);
}

.confirm-row:last-child {
    border-bottom: none;
}

.confirm-label {
    flex: 0 0 200px;
    color: var(--gray-color);
}

.confirm-value {
    flex: 1;
    color: var(--text-color);
}

.confirm-tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
}

.confirm-tag {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1.3rem;
    line-height: 1.5;
    width: fit-content;
}

/* 繰り返しグループ（複数児童等）のインスタンス見出し「申込科目 1」等。
   少し大きめで見やすく＋太字にはしない。モバイルの th 縮小(1.2rem)より優先させるため specificity を上げる。 */
.confirm-section table.table tr.confirm-group-heading th {
    font-size: 1.6rem;
    font-weight: normal;
}

/* 繰り返しグループ（複数児童等）のインスタンス見出し。2件目以降は上に間隔を空けて区切る */
.confirm-group-heading ~ .confirm-group-heading th {
    padding-top: 2.8rem;
}

/* ==========================================================================
   完了画面
   ========================================================================== */

.complete-icon {
    text-align: center;
    font-size: 7.2rem;
    color: var(--success-color);
}

.complete-message {
    text-align: center;
    margin-bottom: 4rem;
}

.complete-message h1 {
    font-size: 2.8rem;
    color: var(--primary-color);
    margin-bottom: 1.6rem;
}

.complete-message p {
    font-size: 1.6rem;
    color: var(--gray-color);
    line-height: 1.8;
}

/* 完了画面の受付番号：見出しはバッジ（common.css の .badge-light）、番号との間を少しあける */
.application-number-box .label {
    margin-bottom: 6px;
}

.complete-flow-wrapper {
    display: flex;
    justify-content: center;
}

.complete-flow-wrapper .complete-flow-box {
    max-width: 480px;
    width: 100%;
    text-align: left;
}

/* ボタングループ */
.form-buttons {
    display: flex;
    gap: 1.6rem;
    justify-content: center;
    margin-top: 4rem;
}

.btn-back {
    background-color: var(--white);
    color: var(--gray-color);
    border: 1px solid var(--border-color);
}

.btn-back:hover {
    background-color: var(--background-color);
}

/* 文面のみ（description）フィールド */
.description-content {
    padding: 1.4rem 1.6rem;
    background: #f0ff001f;
    border: 3px solid #ffe0001f;
    border-radius: 6px;
    color: #00000094;
    font-size: 1.3rem;
}

.description-title {
    font-size: 1.6rem;
    margin-bottom: 0.8rem;
}

.description-content pre {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ==========================================================================
   デバッグエリア（NTTエラー戻りモック等。本番非表示）
   ========================================================================== */

.debug-area {
    border: 2px dashed var(--warning-color);
    background-color: #fffdf5;
}

.debug-area .card-header h2 {
    font-size: 1.6rem;
    color: var(--warning-color);
}

.debug-error-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1.2rem;
}

.debug-error-buttons .btn {
    padding: 0.6rem 1.2rem;
    font-size: 1.2rem;
}

/* 確認画面でエラー戻りした項目行の強調 */
.confirm-section tr.js-confirm-err-row > th,
.confirm-section tr.js-confirm-err-row > td {
    background-color: #fff3b0;
    border-left: 3px solid var(--error-color);
}

/* ==========================================================================
   レスポンシブ（利用者画面）
   ========================================================================== */

@media (max-width: 768px) {
    .radio-group,
    .checkbox-group {
        grid-template-columns: 1fr;
    }

    /* スマホ：文字サイズバーが窮屈になるので「文字サイズ」ラベルを隠す
       （標準/大/特大ボタン自体がサンプル表示で意味が伝わる）。 */
    .fontsize-bar-label {
        display: none;
    }
    /* スマホ：フォーム名は省略（…）せず折り返して全文表示。小さめ＋行間詰めで、
       2行になってもボタン高さ内に収まる。 */
    .fontsize-bar-formname {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 13px;
        line-height: 1.3;
    }
    /* スマホ：文字サイズボタンを一回り小さく（サンプル文字・寸法とも縮小） */
    .fontsize-btns {
        gap: 5px;
    }
    .fontsize-btn {
        height: 30px;
        min-width: 36px;
        padding: 0 8px;
    }
    .fontsize-btn[data-fs="normal"] { font-size: 12px; }
    .fontsize-btn[data-fs="large"]  { font-size: 14px; }
    .fontsize-btn[data-fs="xlarge"] { font-size: 16px; }


    .consumer-form {
        padding: 2rem 0;
    }

    .form-section {
        border-radius: 0;
        padding: 2rem 1.6rem;
    }

    .confirm-section {
        border-radius: 0;
        padding: 2rem 1.6rem;
    }

    .confirm-section table.table th,
    .confirm-section table.table td {
        display: block;
        width: 100%;
        padding: 0.6rem 0;
        border: none;
        text-align: left;
    }

    .confirm-section table.table th {
        font-size: 1.2rem;
        color: var(--gray-color);
        padding-bottom: 0.4rem;
    }

    .confirm-section table.table td {
        font-size: 1.4rem;
        padding-top: 0.4rem;
        word-break: break-word;
    }

    .confirm-row {
        flex-direction: column;
        gap: 0.8rem;
    }

    .confirm-label {
        flex: none;
    }

    .form-buttons {
        flex-direction: column;
    }

    .form-buttons .btn {
        width: 100%;
    }
}

/* ===== 修正確認の行状態（旧 edit_confirm.php のインライン style から移設） ===== */
.row-changed {
    background-color: #fffde7; /* 変更あり行のハイライト */
}
.row-disabled {
    opacity: 0.5; /* 編集対象外（修正不可）行 */
}

/* 完了画面：関連フォーム（レコメンド）。PC/スマホとも2列。各セルはボタン上・説明下。 */
.recommendation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem 1.6rem;
    margin-top: 0.8rem;
}
.recommendation-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0;
}
.recommendation-item .btn {
    width: 100%;
    min-height: 4.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: normal; /* 長い科目名でも折り返す */
    text-align: center;
}
.recommendation-desc {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--gray-color, #6b7280);
}
