/* ========================================
   Reset & Base Styles
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

/* ========================================
   Header
   ======================================== */
header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 20px 30px;
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 10000;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

h1 {
  font-size: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h1 a {
  text-decoration: none;
  color: inherit;
}

/* ========================================
   Category Menu
   ======================================== */
.category-menu {
  position: relative;
}

.menu-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.category-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  margin-top: 10px;
  min-width: 200px;
  z-index: 9999;  /* コンテンツの上に表示 */
  overflow: hidden;
}

.category-dropdown.show {
  display: block;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-dropdown a {
  display: block;
  padding: 12px 20px;
  text-decoration: none;
  color: #333;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.category-dropdown a:last-child {
  border-bottom: none;
}

.category-dropdown a:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

/* ========================================
   Container
   ======================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* ========================================
   Detail Page
   ======================================== */
.detail-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 1;
}

/* ========================================
   3D Viewer
   ======================================== */
.viewer-container {
  position: relative;
  width: 100%;
  height: 600px;
  background: linear-gradient(135deg, #4a4a4a 0%, #3a3a3a 100%);
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

#modelViewer {
  width: 100%;
  height: 100%;
  display: block;
}

/* プログレスバー */
.progress-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 400px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.progress-bar {
  width: 0%;
  height: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  color: white;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

/* シェーディングボタン（3Dキャンバス下中央） */
.viewer-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}

.shading-btn {
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 20px;  /* 丸みを帯びたデザイン */
  padding: 12px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  min-width: 85px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.shading-btn:hover {
  background: white;
  transform: scale(1.05);
}

.shading-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);  /* グラデーション背景 */
  color: white;
}

/* ========================================
   ライトコントロール（3Dキャンバスの下）
   ======================================== */
.light-controls {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.control-group {
  margin-bottom: 15px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.control-group input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #ddd;
  outline: none;
  -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: none;
}

/* ========================================
   ポリゴン数表示（3Dビューアの左上）
   ======================================== */
.polygon-display {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 5;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.polygon-display #polygonCount {
  font-size: 18px;
  font-weight: 700;
  color: #4af;
}

/* ========================================
   アクションボタン（最下部）
   ======================================== */
.action-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.3s ease;
}

.back-link:hover {
  transform: translateX(-5px);
  color: #764ba2;
}

.download-btn {
  display: inline-block;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  padding: 15px 40px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.download-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
}

/* ========================================
   Category Section (for index.html)
   ======================================== */
.category-section {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.category-title {
  font-size: 24px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
}

.more-link {
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 20px;
  transition: all 0.3s ease;
  border: 2px solid #667eea;
}

.more-link:hover {
  background: #667eea;
  color: white;
  transform: translateX(5px);
}

/* Image Grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
}

.image-card {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  background: white;
}

.image-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.image-card img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
}

.image-card::after {
  content: '👁️ プレビュー';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: white;
  padding: 15px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-card:hover::after {
  opacity: 1;
}

/* ========================================
   Footer
   ======================================== */
footer {
  text-align: center;
  margin-top: 50px;
  color: white;
  font-size: 14px;
  opacity: 0.9;
}

/* ========================================
   Loading & Empty States
   ======================================== */
.loading, .empty {
  text-align: center;
  padding: 60px 20px;
  color: #666;
  font-size: 18px;
}

.loading::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  header {
    padding: 15px 20px;
  }

  h1 {
    font-size: 22px;
  }

  .detail-container {
    padding: 20px;
  }

  .viewer-container {
    height: 60vh;
    border-radius: 20px;  /* スマホ表示時20px角丸 */
  }

  .viewer-controls {
    gap: 8px;
  }

  .shading-btn {
    padding: 10px 16px;
    font-size: 12px;
    min-width: 75px;
  }

  .light-controls {
    padding: 15px;
  }

  .action-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .back-link {
    justify-content: center;
  }

  .download-btn {
    width: 100%;
    text-align: center;
  }

  .image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .image-card img {
    height: 200px;
  }
}

@media (max-width: 480px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer-container {
    height: 50vh;
  }

  .shading-btn {
    padding: 8px 12px;
    font-size: 11px;
    min-width: 65px;
  }
}

/* Google AdSense Container */
/* AdSenseのスタイル設定は adsense-config.css で管理されています */
