/**
 * アクセシビリティ強化CSS
 * WCAG 2.1 AAA準拠を目指した実装
 */

/* ========================================
   スキップリンク
   ======================================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary, #2C7A7B);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 0.5rem 0;
    z-index: 10000;
    transition: top 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #F6AD55;
    outline-offset: 2px;
}

/* ========================================
   フォーカスインジケーター強化
   ======================================== */

/* 全てのフォーカス可能要素 */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
[tabindex]:focus {
    outline: 3px solid #F6AD55;
    outline-offset: 2px;
    transition: outline 0.2s ease;
}

/* ボタンのフォーカス */
button:focus,
.btn:focus,
.btn-modern:focus,
.btn-primary:focus,
.btn-secondary:focus {
    outline: 3px solid #F6AD55;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(246, 173, 85, 0.2);
}

/* リンクのフォーカス */
a:focus {
    background-color: rgba(246, 173, 85, 0.1);
    border-radius: 2px;
}

/* ナビゲーションリンクのフォーカス */
nav a:focus {
    background-color: rgba(246, 173, 85, 0.15);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem;
}

/* ========================================
   キーボードナビゲーション表示
   ======================================== */

/* マウス操作時はアウトラインを非表示（キーボード操作時のみ表示） */
body:not(.user-is-tabbing) *:focus {
    outline: none;
}

body.user-is-tabbing *:focus {
    outline: 3px solid #F6AD55;
    outline-offset: 2px;
}

/* ========================================
   スクリーンリーダー専用テキスト
   ======================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* フォーカス時は表示 */
.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ========================================
   コントラスト比の向上
   ======================================== */

/* リンクテキストのコントラスト強化 */
a {
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

a:hover,
a:focus {
    text-decoration-thickness: 3px;
}

/* ========================================
   フォームのアクセシビリティ
   ======================================== */

/* 必須フィールドの視覚的表示 */
input:required,
textarea:required,
select:required {
    border-left: 3px solid #F6AD55;
}

/* エラー状態 */
input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
    border-color: #DC2626;
    border-width: 2px;
}

input:invalid:not(:placeholder-shown):focus,
textarea:invalid:not(:placeholder-shown):focus {
    outline-color: #DC2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* 成功状態 */
input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
    border-left-color: #059669;
}

/* ラベルとフィールドの関連性強化 */
label {
    cursor: pointer;
    user-select: none;
}

label:hover {
    color: var(--color-primary, #2C7A7B);
}

/* ========================================
   モーション削減設定
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   ハイコントラストモード対応
   ======================================== */
@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }

    a,
    button {
        text-decoration: underline;
        text-decoration-thickness: 2px;
    }

    :focus {
        outline-width: 4px !important;
    }
}

/* ========================================
   ダークモード対応（基本）
   ======================================== */
@media (prefers-color-scheme: dark) {
    .skip-link {
        background: #1A202C;
        color: #F7FAFC;
    }

    a:focus {
        background-color: rgba(246, 173, 85, 0.25);
    }
}

/* ========================================
   タッチターゲットサイズの確保
   ======================================== */

/* 全てのクリック可能要素は最低44x44pxを確保（WCAG 2.1 Level AAA） */
@media (max-width: 768px) {
    button,
    a,
    input[type="button"],
    input[type="submit"],
    input[type="reset"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* アイコンボタン */
    .icon-button,
    .hamburger,
    .mobile-menu-close {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem;
    }
}

/* ========================================
   読みやすさの向上
   ======================================== */

/* 行間の最適化 */
p,
li,
td,
th {
    line-height: 1.7;
}

/* 段落の間隔 */
p + p {
    margin-top: 1em;
}

/* リストの読みやすさ */
ul,
ol {
    padding-left: 2em;
}

li + li {
    margin-top: 0.5em;
}

/* ========================================
   ARIA Live Regionのスタイル
   ======================================== */
[role="alert"],
[role="status"],
[aria-live] {
    border-left: 4px solid #F6AD55;
    padding: 1rem;
    margin: 1rem 0;
    background-color: rgba(246, 173, 85, 0.1);
    border-radius: 4px;
}

[role="alert"] {
    border-left-color: #DC2626;
    background-color: rgba(220, 38, 38, 0.1);
}

/* ========================================
   プリントスタイル（アクセシビリティ）
   ======================================== */
@media print {
    /* URLを表示 */
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        font-weight: normal;
    }

    /* 不要な要素を非表示 */
    .skip-link,
    .mobile-cta,
    .scroll-to-top,
    nav,
    footer {
        display: none;
    }

    /* コントラストを最大化 */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}
