/**
 * レスポンシブスタイル
 * モバイルファースト設計の追加調整
 * 
 * @package SUGO_Japan_Theme
 */

/* ========================================
   ベース（モバイル）: 0-767px
   既にstyle.cssで定義済み
======================================== */

/* ========================================
   タブレット: 768px-1023px
======================================== */
@media (min-width: 768px) {
    /* コンテナ */
    .container {
        max-width: 720px;
    }
    
    /* タイポグラフィ */
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 2rem;
    }
    
    h3 {
        font-size: 1.75rem;
    }
    
    /* ヘッダー */
    .site-header {
        padding: var(--spacing-lg) 0;
    }
    
    /* ナビゲーション */
    .main-nav {
        display: flex !important;
    }
    
    .menu-toggle {
        display: none;
    }
    
    /* グリッド */
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* カード */
    .card-body {
        padding: var(--spacing-xl);
    }
    
    /* 記事コンテンツ */
    .article-content {
        font-size: 1.1rem;
    }
    
    /* サイドバー付きレイアウト */
    .content-with-sidebar {
        display: grid;
        grid-template-columns: 1fr 300px;
        gap: var(--spacing-2xl);
    }
    
    /* フッター */
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   デスクトップ小: 1024px-1279px
======================================== */
@media (min-width: 1024px) {
    /* コンテナ */
    .container {
        max-width: 960px;
    }
    
    /* タイポグラフィ */
    h1 {
        font-size: 3rem;
    }
    
    h2 {
        font-size: 2.25rem;
    }
    
    h3 {
        font-size: 1.875rem;
    }
    
    /* グリッド */
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* サイドバー */
    .content-with-sidebar {
        grid-template-columns: 1fr 350px;
    }
    
    /* フッター */
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* ホバーエフェクト有効化 */
    .card:hover {
        transform: translateY(-8px);
    }
}

/* ========================================
   デスクトップ大: 1280px以上
======================================== */
@media (min-width: 1280px) {
    /* コンテナ */
    .container {
        max-width: 1200px;
    }
    
    /* タイポグラフィ */
    h1 {
        font-size: 3.5rem;
    }
    
    /* フッター */
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========================================
   超ワイド: 1920px以上
======================================== */
@media (min-width: 1920px) {
    .container {
        max-width: 1400px;
    }
    
    html {
        font-size: 19px;
    }
}

/* ========================================
   モバイル詳細調整
======================================== */
@media (max-width: 767px) {
    /* ヘッダー */
    .site-header {
        padding: var(--spacing-md) 0;
    }
    
    .site-logo img {
        max-height: 35px;
    }
    
    /* ハンバーガーメニュー */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--white);
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
        z-index: 9999;
        overflow-y: auto;
    }
    
    .mobile-menu.active {
        left: 0;
    }
    
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 9998;
    }
    
    .mobile-menu-overlay.active {
        opacity: 1;
        pointer-events: all;
    }
    
    /* ナビゲーション */
    .main-nav ul {
        flex-direction: column;
        gap: 0;
    }
    
    .main-nav li {
        border-bottom: 1px solid var(--gray);
    }
    
    .main-nav a {
        display: block;
        padding: var(--spacing-md);
    }
    
    /* ボタン */
    .btn {
        width: 100%;
        display: block;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    /* グリッド */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    /* カード */
    .card-image {
        height: 200px;
    }
    
    /* テーブル */
    table {
        font-size: 0.85rem;
    }
    
    table th,
    table td {
        padding: var(--spacing-sm);
    }
    
    /* フォーム */
    input,
    textarea,
    select {
        font-size: 16px; /* iOS zoom対策 */
    }
    
    /* セクション */
    .section {
        padding: var(--spacing-xl) 0;
    }
    
    /* ヒーローセクション */
    .hero-section {
        padding: var(--spacing-xl) 0;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    /* 記事内容 */
    .article-content {
        font-size: 1rem;
    }
    
    .article-content img {
        margin: var(--spacing-md) -16px;
        max-width: calc(100% + 32px);
        width: calc(100% + 32px);
        border-radius: 0;
    }
    
    /* サイドバー */
    .sidebar {
        margin-top: var(--spacing-lg);
    }
    
    /* フッター */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-xl);
    }
    
    /* ページネーション */
    .pagination {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    
    .pagination a,
    .pagination span {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* モーダル */
    .modal-content {
        width: 95%;
        margin: var(--spacing-md);
    }
    
    /* 固定要素 */
    .page-top {
        bottom: 60px;
        right: 16px;
        width: 45px;
        height: 45px;
    }
}

/* ========================================
   タブレット横向き: 768px-1023px
======================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 0 var(--spacing-lg);
    }
    
    .content-with-sidebar {
        grid-template-columns: 1fr 280px;
    }
}

/* ========================================
   プリント用スタイル
======================================== */
@media print {
    /* 不要な要素を非表示 */
    .site-header,
    .main-nav,
    .sidebar,
    .footer,
    .page-top,
    .share-buttons,
    .related-posts,
    .comments {
        display: none !important;
    }
    
    /* ページ設定 */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    /* リンク */
    a {
        color: #000;
        text-decoration: underline;
    }
    
    /* 画像 */
    img {
        max-width: 100%;
        page-break-inside: avoid;
    }
    
    /* 見出し */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    /* ページブレイク */
    .page-break {
        page-break-after: always;
    }
}

/* ========================================
   ランドスケープモード（横向き）
======================================== */
@media (max-width: 767px) and (orientation: landscape) {
    .hero-section {
        padding: var(--spacing-lg) 0;
    }
    
    .section {
        padding: var(--spacing-lg) 0;
    }
}

/* ========================================
   高DPI（Retina）ディスプレイ
======================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 高解像度用の調整 */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ========================================
   ダークモード対応（オプション）
======================================== */
@media (prefers-color-scheme: dark) {
    /* ダークモード時のスタイル調整 */
    /* 必要に応じて実装 */
}

/* ========================================
   コントラスト調整
======================================== */
@media (prefers-contrast: high) {
    /* ハイコントラストモード */
    body {
        background: #fff;
        color: #000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* ========================================
   タッチデバイス最適化
======================================== */
@media (hover: none) and (pointer: coarse) {
    /* タップターゲットサイズを大きく */
    .btn,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* ホバーエフェクトを無効化 */
    .card:hover,
    .btn:hover {
        transform: none;
    }
    
    /* タップハイライトカラー */
    * {
        -webkit-tap-highlight-color: rgba(255, 107, 157, 0.2);
    }
}

/* ========================================
   フレキシブルイメージ
======================================== */
img,
picture,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   アスペクト比の維持
======================================== */
.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4 / 3;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
}

/* 古いブラウザ用のフォールバック */
@supports not (aspect-ratio: 1 / 1) {
    .aspect-ratio-16-9 {
        padding-bottom: 56.25%;
        position: relative;
    }
    
    .aspect-ratio-16-9 > * {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* ========================================
   スクロールバーのカスタマイズ（Webkit）
======================================== */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 10px;
    }
    
    ::-webkit-scrollbar-track {
        background: var(--light-gray);
    }
    
    ::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 5px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary-dark);
    }
}

/* ========================================
   Safari iOS対策
======================================== */
@supports (-webkit-touch-callout: none) {
    /* iOSのバウンススクロール対策 */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 100vh問題の対策 */
    .full-height {
        height: -webkit-fill-available;
    }
}