/* ================================================
   Spathodea — 火焰樹 Design System
   Black + Red-Orange Premium Theme
   ================================================ */

/* ─── CSS Variables ─────────────────────────────── */
html {
  scrollbar-gutter: stable; /* 現代瀏覽器解決跳動的神器 */
}

body {
  font-family: "Noto Sans TC", sans-serif;
  background-color: #1a1a1a;
  color: #e0e0e0;
  margin: 0;
  padding: 0;
  line-height: 1.6;

  /* 增加以下兩行 */
  width: 100%;
  overflow-x: hidden;
}
.series-pie-wrapper {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  text-align: center;
}

.series-pie-title {
  color: #ffa500;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 20px;
}

.series-pie-svg {
  aspect-ratio: 1 / 1;
  display: block;
}

.series-pie-svg image {
  object-fit: cover;
  object-position: center;
}
/* 建議加入到你的 style.css 中 */
.preview-container {
  width: 100%;
  max-width: 600px; /* 限制最大寬度，避免在大螢幕上過大 */
  margin: 20px auto; /* 居中顯示 */
  border-radius: 12px;
  overflow: hidden; /* 確保圓角效果 */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  background: #1a1a1a;
}

#preview-img {
  width: 100%; /* 寬度撐滿容器 */
  height: auto; /* 高度自動縮放，維持比例 */
  display: block;
  max-height: 500px; /* 限制最大高度，避免長圖霸佔螢幕 */
  object-fit: contain; /* 若限制高度，確保圖片不變形且完整顯示 */
}

:root {
  /* 背景層級（60%） */
  --bg-body: #0d0d0d;
  --bg-surface: #1a1a1a;
  --bg-elevated: #262626;

  /* 品牌色（30% + 10%） */
  --color-primary: #e63946;
  /* 烈焰紅 */
  --color-secondary: #ff8c42;
  /* 亮橘 */
  --color-accent: #ff4d00;
  /* 紅橘過渡 */

  /* 文字 */
  --text-high: #ffffff;
  --text-med: #b3b3b3;
  --text-low: #666666;

  /* 邊框 */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-brand: rgba(230, 57, 70, 0.5);

  /* 光暈特效 */
  --shadow-glow-red: 0 0 20px rgba(230, 57, 70, 0.35);
  --shadow-glow-orange: 0 0 20px rgba(255, 140, 66, 0.35);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.6);

  /* 漸層 */
  --gradient-lava: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  --gradient-body: radial-gradient(ellipse at top, #1f0a08 0%, #0d0d0d 60%);
}

/* ─── Reset & Base ───────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ─── Background Canvas ─────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

/* ─── Global Scrollbar ───────────────────────────── */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 5px;
  border: 2px solid var(--bg-body);
  /* 讓滾動條有一點間隙看起來更細緻 */
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gradient-lava);
}

/* 确保所有內容在 canvas 上層 */
.container,
.modal-bg {
  position: relative;
  z-index: 1;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg-body);
  background-image: var(--gradient-body);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text-high);
  overflow-x: hidden;
  letter-spacing: 0.02em;
}

/* 極細的紅光暗紋背景 + 滑鼠追蹤光暈 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 80% 40% at 50% 0%,
      rgba(230, 57, 70, 0.12) 0%,
      transparent 70%
    ),
    radial-gradient(
      ellipse 60% 30% at 80% 100%,
      rgba(255, 140, 66, 0.07) 0%,
      transparent 60%
    );
  pointer-events: none;
  z-index: 0;
}

/* 滑鼠追蹤光暈（由 JS 更新 --mouse-x / --mouse-y） */
body::after {
  content: "";
  position: fixed;
  width: 600px;
  height: 600px;
  left: var(--mouse-x, 50%);
  top: var(--mouse-y, 50%);
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    rgba(230, 57, 70, 0.1) 0%,
    rgba(255, 140, 66, 0.06) 30%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  transition:
    left 0.05s linear,
    top 0.05s linear;
  border-radius: 50%;
}

/* ─── Layout ─────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* ─── Header ─────────────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 48px;
  padding-top: 16px;
}

header h1 {
  font-size: clamp(2.6rem, 5vw, 3.8rem);
  font-weight: 800;
  color: var(--text-high);
  letter-spacing: 0.04em;
  text-shadow:
    0 0 30px rgba(230, 57, 70, 0.7),
    0 0 60px rgba(230, 57, 70, 0.3);
}

.fire-emoji {
  display: inline-block;
  animation: flicker 5s ease-in-out infinite alternate;
}

@keyframes flicker {
  0% {
    filter: drop-shadow(0 0 6px #ff4500);
    transform: scale(1);
  }

  50% {
    filter: drop-shadow(0 0 14px #ff8c42);
    transform: scale(1.08);
  }

  100% {
    filter: drop-shadow(0 0 8px #e63946);
    transform: scale(0.96);
  }
}

.subtitle {
  text-align: center;
  margin-top: 10px;
  margin-bottom: 0;
  color: var(--text-med);
  font-size: 1rem;
  letter-spacing: 0.05em;
}

/* ─── Stats Container ────────────────────────────── */
.stats-container {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-left: 3px solid var(--color-primary) !important;
  border-right: 3px solid var(--color-primary) !important;
  border-radius: 16px !important;
  padding: 24px !important;
  margin-bottom: 28px !important;

  /* 將所有陰影合併寫在同一行才不會互相覆蓋 */
  box-shadow:
    -4px 0 16px rgba(230, 57, 70, 0.1),
    4px 0 16px rgba(230, 57, 70, 0.1),
    var(--shadow-card);
}

.stats-container label {
  color: var(--text-med);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

#dateRange {
  width: auto;
  display: inline-block;
  padding: 6px 16px;
  margin-left: 10px;
}

/* ─── Filter Section ─────────────────────────────── */
.filter-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 28px 30px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-card);
  /* 左側紅線 */
  border-left: 3px solid var(--color-primary);
  box-shadow:
    -4px 0 20px rgba(230, 57, 70, 0.1),
    var(--shadow-card);
  border-right: 3px solid var(--color-primary);
  box-shadow:
    4px 0 20px rgba(230, 57, 70, 0.1),
    var(--shadow-card);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.filter-group label {
  display: block;
  color: var(--color-secondary);
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── Selects ────────────────────────────────────── */
select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-high);
  outline: none;
  cursor: pointer;
  transition:
    border-color 0.25s,
    box-shadow 0.25s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select:hover {
  border-color: rgba(230, 57, 70, 0.5);
}

select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

select option {
  background: var(--bg-elevated);
  color: var(--text-high);
}

/* ─── Deck Grid ──────────────────────────────────── */
.deck-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 24px !important;
}
/* 一般情況不顯示內嵌網頁 */
.web-modal-content {
  display: none;
  width: 100%;
  height: 100%;
}

/* 內嵌網頁 iframe */
#post-web-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

/* post_url 模式下，彈窗占視窗的 95% */
.modal-box.web-mode {
  width: 95vw;
  max-width: 95vw;
  height: 95vh;
  max-height: 95vh;
  padding: 0;
  overflow: hidden;
}

/* web 模式隱藏原本的牌組內容 */
.modal-box.web-mode #normal-modal-content {
  display: none;
}

/* web 模式顯示 iframe */
.modal-box.web-mode #web-modal-content {
  display: block;
  width: 100%;
  height: 100%;
}

/* 關閉按鈕固定在 iframe 上方 */
.modal-box.web-mode .close-btn {
  position: absolute;
  top: 8px;
  right: 14px;
  z-index: 10;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 42px;
  height: 42px;
  padding: 0;

  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;

  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

/* 一般模式隱藏 web 內容 */
.modal-box:not(.web-mode) #web-modal-content {
  display: none;
}

/* 手機仍維持 95% */
@media (max-width: 768px) {
  .modal-box.web-mode {
    width: 95vw;
    max-width: 95vw;
    height: 95vh;
    max-height: 95vh;
  }

  .modal-box.web-mode .close-btn {
    top: 6px;
    right: 8px;
    width: 38px;
    height: 38px;
    font-size: 26px;
  }
}
/* ─── Deck Card ──────────────────────────────────── */
.deck-card {
  background: var(--bg-surface);
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
  box-shadow: var(--shadow-card);
}

.deck-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-brand);
  box-shadow: var(--shadow-glow-red), var(--shadow-card);
}

.deck-image-container {
  /* aspect-ratio: 16 / 9; */
  height: 200px;
  overflow: hidden;
  position: relative;
}

.deck-image-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(13, 13, 13, 0.6) 0%,
    transparent 50%
  );
  pointer-events: none;
}

.deck-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.4s ease;
}

.deck-card:hover .deck-image {
  transform: scale(1.04);
}

.deck-info {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deck-name {
  margin: 0;
  color: var(--text-high);
  font-size: 1.1rem;
  font-weight: 700;
}

.deck-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.axis-text {
  color: var(--text-med) !important;
  font-weight: 600;
  font-size: 0.9rem;
}

.series-tag {
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(230, 57, 70, 0.4);
  color: var(--color-secondary) !important;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ─── Lava Button ────────────────────────────────── */
.btn-view-more {
  width: 100%;
  padding: 12px;
  background: var(--gradient-lava);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease,
    opacity 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn-view-more::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.btn-view-more:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 140, 66, 0.45);
}

.btn-view-more:hover::before {
  transform: translateX(100%);
}

.btn-view-more:active {
  transform: translateY(0);
  opacity: 0.9;
}

/* ─── Modal ──────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  backdrop-filter: blur(12px);
}

.modal-box {
  background: var(--bg-surface);
  margin: 5vh auto;
  padding: 40px;
  width: 80%;
  height: 85vh;
  max-width: 1400px;
  border-radius: 22px;
  border: 1px solid var(--border-brand);
  box-shadow:
    var(--shadow-glow-red),
    0 20px 60px rgba(0, 0, 0, 0.7);
  position: relative;
  overflow: hidden;
}
.copy-deck-link {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 20;

    padding: 8px 14px;
    border: none;
    border-radius: 8px;

    background: rgba(255, 255, 255, 0.92);
    color: #333;

    font-size: 14px;
    font-weight: 600;
    cursor: pointer;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    transition:
        transform 0.15s ease,
        background-color 0.15s ease;
}

.copy-deck-link:hover {
    background: #ffffff;
    transform: translateY(-1px);
}

.copy-deck-link:active {
    transform: translateY(0);
}
.modal-layout {
  display: flex;
  gap: 40px;
  height: 100%;
  overflow-y: auto;
  padding-right: 10px;
}

/* 自定義滾動條 */
.modal-layout::-webkit-scrollbar {
  width: 6px;
}

.modal-layout::-webkit-scrollbar-track {
  background: var(--bg-elevated);
  border-radius: 8px;
}

.modal-layout::-webkit-scrollbar-thumb {
  background: var(--gradient-lava);
  border-radius: 8px;
}

.modal-img-area {
  flex: 1.2;
  position: sticky;
  top: 0;
}

.modal-img-area img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow:
    0 0 30px rgba(230, 57, 70, 0.2),
    0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-text-area {
  flex: 1;
  color: var(--text-high);
  font-size: 1.05rem;
  line-height: 1.7;
}

.modal-text-area h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: var(--gradient-lava);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-text-area hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 10px 0;
}

.modal-text-area p {
  color: var(--text-med);
}

.modal-text-area p strong,
.modal-text-area #m-notes {
  color: var(--text-high);
}

.close-btn {
  position: absolute;
  right: 24px;
  top: 14px;
  font-size: 36px;
  cursor: pointer;
  color: var(--text-low);
  z-index: 10;
  transition:
    color 0.2s ease,
    transform 0.2s ease;
  line-height: 1;
}

.close-btn:hover {
  color: var(--color-primary);
  transform: rotate(90deg);
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 1000px) {
  .modal-box {
    width: 95%;
    height: 90vh; /* 保持彈窗高度 */
    padding: 15px; /* 縮小內邊距給圖片更多空間 */
    display: flex;
    flex-direction: column;
  }

  .modal-layout {
    flex-direction: column;
    overflow-y: auto; /* 讓整個佈局可以上下捲動 */
  }

  .modal-img-area {
    position: relative;
    width: 100%;
    flex: none; /* 不要讓 flex 壓縮圖片區域 */
    margin-bottom: 20px;
    height: auto; /* 讓圖片自然撐開 */
  }

  .modal-img-area img {
    width: 100%; /* 手機上寬度 100% 即可，不建議 120% 避免橫向溢出 */
    height: auto;
    display: block;
  }

  .modal-text-area {
    flex: none; /* 確保文字跟在圖片後面 */
  }
}

@media (max-width: 640px) {
  .deck-grid {
    grid-template-columns: 1fr !important;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  header h1 {
    font-size: 2.2rem;
  }
}

.series-pie-wrapper {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  text-align: center;
  position: relative;
}

.series-pie-title {
  color: #ffa500;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 20px;
}

.series-pie-svg {
  aspect-ratio: 1 / 1;
  display: block;
}

.series-pie-tooltip {
  display: none;
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
}
