/* ベース(モバイルファースト) */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0 16px 40px;
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'メイリオ', Meiryo, sans-serif;
    color: #222;
    background: #f8fafc;
    line-height: 1.6;
}

.display_none {
    display: none !important;
}

/* ヘッダー・フッター */
.site_header {
    padding: 16px 0;
}

.site_header__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site_header__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: bold;
}

.site_header__link {
    color: inherit;
    text-decoration: none;
}

/* 言語切替UI([IMG-72])。320px幅でも折り返して表示崩れしないようflex-wrapを使う。 */
.locale_switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
}

.locale_switcher__icon {
    margin-right: 2px;
}

.locale_switcher__link {
    /* #666はWCAG AA(通常文字4.5:1以上)を満たす(bg #f8fafcで十分なコントラスト、
       site_footer__navと同じ配色を踏襲)。 */
    color: #666;
    text-decoration: underline;
    padding: 4px 6px;
    border-radius: 4px;
}

.locale_switcher__link:not(:last-child) {
    border-right: 1px solid #e2e8f0;
    padding-right: 8px;
}

/* 現在言語を視覚的に伝える(aria-currentは支援技術向け、[IMG-72])。 */
.locale_switcher__link[aria-current='true'] {
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
}

.locale_switcher__link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* アップロード中は言語切替による未送信データ消失を避けるため無効化する
   (compress.js、[IMG-72]技術的注意点)。 */
.locale_switcher__link[aria-disabled='true'] {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

/* ブランドロゴ([IMG-65]、アイコン+wordmarkの横並び、素材/header.png・footer.png準拠) */
.brand_logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.brand_logo__icon {
    display: block;
    flex-shrink: 0;
}

.brand_logo__text {
    font-weight: 800;
    color: #0f172a;
}

.site_footer {
    margin-top: 40px;
    /* 素材/footer.pngのバー状デザイン(白背景・上部ボーダー)を踏襲。 */
    padding: 24px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.site_footer__bar {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.site_footer__divider {
    display: none;
}

.site_footer__nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

.site_footer__nav a {
    /* #666はWCAG AA(通常文字4.5:1以上)を満たす(bg #fffで約5.7:1、
       [IMG-29]で発見した#888のコントラスト不足を踏襲して回避)。 */
    color: #666;
    text-decoration: underline;
    font-size: 0.85rem;
}

.site_footer__copyright {
    margin: 0;
    color: #666;
    font-size: 0.8rem;
}

/* デスクトップ幅では素材/footer.png通り、区切り線を挟んだ横一列のバーにする。 */
@media (min-width: 640px) {
    .site_footer__bar {
        flex-wrap: nowrap;
        justify-content: flex-start;
    }

    .site_footer__nav {
        flex: 1 1 auto;
    }

    .site_footer__divider {
        display: block;
        width: 1px;
        height: 20px;
        background: #e2e8f0;
        flex-shrink: 0;
    }
}

/* メインコンテンツ */
.main {
    max-width: 640px;
    margin: 0 auto;
}

.hero {
    text-align: center;
    margin-bottom: 24px;
}

.hero__title {
    font-size: 1.6rem;
    margin: 0 0 8px;
}

.hero__description {
    margin: 0;
    color: #555;
    font-size: 0.95rem;
}

/* 圧縮ツール本体 */
.compress_tool {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    padding: 24px 16px;
}

.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

/* 状態1: ドロップゾーン */
.drop_zone {
    width: 100%;
    /* #64748bはWCAG 1.4.11(非テキストコントラスト、3:1以上)を満たす濃さ
       (白背景で約4.76:1、[IMG-21]で#99a3af(約2.56:1)から変更)。 */
    border: 2px dashed #64748b;
    border-radius: 8px;
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.drop_zone--dragover {
    border-color: #2563eb;
    background-color: #eff6ff;
}

.drop_zone__text {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

.drop_zone__or {
    margin: 0;
    /* #666はWCAG AA(通常文字4.5:1以上)を満たす(白背景で約5.74:1、
       [IMG-21]で#999(約2.85:1、axe-coreのcolor-contrast違反)から変更)。 */
    color: #666;
    font-size: 0.85rem;
}

.privacy_note {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* ボタン共通(タップ領域44px以上を確保) */
.btn {
    display: inline-block;
    min-height: 44px;
    padding: 10px 24px;
    border-radius: 6px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
}

.btn:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* 処理中(ZIP作成中等)のdisabled状態を視覚的に判別できるようにする
   ([IMG-99]完了条件)。 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn--primary {
    background: #2563eb;
    color: #fff;
}

.btn--primary:hover,
.btn--primary:focus-visible {
    background: #1d4ed8;
}

.btn--secondary {
    background: #e5e7eb;
    color: #333;
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
    background: #d1d5db;
}

/* 共有ボタン([IMG-66])。[IMG-66]レビューv2対応: 圧縮・ダウンロード等の
   主要CTA(.btn)よりも視覚的に弱いアイコンのみの丸型ボタンにする
   (テキストボタンだと主導線と強さが近く、副次的な共有アクションとしては
   重すぎるという指摘への対応)。タップ領域は他ボタンと同じ44px以上を維持する。 */
.share_buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.share_buttons__heading {
    width: 100%;
    margin: 0;
    font-size: 0.85rem;
    color: #666;
}

.share_buttons__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    border-radius: 50%;
    color: #fff;
}

.share_buttons__link:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* ブランドカラーの丸背景にすることで、テキストなしでも一目でX/Facebookと
   わかるようにする(ユーザー指摘: アイコンの色でわかりやすさが大きく
   変わる)。ホバー・フォーカス時は各ブランドカラーをわずかに暗くする。 */
.share_buttons__link--x {
    background: #000;
}

.share_buttons__link--x:hover,
.share_buttons__link--x:focus-visible {
    background: #272727;
}

.share_buttons__link--facebook {
    background: #1877f2;
}

.share_buttons__link--facebook:hover,
.share_buttons__link--facebook:focus-visible {
    background: #0f5fcc;
}

.share_buttons__icon {
    width: 18px;
    height: 18px;
}

/* 状態2: プレビュー・設定 */
.preview__image {
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
}

.preview__filename,
.preview__filesize {
    margin: 4px 0;
    font-size: 0.9rem;
    color: #555;
}

.quality_setting {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quality_setting legend {
    font-weight: bold;
    margin-bottom: 4px;
}

.quality_setting label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    min-height: 44px;
}

/* 状態3: 処理中・プログレスバー */
.processing__icon {
    display: block;
    margin: 0 auto 8px;
    animation: processing_icon_spin 1.6s linear infinite, processing_icon_fade 1.6s ease-in-out infinite;
}

@keyframes processing_icon_spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes processing_icon_fade {
    0%, 100% {
        opacity: 0.55;
    }
    50% {
        opacity: 1;
    }
}

/* [IMG-65] 前庭障害等への配慮。回転・明滅を止め、静止アイコンのみ表示する。 */
@media (prefers-reduced-motion: reduce) {
    .processing__icon {
        animation: none;
    }
}

.processing__filename {
    font-size: 0.95rem;
    color: #333;
    margin: 0;
    word-break: break-all;
}

.progress_bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress_bar__fill {
    height: 100%;
    background: #2563eb;
    transition: width 0.2s ease-out;
}

.progress_bar__label {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
}

/* 状態4: 結果 */
.result__image {
    max-width: 100%;
    max-height: 240px;
    border-radius: 6px;
}

.result__filename {
    font-size: 0.95rem;
    color: #333;
    margin: 0;
    word-break: break-all;
}

.result__sizes {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result__percent {
    font-size: 1.1rem;
    font-weight: bold;
    /* #166534はWCAG AA(通常文字4.5:1以上)を満たす濃さ(白背景で約7.13:1、
       [IMG-21]で#16a34a(約3.30:1、axe-coreのcolor-contrast違反)から変更)。 */
    color: #166534;
    margin: 0;
}

.result__percent--increased {
    color: #b45309;
}

/* 削減率バッジ([IMG-102])。Apple・Google系の控えめなピル型バッジを意識し、
   彩度を抑えた背景+同系色の濃い文字で、色覚に依存せず符号(+/-)と数値だけでも
   意味が伝わるようにする。単一結果(.result__badge)・一括結果一覧の各行
   (.bulk_item__badge)で共通のvariant命名を使う。 */
.result__badge,
.bulk_item__badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
}

.result__badge--reduced,
.bulk_item__badge--reduced {
    background: #dcfce7;
    color: #166534;
}

.result__badge--unchanged,
.bulk_item__badge--unchanged {
    background: #e5e7eb;
    color: #374151;
}

.result__badge--increased,
.bulk_item__badge--increased {
    background: #fef3c7;
    color: #b45309;
}

.result__badge--unknown,
.bulk_item__badge--unknown {
    background: #e5e7eb;
    color: #6b7280;
}

.result__note {
    font-size: 0.85rem;
    color: #b45309;
    margin: 0;
}

/* 状態5: エラー */
.error__message {
    color: #b91c1c;
    font-size: 0.95rem;
    margin: 0;
}

/* 法的ページ(プライバシーポリシー・利用規約、[IMG-29]・[IMG-30]) */
.legal_page {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    padding: 24px 20px;
    text-align: left;
}

.legal_page__title {
    font-size: 1.4rem;
    margin: 0 0 8px;
}

.legal_page__updated {
    color: #666;
    font-size: 0.85rem;
    margin: 0 0 24px;
}

.legal_page__section {
    margin-bottom: 24px;
}

.legal_page__section h2 {
    font-size: 1.05rem;
    margin: 0 0 8px;
}

.legal_page__section p,
.legal_page__section ul {
    font-size: 0.95rem;
    color: #333;
    margin: 0 0 8px;
}

.legal_page__section ul {
    padding-left: 1.5em;
}

/* 状態6・7: 一括圧縮([IMG-23]、進捗バー等の詳細UIはIMG-24で拡張予定) */
.bulk__count,
.bulk__status {
    margin: 0;
    font-size: 0.95rem;
    color: #333;
}

/* 圧縮結果サマリーカード([IMG-97])。既存の.compress_toolカード(白背景・
   角丸8px)より一段軽い背景色で、結果一覧より前に成果を示す(IMG-106)。 */
.bulk_summary {
    width: 100%;
    box-sizing: border-box;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    text-align: center;
}

.bulk_summary__heading {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: bold;
    /* .result__percentと同じ配色(WCAG AA、[IMG-21]) */
    color: #166534;
}

.bulk_summary__count {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: #333;
}

.bulk_summary__sizes {
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
}

.bulk_summary__percent {
    margin: 0;
    font-size: 1.1rem;
    font-weight: bold;
    color: #166534;
}

/* 全件確定後、プログレスバーの代わりに表示する完了状態([IMG-100])。
   文言自体に記号(✓等)を含めているため、色だけに依存せず状態が伝わる。 */
.bulk_completion_status {
    margin: 0;
    font-size: 1.05rem;
    font-weight: bold;
}

.bulk_completion_status--success {
    /* .result__percentと同じ成功色(WCAG AA、[IMG-21]) */
    color: #166534;
}

.bulk_completion_status--partial {
    /* .result__percent--increasedと同じ配色([IMG-22]) */
    color: #b45309;
}

.bulk_completion_status--failed {
    /* .error__messageと同じ配色 */
    color: #b91c1c;
}

.bulk__file_list,
.bulk__result_list {
    width: 100%;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

/* 結果一覧の開閉見出し([IMG-101])。矢印はaria-expandedの値のみを見て
   回転させ、開閉状態・矢印表示・支援技術への通知が常に一致するようにする。 */
.bulk_result_toggle {
    width: 100%;
}

.bulk_result_toggle__button {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    padding: 8px 4px;
    background: none;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    text-align: left;
    cursor: pointer;
}

.bulk_result_toggle__button:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

.bulk_result_toggle__arrow {
    display: inline-block;
    transition: transform 0.15s;
}

.bulk_result_toggle__button[aria-expanded='false'] .bulk_result_toggle__arrow {
    transform: rotate(-90deg);
}

/* 結果一覧下部のアクション領域([IMG-104]レビューv1 Blocking-1対応)。
   主導線(ZIP/個別ダウンロード)と副導線(別の画像を圧縮する)を1つの領域に
   まとめ、結果一覧の展開/折りたたみに関わらず常に同じ位置で操作できる
   ようにする。 */
.bulk_result_actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

/* 個別結果カード([IMG-98])。ヘッダー(ファイル名+状態)→容量比較→結果→
   操作の順に縦積みし、カードだけで内容が完結して読めるようにする
   (IMG-106の視線順序をカード単位でも踏襲)。 */
.bulk_item {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-align: left;
}

.bulk_item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.bulk_item__name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
    color: #333;
    font-weight: 600;
    /* 長いファイル名でもカードのレイアウトが崩れないようにする
       ([IMG-98]完了条件)。break-allに加えoverflow-wrapでも二重に保証する。 */
    word-break: break-all;
    overflow-wrap: anywhere;
}

.bulk_item__status {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.bulk_item__status_icon {
    width: 18px;
    height: 18px;
    /* .result__percentと同じ成功色(WCAG AA、[IMG-21]) */
    color: #166534;
}

.bulk_item__size,
.bulk_item__sizes,
.bulk_item__status,
.bulk_item__result {
    font-size: 0.85rem;
    color: #555;
}

.bulk_item__sizes {
    white-space: nowrap;
}

/* 容量が増加した場合の強調色(単一フローの.result__percent--increasedと同じ配色、[IMG-22]対応)。 */
.bulk_item__result--increased {
    color: #b45309;
}

.bulk_item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.bulk_item__download,
.bulk_item__retry {
    min-height: 36px;
    padding: 6px 16px;
    font-size: 0.85rem;
}

/* 視覚的には隠すがスクリーンリーダーには伝える([IMG-98]、成功アイコンの
   ラベル用)。標準的なsr-onlyパターン。 */
.visually_hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 一括圧縮のファイルごとの進捗バー([IMG-24]) */
.bulk_item__progress {
    width: 100%;
}

.bulk_item__progress_bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.bulk_item__progress_fill {
    height: 100%;
    background: #2563eb;
    transition: width 0.2s ease-out;
}

/* 広告ユニット([IMG-92])。初期表示時はプレースホルダーのみで高さ0
   (完了条件「初期表示およびファーストビューに広告枠が存在しない」、
   [IMG-93])。圧縮成功後、AdSense.activate()(public/js/adsense.js)が
   <ins>への置き換えと同時に.adsense--activeを付与した時点で初めて
   min-height・marginを与え、広告読み込み前後でのレイアウトシフト(CLS)を
   抑える([docs/adsense-readiness.md]のCLS対策方針)。 */
.adsense {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    box-sizing: border-box;
    text-align: center;
}

.adsense.adsense--active {
    min-height: 100px;
    margin: 24px auto;
}

/* デスクトップ幅での調整 */
@media (min-width: 480px) {
    .adsense.adsense--active {
        margin: 32px auto;
    }
}

@media (min-width: 640px) {
    .adsense.adsense--active {
        margin: 48px auto;
    }
}

/* 開発環境用の広告表示切替ボタン([IMG-92])。他要素のレイアウトに影響しない
   よう固定位置に置く(本番環境では出力自体されない)。 */
.adsense_dev_toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    font-size: 0.8rem;
    min-height: 36px;
    padding: 6px 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

@media (min-width: 480px) {
    .quality_setting {
        flex-direction: row;
        justify-content: center;
        gap: 24px;
    }

    .quality_setting legend {
        width: 100%;
        text-align: center;
    }
}
