/* ==========================================================================
   ダウンロード機能専用CSS - TheGlowRad Blog
   ========================================================================== */

/* ベースカード */
.download-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  margin: 24px 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 2px solid #dee2e6;
  border-radius: 16px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.download-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #007bff, #6610f2, #6f42c1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.download-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 123, 255, 0.15);
  border-color: #007bff;
}

.download-card:hover::before {
  opacity: 1;
}

/* 注目ファイル */
.download-card--featured {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  border-color: #f39c12;
  position: relative;
}

.download-card--featured::before {
  background: linear-gradient(90deg, #f39c12, #e67e22, #d35400);
  opacity: 1;
}

.download-card--featured::after {
  content: '🔥 注目';
  position: absolute;
  top: -2px;
  right: 20px;
  background: #e67e22;
  color: white;
  padding: 6px 12px;
  border-radius: 0 0 8px 8px;
  font-size: 0.8rem;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.3);
}

/* ファイルアイコン */
.download-icon {
  flex-shrink: 0;
  position: relative;
}

.file-icon {
  display: inline-block;
  font-size: 3.5rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  transition: transform 0.3s ease;
}

.download-card:hover .file-icon {
  transform: scale(1.1) rotate(5deg);
}

/* ファイル情報エリア */
.download-info {
  flex: 1;
  min-width: 0;
}

.download-title {
  margin: 0 0 8px 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: #2c3e50;
  line-height: 1.3;
}

.download-description {
  margin: 0 0 12px 0;
  color: #6c757d;
  font-size: 0.95rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.download-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
}

.download-meta span {
  padding: 4px 8px;
  background: rgba(0,123,255,0.1);
  color: #0056b3;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.file-name {
  background: rgba(40,167,69,0.1) !important;
  color: #155724 !important;
}

.file-size {
  background: rgba(255,193,7,0.1) !important;
  color: #856404 !important;
}

.file-version {
  background: rgba(111,66,193,0.1) !important;
  color: #6f42c1 !important;
}

.file-updated {
  background: rgba(220,53,69,0.1) !important;
  color: #721c24 !important;
}

/* プレビューエリア */
.download-preview {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  transition: transform 0.3s ease;
}

.download-preview:hover {
  transform: scale(1.05);
}

.download-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* アクションボタン */
.download-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 140px;
  position: relative;
  overflow: hidden;
}

.download-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.download-btn:active::before {
  width: 300px;
  height: 300px;
}

.download-btn.primary {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.download-btn.primary:hover {
  background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,123,255,0.4);
  color: white;
  text-decoration: none;
}

.download-btn.secondary {
  background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
  color: white;
}

.download-btn.secondary:hover {
  background: linear-gradient(135deg, #545b62 0%, #3a3e42 100%);
  transform: translateY(-1px);
  color: white;
  text-decoration: none;
}

/* ダウンロード統計 */
.download-stats {
  position: absolute;
  top: 12px;
  right: 12px;
  text-align: center;
  font-size: 0.75rem;
  color: #6c757d;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.download-count {
  display: block;
  font-size: 1.2rem;
  font-weight: bold;
  color: #007bff;
  margin-bottom: 2px;
}

.download-label {
  font-size: 0.7rem;
  color: #6c757d;
}

/* ファイルギャラリー */
.file-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
  margin: 32px 0;
}

.file-gallery .download-card {
  margin: 0;
}

.gallery-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 3px solid #007bff;
}

/* ローディング状態 */
.download-card.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.download-card.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* エラー状態 */
.download-card.error {
  border-color: #dc3545;
  background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
}

.download-card.error .download-title {
  color: #721c24;
}

/* 成功状態 */
.download-card.success .download-btn.primary {
  background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.download-card.success .download-btn.primary .download-text::before {
  content: '✅ ';
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .download-card {
    flex-direction: column;
    text-align: center;
    padding: 20px;
    gap: 16px;
  }
  
  .download-actions {
    flex-direction: row;
    width: 100%;
    gap: 12px;
  }
  
  .download-btn {
    flex: 1;
    min-width: auto;
    padding: 10px 16px;
  }
  
  .download-preview {
    width: 100%;
    height: 120px;
  }
  
  .download-meta {
    justify-content: center;
  }

  .file-gallery {
    grid-template-columns: 1fr;
  }

  .download-stats {
    position: relative;
    top: auto;
    right: auto;
    margin-top: 10px;
    align-self: center;
  }

  .file-icon {
    font-size: 2.5rem;
  }
  
  .download-title {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .download-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .download-btn {
    width: 100%;
  }

  .download-card {
    padding: 16px;
    margin: 16px 0;
  }

  .download-meta {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  .download-card {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-color: #4a5568;
    color: #e2e8f0;
  }
  
  .download-title {
    color: #f7fafc;
  }
  
  .download-description {
    color: #a0aec0;
  }
  
  .download-preview {
    background: #2d3748;
    border-color: #4a5568;
  }

  .download-stats {
    background: rgba(45, 55, 72, 0.9);
    border-color: #4a5568;
  }

  .download-card--featured {
    background: linear-gradient(135deg, #744210 0%, #975a16 100%);
    border-color: #d69e2e;
  }
}

/* アニメーション */
@keyframes downloadPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.download-card:active {
  animation: downloadPulse 0.3s ease;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.download-card {
  animation: slideInUp 0.6s ease forwards;
}

/* カスタムスクロールバー */
.download-card::-webkit-scrollbar {
  width: 8px;
}

.download-card::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.download-card::-webkit-scrollbar-thumb {
  background: #007bff;
  border-radius: 4px;
}

.download-card::-webkit-scrollbar-thumb:hover {
  background: #0056b3;
}

/* プリント用スタイル */
@media print {
  .download-card {
    break-inside: avoid;
    box-shadow: none;
    border: 2px solid #000;
  }
  
  .download-btn {
    display: none;
  }
  
  .download-stats {
    display: none;
  }
}