/* モバイル最適化とタップターゲットサイズの改善 */

/* タップターゲットのサイズ最適化 - Google推奨の44x44px以上 */
a, button, .btn, [role="button"], input[type="submit"], input[type="button"] {
  min-height: 44px;
  min-width: 44px;
  position: relative;
}

/* 小さなリンクにタップエリアを追加 */
a.small-link::before,
.tag-item::before,
.filter-btn::before {
  content: "";
  position: absolute;
  top: -8px;
  right: -8px;
  bottom: -8px;
  left: -8px;
}

/* サイドバーのリンク */
.tag-item {
  padding: 0.5rem 0.875rem;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.filter-btn {
  padding: 0.6rem 1.2rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 記事カード内のリンク */
.card-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin-top: 0.5rem;
}

/* パンくずリストのリンク */
.breadcrumb-item a {
  display: inline-block;
  padding: 0.375rem 0.5rem;
  margin: -0.375rem -0.5rem;
}

/* ヘッダーの検索ボタン */
#searchForm button {
  min-width: 80px;
  padding: 0.5rem 1rem;
}

/* モバイルでのタッチ最適化 */
@media (max-width: 767.98px) {
  /* タップターゲットをさらに大きく */
  .tag-item {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
  }
  
  .filter-btn {
    font-size: 0.95rem;
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  /* パンくずリストのタップエリア拡大 */
  .breadcrumb-item {
    margin-right: 0.5rem;
  }
  
  .breadcrumb-item a {
    padding: 0.5rem 0.75rem;
    margin: -0.5rem -0.75rem;
  }
  
  /* ヘッダーの最適化 */
  header .fs-4 {
    font-size: 1.5rem !important;
  }
  
  /* 検索フォームの最適化 */
  #searchInput {
    font-size: 16px; /* iOSのズーム防止 */
    padding: 0.75rem;
    min-height: 44px;
  }
  
  /* カード内の要素 */
  .card-title {
    font-size: 1.25rem;
    line-height: 1.4;
  }
  
  .card-link {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    background-color: var(--background-accent);
    border-radius: 8px;
    margin-top: 1rem;
  }
  
  /* 記事ページの最適化 */
  .blog-post {
    padding: var(--spacing-md);
  }
  
  .blog-post h1 {
    font-size: 1.75rem;
    line-height: 1.3;
  }
  
  /* サイドバーの最適化 */
  .sidebar {
    margin-top: 2rem;
  }
  
  .sidebar-section {
    margin-bottom: 2rem;
  }
  
  /* レーティングフィルター */
  .rating-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  /* フッターリンク */
  footer nav a {
    padding: 0.75rem 1rem;
    display: inline-block;
  }
}

/* アクセシビリティ改善 */
a:focus,
button:focus,
.btn:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid #4A90E2;
  outline-offset: 2px;
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
  .filter-btn,
  .tag-item {
    border: 2px solid currentColor;
  }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --background-light: #1a1a1a;
    --background-white: #2a2a2a;
    --background-accent: #3a3a3a;
    --border-color: #404040;
  }
  
  .filter-btn:hover {
    background-color: #5a5a5a;
  }
}

/* パフォーマンス最適化 */
.card-img-top {
  content-visibility: auto;
  contain-intrinsic-size: 200px;
}

/* スクロールパフォーマンス改善 */
.sidebar {
  will-change: transform;
}

/* 画像の遅延読み込み表示 */
img[loading="lazy"] {
  background-color: #f0f0f0;
  background-image: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* フォントの最適化 */
@font-face {
  font-family: 'System Font';
  font-style: normal;
  font-weight: 400;
  src: local('.SFNSText-Light'), local('.HelveticaNeueDeskInterface-Light'), 
       local('.LucidaGrandeUI'), local('Ubuntu Light'), local('Segoe UI Light'), 
       local('Roboto-Light'), local('DroidSans'), local('Tahoma');
}

body {
  font-family: 'System Font', -apple-system, BlinkMacSystemFont, "Segoe UI", 
               Roboto, "Helvetica Neue", Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}