/**
 * コアウェブバイタル最適化用CSS
 * LCP, FID, CLS, INPの各指標を改善するための共通スタイル
 */

/* ===== CLS対策 ===== */
/* 画像のレイアウトシフト防止 */
img {
  max-width: 100%;
  height: auto;
}

/* 明示的なサイズが指定されていない画像のために空間を確保 */
img:not([width]):not([height]) {
  aspect-ratio: 1;
  contain: size;
}

/* フォント読み込み中のレイアウトシフト防止 */
.fonts-loading {
  font-display: swap;
}

.fonts-loaded {
  font-display: optional;
}

/* ===== LCP対策 ===== */
/* フォント表示の最適化（フォント自体はHTMLのlinkタグで読み込む） */
.yuji-boku {
  font-family: 'Yuji Boku', serif;
  font-display: swap;
}

/* フォント読み込み状態に基づく表示調整 */
html.fonts-loading {
  font-display: swap;
}

html.fonts-loaded {
  font-display: optional;
}

/* 明示的なコンテンツサイズの設定 */
.container, main, .content-area {
  width: 100%;
  box-sizing: border-box;
}

/* スケルトンスクリーン（コンテンツ読み込み中の表示） */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

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

/* ===== INP対策 ===== */
/* タッチ操作の最適化 */
a, button, [role="button"], .action-btn, input[type="submit"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* アニメーションの最適化 */
.animate {
  will-change: transform;
  transition: transform 0.2s;
}

/* ホバー・アクティブ状態の最適化 */
button:hover, .action-btn:hover, a:hover {
  transform: translateY(-2px);
}

button:active, .action-btn:active, a:active {
  transform: translateY(1px);
}

/* 低スペックデバイス向けアニメーション軽減 */
@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;
  }
  
  .seasonal-decoration {
    display: none;
  }
}

/* ===== リソース優先度の設定 ===== */
/* 重要なコンテンツ */
.critical-content {
  content-visibility: auto;
  contain-intrinsic-size: 500px;
}

/* 非重要なコンテンツの遅延読み込み */
.non-critical {
  content-visibility: auto;
  contain-intrinsic-size: 100px;
}

/* フォールバック：非表示コンテンツ */
.hidden {
  display: none !important;
} 