/* カードトリガーのスタイル */
.card-trigger {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.card-trigger:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card-trigger .card-image {
    width: 100%;
    height: auto;
    display: block;
}

/* ポップアップオーバーレイ */
.card-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-popup-overlay.active {
    display: flex;
    opacity: 1;
}

/* ポップアップコンテナ */
.card-popup-container {
    background: #fff;
    border-radius: 12px;
    width: 95vw; /* モバイル: 画面幅の95% */
    max-width: 1200px; /* PC: 1200px */
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.card-popup-overlay.active .card-popup-container {
    transform: scale(1);
}

/* 閉じるボタン */
.card-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.card-popup-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* タブナビゲーション */
.card-popup-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    background: #f5f5f5;
    padding: 0;
}

.card-tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
}

.card-tab-btn:hover {
    background: #e8e8e8;
    color: #333;
}

.card-tab-btn.active {
    color: #2196F3;
    background: #fff;
}

.card-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #2196F3;
}

.card-tab-btn.hidden {
    display: none;
}

/* タブコンテンツ */
.card-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.card-tab-content {
    display: none;
}

.card-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ローディング */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 18px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .card-popup-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .card-popup-content {
        padding: 15px;
    }
    
    .card-tab-btn {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .card-popup-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
}

/* Elementorコンテンツのスタイル調整 */
.card-tab-content .elementor-section,
.card-tab-content .elementor-container {
    max-width: 100%;
}

.card-tab-content img {
    max-width: 100%;
    height: auto;
}

/* ポップアップ内のカードグリッドレイアウト（既存CSSを継承） */
.card-tab-content .card-grid-container {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 24px !important;
  padding: 20px 0;
}

@media (max-width: 1024px) {
  .card-tab-content .card-grid-container {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 767px) {
  .card-tab-content .card-grid-container {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* ポップアップ内のカード基本設定 */
.card-tab-content .card-grid-container > .card {
  width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box;
  position: relative;
  aspect-ratio: 7 / 10;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* 情報バー */
.card-tab-content .card-grid-container > .card .info-bar {
  position: absolute;
  top: clamp(2px, 0.6vw, 8px);
  left: clamp(6px, 1.4vw, 14px);
  right: clamp(6px, 1.4vw, 14px);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  grid-template-areas: "cost skill" "cost type";
  column-gap: clamp(8px, 1.2vw, 12px);
  padding: clamp(5px, 0.8vw, 8px) clamp(9px, 1.4vw, 12px);
  align-items: center;
  z-index: 3;
  border-radius: 0 !important;
}

/* 上部背景（線形グラデーション） */
.card-tab-content .card-grid-container > .card .info-bar::before {
  content: "";
  position: absolute;
  left: clamp(-14px, -2.2vw, -22px);
  right: clamp(-14px, -2.2vw, -22px);
  height: clamp(44px, 7vw, 70px);
  top: clamp(-10px, -0.5vw, -4px);
  border-radius: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 50%, rgba(0, 0, 0, 0) 100%) !important;
}

/* コスト数字 */
.card-tab-content .card-grid-container > .card .info-bar .cost {
  grid-area: cost;
  align-self: start;
  transform: translateY(-4px);
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 900;
  color: #b9e6ff;
  line-height: 1;
  letter-spacing: 0.02em;
  text-shadow: 0 0 2px #fff, 0 0 6px #bfe9ff, 0 0 10px rgba(0, 180, 255, 0.9),
    0 0 20px rgba(0, 160, 255, 0.75), 0 0 30px rgba(0, 140, 255, 0.6);
}

/* スキル名 */
.card-tab-content .card-grid-container > .card .info-bar .skill {
  grid-area: skill;
  transform: translateY(-6px);
  font-size: clamp(13px, 2.4vw, 20px);
  font-weight: 100;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.8), 0 0 4px rgba(150, 220, 255, 0.7), 0 0 8px rgba(0, 0, 0, 0.6);
}

/* 種別行 */
.card-tab-content .card-grid-container > .card .info-bar .type {
  grid-area: type;
  display: inline-flex;
  align-items: center;
  gap: clamp(4px, 0.7vw, 8px);
  transform: translateY(-52px) translateX(-8px);
}

/* 種別アイコン */
.card-tab-content .card-grid-container > .card .info-bar .type-ic img {
  width: clamp(14px, 2.2vw, 20px);
  height: auto;
  transform: translateY(-8px);
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.5)) drop-shadow(0 0 6px rgba(0, 0, 0, 0.6));
}

/* 種別テキスト */
.card-tab-content .card-grid-container > .card .info-bar .type-tx {
  font-size: clamp(13px, 2.4vw, 20px);
  font-weight: 100;
  color: #fff;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.9), 0 0 10px rgba(255, 255, 255, 0.45), 0 0 16px rgba(0, 0, 0, 0.5);
  transform: translateX(-4px);
}

/* カード下部（線形グラデーション） */
.card-tab-content .card-grid-container > .card .desc-box {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: clamp(8px, 1.2vw, 12px) clamp(14px, 2.2vw, 22px);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  z-index: 2;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 50%, rgba(0, 0, 0, 0) 100%) !important;
}

/* 説明テキスト */
.card-tab-content .card-grid-container > .card .desc-box .desc {
  font-size: clamp(11px, 2vw, 16px);
  font-weight: 300;
  color: #ffffff;
  line-height: 1.0 !important;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 8px rgba(0, 0, 0, 0.6);
  margin: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.card-tab-content .card-grid-container > .card .desc-box .desc br {
  display: block;
  content: "";
  margin-top: -0.3em;
}

.card-tab-content .card-grid-container > .card .desc-box .desc p {
  margin: 0;
  line-height: 1.2 !important;
}

/* タブレット */
@media (max-width: 1024px) and (min-width: 768px) {
  .card-tab-content .card-grid-container > .card .desc-box .desc {
    line-height: 1.2 !important;
    font-size: clamp(10px, 2.2vw, 15px);
  }
  .card-tab-content .card-grid-container > .card .desc-box .desc br {
    margin-top: -0.4em;
  }
  .card-tab-content .card-grid-container > .card .info-bar::before {
    height: clamp(52px, 9vw, 85px) !important;
  }
  
  /* タブレットでtype-icを1px上に */
  .card-tab-content .card-grid-container > .card .info-bar .type-ic img {
    transform: translateY(-9px) !important;
  }
}

/* スマホ */
@media (max-width: 767px) {
  .card-tab-content .card-grid-container > .card .desc-box .desc {
    line-height: 1.2 !important;
    font-size: clamp(10px, 2.5vw, 14px);
  }
  .card-tab-content .card-grid-container > .card .desc-box .desc br {
    margin-top: -0.4em;
  }
  .card-tab-content .card-grid-container > .card .desc-box {
    padding: clamp(10px, 1.5vw, 14px) clamp(12px, 2vw, 18px) !important;
  }
  
  /* スマホでskillを下に移動 */
  .card-tab-content .card-grid-container > .card .info-bar .skill {
    transform: translateY(0px) !important;
  }
  
  /* スマホでtypeを元の位置に戻す */
  .card-tab-content .card-grid-container > .card .info-bar .type {
    transform: translateY(-44px) translateX(-8px) !important;
  }
  
  /* スマホでtype-icを1px上に */
  .card-tab-content .card-grid-container > .card .info-bar .type-ic img {
    transform: translateY(-9px) !important;
  }
}
