/* Mobile-First Design Optimizations */

/* タッチ操作最適化 */
.touchable {
  cursor: pointer;
  transition: all 0.15s ease-out;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.touchable:hover,
.touchable.touch-active {
  transform: scale(0.98);
  opacity: 0.8;
}

/* タッチターゲットサイズの最適化 */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* モバイルファーストのフォント設定 */
@media (max-width: 768px) {
  body {
    font-size: 16px; /* iOS Safariのズーム防止 */
    line-height: 1.5;
  }
  
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.125rem; }
  
  /* タッチしやすいボタンサイズ */
  .btn, button, .button {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 16px;
  }
  
  /* フォーム要素の最適化 */
  input, textarea, select {
    min-height: 44px;
    font-size: 16px; /* iOS Safariのズーム防止 */
    padding: 12px 16px;
    border-radius: 8px;
  }
  
  /* カード間隔の調整 */
  .card, .blog-card, .forum-card {
    margin-bottom: 12px;
    padding: 16px;
  }
  
  /* ナビゲーションの最適化 */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 8px 0;
    z-index: 50;
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    min-height: 56px;
    color: #6b7280;
    text-decoration: none;
    font-size: 12px;
    transition: color 0.2s;
  }
  
  .mobile-nav-item.active,
  .mobile-nav-item:hover {
    color: #3b82f6;
  }
  
  .mobile-nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
  }
}

/* スワイプ可能要素 */
.swipeable {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.swipeable::-webkit-scrollbar {
  display: none;
}

.swipe-item {
  scroll-snap-align: start;
  flex-shrink: 0;
}

/* Pull-to-refresh */
.pull-to-refresh {
  transform: translateY(-100%);
  transition: transform 0.3s ease-out;
}

.pull-to-refresh.visible {
  transform: translateY(0);
}

/* モバイル専用レイアウト */
@media (max-width: 640px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  
  /* グリッドの調整 */
  .grid-mobile-1 { grid-template-columns: 1fr; }
  .grid-mobile-2 { grid-template-columns: repeat(2, 1fr); }
  
  /* スペーシングの調整 */
  .space-y-mobile > * + * { margin-top: 8px; }
  .space-x-mobile > * + * { margin-left: 8px; }
  
  /* モーダルの調整 */
  .modal {
    margin: 0;
    min-height: 100vh;
    border-radius: 0;
  }
  
  /* ドロップダウンの調整 */
  .dropdown-menu {
    width: 100vw;
    left: 0;
    right: 0;
    margin-left: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* ランドスケープ対応 */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-nav {
    display: none;
  }
  
  .landscape-hidden {
    display: none;
  }
  
  body {
    padding-bottom: 0;
  }
}

/* タブレット対応 */
@media (min-width: 641px) and (max-width: 1024px) {
  .tablet-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .tablet-grid-3 { grid-template-columns: repeat(3, 1fr); }
  
  .tablet-text-sm { font-size: 0.875rem; }
  .tablet-text-base { font-size: 1rem; }
  .tablet-text-lg { font-size: 1.125rem; }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  .mobile-nav {
    background: #1f2937;
    border-top-color: #374151;
  }
  
  .mobile-nav-item {
    color: #9ca3af;
  }
  
  .mobile-nav-item.active,
  .mobile-nav-item:hover {
    color: #60a5fa;
  }
}

/* 高コントラスト対応 */
@media (prefers-contrast: high) {
  .touchable:hover,
  .touchable.touch-active {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }
}

/* モーション設定の考慮 */
@media (prefers-reduced-motion: reduce) {
  .touchable,
  .swipeable,
  .pull-to-refresh {
    transition: none;
    animation: none;
  }
}

/* 安全領域対応 (iOS) */
@supports (padding-top: env(safe-area-inset-top)) {
  .safe-area-top {
    padding-top: env(safe-area-inset-top);
  }
  
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .mobile-nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

/* フローティングアクションボタン */
.fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  border: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.3s ease;
  z-index: 40;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 640px) {
  .fab {
    bottom: 96px; /* モバイルナビの上 */
  }
}

/* スクロール最適化 */
.smooth-scroll {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* 画像最適化 */
@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
  }
  
  .responsive-img {
    width: 100%;
    height: auto;
    object-fit: cover;
  }
}

/* モバイル専用ユーティリティ */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
  
  .mobile-flex {
    display: flex !important;
  }
  
  .mobile-hidden {
    display: none !important;
  }
  
  .mobile-full {
    width: 100% !important;
  }
}
