/**
 * タイポグラフィとモバイル最適化CSS - フェーズ3
 * 文字サイズ、行間、モバイル対応の詳細調整
 */

/* ========================================
   タイポグラフィの階層化
======================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", YuGothic, Meiryo, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: #333;
    font-feature-settings: "palt" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 見出しの階層 */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.4;
    margin-top: 2em;
    margin-bottom: 0.8em;
    color: #1a1a1a;
}

h1 {
    font-size: 2.5em;
    margin-top: 0;
    border-bottom: 3px solid #667eea;
    padding-bottom: 0.5em;
}

h2 {
    font-size: 2em;
    position: relative;
    padding-left: 1em;
}

h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 1.5em;
    background: #667eea;
}

h3 {
    font-size: 1.5em;
    border-left: 3px solid #e91e63;
    padding-left: 0.8em;
}

h4 {
    font-size: 1.25em;
    font-weight: 600;
}

h5 {
    font-size: 1.1em;
    font-weight: 600;
}

h6 {
    font-size: 1em;
    font-weight: 600;
    color: #666;
}

/* 段落 */
p {
    margin-bottom: 1.5em;
    line-height: 1.8;
}

/* リンク */
a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #5a67d8;
    text-decoration: underline;
}

/* 強調 */
strong, b {
    font-weight: 700;
    color: #1a1a1a;
}

em, i {
    font-style: italic;
}

mark {
    background: linear-gradient(transparent 60%, #ffeb3b 60%);
    padding: 0 0.2em;
}

/* コード */
code {
    background: #f4f4f4;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
}

pre {
    background: #f4f4f4;
    padding: 1.5em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 2em 0;
}

pre code {
    background: transparent;
    padding: 0;
}

/* 引用 */
blockquote {
    margin: 2em 0;
    padding: 1em 1.5em;
    border-left: 4px solid #667eea;
    background: #f8f9fa;
    font-style: italic;
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* ========================================
   モバイル最適化
======================================== */
@media (max-width: 768px) {
    /* フォントサイズ調整 */
    body {
        font-size: 15px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    h2 {
        font-size: 1.5em;
    }
    
    h3 {
        font-size: 1.3em;
    }
    
    h4 {
        font-size: 1.15em;
    }
    
    /* 余白調整 */
    .entry-content,
    .page-content,
    .post-content {
        padding: 0 15px;
    }
    
    section,
    .content-section {
        padding: 2em 0;
    }
    
    /* カード・ボックスの余白調整 */
    .card,
    .box,
    .content-box {
        padding: 1em;
        margin: 1em 0;
    }
}

/* スマートフォン縦向き */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.6em;
    }
    
    h2 {
        font-size: 1.3em;
        padding-left: 0.5em;
    }
    
    h3 {
        font-size: 1.15em;
    }
}

/* ========================================
   タッチデバイス最適化
======================================== */
@media (hover: none) and (pointer: coarse) {
    /* タッチ可能な要素のサイズ確保 */
    a,
    button,
    .button,
    .btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* ホバー効果の無効化 */
    .card:hover,
    .box:hover {
        transform: none;
    }
}

/* ========================================
   印刷用スタイル
======================================== */
@media print {
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
    }
    
    h1 {
        font-size: 18pt;
    }
    
    h2 {
        font-size: 16pt;
    }
    
    h3 {
        font-size: 14pt;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
    
    /* 不要な要素を非表示 */
    .cta,
    .button,
    .btn,
    nav,
    .navigation {
        display: none !important;
    }
}

/* ========================================
   アクセシビリティ向上
======================================== */
/* フォーカススタイル */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* スキップリンク */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999999;
}

.skip-link:focus {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 10px;
    background: #667eea;
    color: #fff;
    padding: 1em 2em;
    border-radius: 4px;
    text-decoration: none;
}

/* ========================================
   レスポンシブテーブル
======================================== */
@media (max-width: 768px) {
    table {
        font-size: 0.9em;
    }
    
    table th,
    table td {
        padding: 0.5em;
    }
    
    /* 横スクロール可能なテーブル */
    .table-wrapper,
    .wp-block-table {
        position: relative;
    }
    
    .table-wrapper::after,
    .wp-block-table::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,0,0,0.5);
        color: #fff;
        padding: 0.5em;
        border-radius: 50%;
        pointer-events: none;
        opacity: 0.7;
    }
}

/* ========================================
   画像の最適化
======================================== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loading対応 */
img[loading="lazy"] {
    background: #f0f0f0;
}

/* レスポンシブ画像 */
picture img {
    width: 100%;
    height: auto;
}

/* ========================================
   フォーム要素の最適化
======================================== */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 0.75em;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px; /* iOS zoom防止 */
    transition: border-color 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #667eea;
    outline: none;
}

/* ========================================
   アニメーション最適化
======================================== */
@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-color-scheme: dark) {
    /* ダークモード時のスタイルをここに追加 */
}