/**
 * 📱 Universal Mobile Responsive Library
 * モバイル対応 + レスポンシブデザインシステム
 * 作成: 秘書鈴原 | 2026-03-04
 */

/* ========== 基本リセット ========== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 
                'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 
                'Noto Color Emoji';
    line-height: 1.6;
}

/* ========== レスポンシブ画像 ========== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========== フレックスボックス ユーティリティ ========== */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-row {
    flex-direction: row;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

/* ========== グリッドシステム ========== */
.grid {
    display: grid;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* ========== コンテナ ========== */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-sm { max-width: 640px; }
.container-md { max-width: 768px; }
.container-lg { max-width: 1024px; }
.container-xl { max-width: 1280px; }
.container-2xl { max-width: 1536px; }

/* ========== スペーシング ========== */
.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }

.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.m-2 { margin: 0.5rem; }
.m-4 { margin: 1rem; }
.m-6 { margin: 1.5rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* ========== テキストユーティリティ ========== */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ========== 表示ユーティリティ ========== */
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.min-h-screen { min-height: 100vh; }

/* ========== ボタン ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* iOS タッチターゲット最小サイズ */
    min-width: 44px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #374151 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #047857 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

/* ========== カード ========== */
.card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 
                0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ========== フォーム要素 ========== */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    min-height: 44px;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ========== レスポンシブブレークポイント ========== */

/* モバイル（デフォルト） */
@media (max-width: 639px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-block {
        display: block !important;
    }
    
    .text-mobile-sm {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }
    
    .p-mobile-2 {
        padding: 0.5rem;
    }
    
    .grid-cols-mobile-1 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .btn-mobile-sm {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* タブレット */
@media (min-width: 640px) {
    .container {
        padding: 0 1rem;
    }
    
    .sm\:hidden { display: none !important; }
    .sm\:block { display: block !important; }
    .sm\:flex { display: flex !important; }
    
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    
    .sm\:text-base { font-size: 1rem; line-height: 1.5rem; }
    .sm\:text-lg { font-size: 1.125rem; line-height: 1.75rem; }
    
    .btn {
        width: auto;
    }
}

/* デスクトップ小 */
@media (min-width: 768px) {
    .md\:hidden { display: none !important; }
    .md\:block { display: block !important; }
    .md\:flex { display: flex !important; }
    
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    
    .md\:text-lg { font-size: 1.125rem; line-height: 1.75rem; }
    .md\:text-xl { font-size: 1.25rem; line-height: 1.75rem; }
    
    .md\:p-6 { padding: 1.5rem; }
    .md\:p-8 { padding: 2rem; }
}

/* デスクトップ大 */
@media (min-width: 1024px) {
    .lg\:hidden { display: none !important; }
    .lg\:block { display: block !important; }
    .lg\:flex { display: flex !important; }
    
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    
    .lg\:text-xl { font-size: 1.25rem; line-height: 1.75rem; }
    .lg\:text-2xl { font-size: 1.5rem; line-height: 2rem; }
    
    .lg\:p-8 { padding: 2rem; }
    .lg\:p-12 { padding: 3rem; }
}

/* ========== 特別なモバイル対応 ========== */

/* タッチデバイス用 */
@media (hover: none) and (pointer: coarse) {
    .card:hover {
        transform: none;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                    0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    
    .btn:hover {
        transform: none;
        box-shadow: none;
    }
}

/* iOS Safari用 */
@supports (-webkit-touch-callout: none) {
    .ios-fix {
        -webkit-appearance: none;
        -webkit-border-radius: 0;
    }
}

/* ========== ダークモード対応 ========== */
@media (prefers-color-scheme: dark) {
    .dark-auto {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .card.dark-auto {
        background-color: #374151;
        color: #f9fafb;
    }
    
    .form-input.dark-auto {
        background-color: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
}

/* ========== アクセシビリティ ========== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* フォーカス表示の改善 */
*:focus-visible {
    outline: 2px solid #3b82f6;
    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: 0;
}