/* ============================================================
   寶可夢屬性相剋表 (Type Matchup Chart) CSS
   適合國小學生與兒童，乾淨直覺、支援 iPhone/iPad/Desktop
   ============================================================ */

/* 頁面專屬容器 */
.type-chart-container {
  max-width: 1080px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  padding-left: max(14px, env(safe-area-inset-left, 0px));
}

/* 頁頂導覽列 */
.type-chart-header {
  padding: 12px 4px 18px 4px;
}

.type-chart-top-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 12px;
}

.type-chart-back-btn {
  background-color: #475569;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  min-height: 48px; /* >= 44px 兒童觸控 */
  min-width: 44px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: var(--btn-radius);
  border: none;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.type-chart-back-btn:hover {
  background-color: #334155;
}

.type-chart-back-btn:active {
  transform: scale(0.96);
}

.type-chart-title-area {
  text-align: center;
  margin: 6px 0 16px 0;
}

.type-chart-main-title {
  font-size: 2rem;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.type-chart-subtitle {
  font-size: 1.15rem;
  font-weight: 600;
  color: #475569;
}

/* ============================================================
   步驟 1：選擇攻擊屬性 (簡易查詢)
   ============================================================ */

.type-selector-card {
  background-color: var(--card-bg);
  border-radius: 22px;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 18px 16px;
  margin-bottom: 20px;
}

.section-label-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
}

.section-label {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-hint {
  font-size: 0.95rem;
  font-weight: 600;
  color: #64748b;
}

/* 18 屬性按鈕網格 */
.type-buttons-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

@media (max-width: 768px) {
  .type-buttons-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

.type-select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px; /* >= 44px */
  padding: 8px 12px;
  border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
  user-select: none;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.type-select-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.type-select-btn:active {
  transform: scale(0.96);
}

.type-select-btn.is-active {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  z-index: 1;
}

.btn-type-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.btn-type-label {
  line-height: 1;
}

/* ============================================================
   步驟 2：相剋效果結果區 (簡易查詢)
   ============================================================ */

.effectiveness-result-section {
  margin-bottom: 24px;
}

/* 未選擇屬性提示 */
.empty-selection-placeholder {
  background-color: var(--card-bg);
  border: 2px dashed #cbd5e1;
  border-radius: 20px;
  padding: 40px 20px;
  text-align: center;
}

.empty-placeholder-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-placeholder-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.empty-placeholder-desc {
  font-size: 1.05rem;
  font-weight: 600;
  color: #64748b;
}

/* 當前攻擊屬性狀態橫幅 */
.active-attacker-banner {
  background-color: #ffffff;
  border-radius: 18px;
  border: 2px solid #e2e8f0;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.attacker-info-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attacker-title-tag {
  font-size: 1.05rem;
  font-weight: 700;
  color: #475569;
}

.attacker-badge-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: 9999px;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.attacker-summary-text {
  font-size: 1rem;
  font-weight: 600;
  color: #64748b;
}

/* 4 大效果分組容器 */
.matchup-groups-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.matchup-group-card {
  background-color: #ffffff;
  border-radius: 18px;
  border: 2px solid #e2e8f0;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.matchup-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1.5px solid #f1f5f9;
}

.matchup-group-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matchup-multiplier-badge {
  font-size: 0.95rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 9999px;
  letter-spacing: 0.5px;
}

.matchup-group-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.matchup-group-desc {
  font-size: 0.95rem;
  font-weight: 600;
  color: #64748b;
}

/* 分組顏色系統 */
/* 效果絕佳 x2 */
.group-super-effective {
  border-color: #bbf7d0;
  background-color: #f0fdf4;
}
.group-super-effective .matchup-multiplier-badge {
  background-color: #16a34a;
  color: #ffffff;
}
.group-super-effective .matchup-group-title {
  color: #15803d;
}

/* 效果普通 x1 */
.group-normal-effective {
  border-color: #e2e8f0;
  background-color: #ffffff;
}
.group-normal-effective .matchup-multiplier-badge {
  background-color: #64748b;
  color: #ffffff;
}
.group-normal-effective .matchup-group-title {
  color: #334155;
}

/* 效果不佳 x0.5 */
.group-not-effective {
  border-color: #fed7aa;
  background-color: #fff7ed;
}
.group-not-effective .matchup-multiplier-badge {
  background-color: #ea580c;
  color: #ffffff;
}
.group-not-effective .matchup-group-title {
  color: #c2410c;
}

/* 無效 x0 */
.group-no-effective {
  border-color: #e2e8f0;
  background-color: #f8fafc;
}
.group-no-effective .matchup-multiplier-badge {
  background-color: #94a3b8;
  color: #ffffff;
}
.group-no-effective .matchup-group-title {
  color: #64748b;
}

/* 屬性卡片網格 (防守屬性) */
.defending-types-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.defending-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 10px;
  border-radius: 9999px;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  user-select: none;
}

.defending-type-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

.defending-none-text {
  font-size: 1rem;
  font-weight: 700;
  color: #94a3b8;
  padding: 4px 8px;
}

/* ============================================================
   完整 18 x 18 相剋表區塊
   ============================================================ */

.full-matrix-section {
  background-color: var(--card-bg);
  border-radius: 22px;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px 18px;
  margin-top: 10px;
  margin-bottom: 30px;
}

.matrix-toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.matrix-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  min-height: 48px;
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.matrix-toggle-btn:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
}

.matrix-toggle-btn:active {
  transform: scale(0.97);
}

.matrix-legend-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-weight: 700;
  color: #475569;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
}

.legend-badge.badge-2   { background-color: #16a34a; color: #ffffff; }
.legend-badge.badge-1   { background-color: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.legend-badge.badge-05  { background-color: #ea580c; color: #ffffff; }
.legend-badge.badge-0   { background-color: #1e293b; color: #ffffff; }

/* 表格水平捲動容器 */
.matrix-scroll-wrapper {
  margin-top: 18px;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  background-color: #ffffff;
  -webkit-overflow-scrolling: touch;
}

/* 18 x 18 表格 */
.matchup-matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.95rem;
  text-align: center;
}

/* 表格左上角方向指示格 (雙向 sticky) */
.matrix-corner-cell {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 20;
  background-color: #0f172a;
  color: #ffffff;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  min-width: 86px;
  border-right: 2px solid #334155;
  border-bottom: 2px solid #334155;
  white-space: nowrap;
}

.corner-label-atk {
  color: #60a5fa;
  font-size: 0.78rem;
}

.corner-label-def {
  color: #4ade80;
  font-size: 0.78rem;
}

/* 頂部防守屬性標題 (Top Sticky) */
.matrix-def-header-cell {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f8fafc;
  padding: 8px 6px;
  min-width: 46px;
  border-bottom: 2px solid #94a3b8;
  border-right: 1px solid #e2e8f0;
  text-align: center;
}

.matrix-header-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

.matrix-header-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.matrix-header-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: #1e293b;
  white-space: nowrap;
}

/* 左側攻擊屬性欄 (Left Sticky) */
.matrix-atk-header-cell {
  position: sticky;
  left: 0;
  z-index: 5;
  background-color: #f8fafc;
  padding: 6px 10px;
  min-width: 86px;
  border-right: 2px solid #94a3b8;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.matrix-atk-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 6px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  white-space: nowrap;
}

.matrix-atk-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

/* 矩陣資料格 (倍率 cell) */
.matrix-cell {
  padding: 6px 4px;
  min-width: 44px;
  height: 40px;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.95rem;
  font-weight: 800;
  user-select: none;
}

/* 倍率上色 */
.cell-mult-2 {
  background-color: #dcfce7;
  color: #15803d;
}

.cell-mult-1 {
  background-color: #ffffff;
  color: #94a3b8;
}

.cell-mult-05 {
  background-color: #ffedd5;
  color: #c2410c;
}

.cell-mult-0 {
  background-color: #0f172a;
  color: #94a3b8;
}

/* 高亮目前游標或選擇的 row / col */
.matrix-row.is-selected-atk .matrix-atk-header-cell {
  background-color: #dbeafe;
}

/* ============================================================
   RWD 微調 (iPhone 375 / 390)
   ============================================================ */

@media (max-width: 480px) {
  .type-chart-main-title {
    font-size: 1.6rem;
  }
  
  .type-chart-subtitle {
    font-size: 1rem;
  }
  
  .type-select-btn {
    padding: 8px 6px;
    font-size: 0.95rem;
    gap: 6px;
  }
  
  .btn-type-icon {
    width: 20px;
    height: 20px;
  }
  
  .attacker-badge-display {
    font-size: 1.1rem;
    padding: 5px 12px;
  }
  
  .defending-type-pill {
    padding: 5px 10px 5px 8px;
    font-size: 0.95rem;
  }
  
  .matrix-cell {
    min-width: 40px;
    height: 38px;
    font-size: 0.85rem;
  }
}
