/* ============================================================
   BuakTCG — Card Template Stylesheet
   ออกแบบโดย Friday • ใช้คู่กับ cards.json + index.html
   Icons: game-icons.net (CC BY 3.0)
   ============================================================ */

:root {
  --card-w: 320px;
  --card-h: 460px;
  --str: #e5484d;
  --str-glow: #ff8a8d;
  --agi: #46a758;
  --agi-glow: #8fe3a4;
  --mag: #3e9df0;
  --mag-glow: #9fd4ff;
  --gold: #d4b06a;
  --gold-dark: #a8874a;
  --ink: #12141c;
  --ink-2: #1a1e2a;
  --paper: #f4efe4;
  --paper-dim: #d8d2c4;
}

/* ---------- ตัวการ์ดหลัก ---------- */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  color: var(--paper);
  font-family: "Sarabun", "Noto Sans Thai", sans-serif;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 40%),
    linear-gradient(0deg, var(--ink) 0%, var(--ink-2) 55%, #232838 100%);
  border: 2px solid var(--c, var(--gold));
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 24px -6px var(--c-glow, var(--gold)),
    0 18px 40px -18px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 34px -4px var(--c-glow, var(--gold)),
    0 26px 50px -20px rgba(0, 0, 0, 0.95);
}

/* มงกุฎลายเส้นบาง ๆ รอบการ์ด */
.card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid color-mix(in srgb, var(--c, var(--gold)) 45%, transparent);
  border-radius: 12px;
  pointer-events: none;
  z-index: 4;
}

/* ---------- หัวการ์ด ---------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  z-index: 3;
}
.card-name {
  font-family: "Cinzel", serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-name-th {
  font-size: 12.5px;
  color: var(--paper-dim);
  margin-top: -2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- ป้ายประเภทจังหวะ ---------- */
.badge-action {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 8px;
  color: #0d0f16;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.badge-action.Action  { background: linear-gradient(135deg, #f0c06a, #d4934a); }
.badge-action.Bonus   { background: linear-gradient(135deg, #8ad3f0, #4ba3c9); }
.badge-action.Free    { background: linear-gradient(135deg, #9fe8a8, #57b96b); }
.badge-action.Reaction{ background: linear-gradient(135deg, #e59ab8, #c9648f); }

/* ---------- โซนภาพ ---------- */
.card-art {
  position: relative;
  height: 152px;
  margin: 2px 12px;
  border-radius: 12px;
  background:
    radial-gradient(ellipse 90% 80% at 50% 42%, var(--c-glow) 0%, transparent 62%),
    radial-gradient(ellipse 120% 100% at 50% 110%, color-mix(in srgb, var(--c) 55%, #05060a) 0%, #05060a 70%);
  border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  overflow: hidden;
}
.card-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(5, 6, 10, 0.85) 100%);
  pointer-events: none;
}
.card-art .icon {
  width: 104px;
  height: 104px;
  color: #fff;
  opacity: 0.95;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 18px var(--c-glow));
  z-index: 2;
}
.card-art .icon svg { width: 100%; height: 100%; display: block; }

/* วงแหวนตกแต่งหลังไอคอน */
.art-ring {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--c-glow, var(--gold)) 40%, transparent);
  box-shadow: inset 0 0 26px color-mix(in srgb, var(--c, var(--gold)) 22%, transparent);
  pointer-events: none;
}

/* ---------- ป้ายดาเมจ ---------- */
.damage-badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  z-index: 5;
  min-width: 56px;
  height: 56px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  background: radial-gradient(circle at 32% 28%, #4a4f63, #14161f 68%);
  border: 2px solid var(--str);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7), inset 0 0 12px rgba(229, 72, 77, 0.35);
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 20px;
  color: #ffd9da;
  text-shadow: 0 0 10px rgba(229, 72, 77, 0.9);
}
.damage-badge .sw {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--str-glow);
}
.damage-badge .sw svg { width: 100%; height: 100%; display: block; }
/* สูตรอิง stat (STR / MAG+2) — pill กว้าง ตัวเล็กลง */
.damage-badge.formula {
  height: 44px;
  font-size: 14.5px;
  letter-spacing: 0.4px;
  border-radius: 999px;
}
.damage-badge.formula .sw { width: 15px; height: 15px; }

/* ---------- แถบ Threshold ---------- */
.threshold-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 6px;
  z-index: 3;
}
.threshold-label {
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--paper-dim);
  font-weight: 600;
}
.threshold-orb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 32% 28%, var(--sc-glow), var(--sc) 72%);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 14px -2px var(--sc), inset 0 -4px 8px rgba(0, 0, 0, 0.45);
}
.threshold-orb .orb-icon {
  width: 19px;
  height: 19px;
  display: flex;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}
.threshold-orb .orb-icon svg { width: 100%; height: 100%; }
.threshold-orb .orb-val {
  position: absolute;
  right: -5px;
  bottom: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: #14161f;
  border: 1px solid var(--sc-glow);
  color: #fff;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 10.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
/* Natural (เทา) — universal: ขอบประ + สว่างกว่าปกติ กันกลืนพื้นการ์ด */
.threshold-orb.nat {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 16px 0 rgba(195, 199, 206, 0.55), inset 0 -4px 8px rgba(0, 0, 0, 0.45);
}
.threshold-plus {
  font-size: 15px;
  color: var(--paper-dim);
  font-weight: 700;
}

/* ---------- กล่องเอฟเฟค ---------- */
.card-effect {
  flex: 1;
  margin: 2px 12px 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(6, 8, 13, 0.72);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  font-size: 13.5px;
  line-height: 1.5;
  color: #eef;
  display: flex;
  align-items: center;
  z-index: 3;
}
/* ครอบข้อความเป็น flex item เดียว — กัน keyword span แตกบรรทัด/เว้นวรรคแปลก */
.card-effect .txt { flex: 1; }
.card-effect .kw {
  color: var(--c-glow);
  font-weight: 700;
}

/* ---------- ท้ายการ์ด ---------- */
.card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px 11px;
  z-index: 3;
}
.card-flavor {
  font-size: 12px;
  font-style: italic;
  color: #b3bccc;
  line-height: 1.45;
  max-width: 225px;
}
.card-id {
  font-size: 10px;
  letter-spacing: 1px;
  color: color-mix(in srgb, var(--c) 75%, #fff);
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}
.card-id .suggest {
  display: block;
  font-weight: 400;
  color: #7d869c;
  font-size: 9.5px;
}

/* ============================================================
   การ์ดเผ่า (Tribe)
   ============================================================ */
.card.tribe {
  --c: var(--gold);
  --c-glow: var(--gold);
}
.card.tribe .card-art {
  height: 196px;
}
.card.tribe .card-art .icon {
  width: 132px;
  height: 132px;
}
.badge-action.tribe-chip {
  background: linear-gradient(135deg, #f5d78e, #d4b06a);
  letter-spacing: 0.4px;
}
.hp-orb {
  position: absolute;
  left: -6px;
  bottom: -6px;
  z-index: 5;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 32% 28%, #5a4732, #171208 68%);
  border: 2px solid var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7), inset 0 0 12px rgba(212, 176, 106, 0.3);
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 22px;
  color: #ffe9c2;
  text-shadow: 0 0 10px rgba(212, 176, 106, 0.8);
}
.hp-orb small {
  font-size: 10px;
  font-weight: 400;
  color: #cbb384;
  letter-spacing: 1px;
  margin-left: 3px;
}
.tribe-ability {
  margin: 4px 12px 2px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(6, 8, 13, 0.72);
  border: 1px solid rgba(212, 176, 106, 0.35);
  z-index: 3;
}
.tribe-ability .ability-title {
  font-family: "Cinzel", serif;
  font-size: 11.5px;
  letter-spacing: 0.8px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 3px;
}
.tribe-ability .ability-text {
  font-size: 13px;
  color: #eef;
  line-height: 1.5;
}
.tribe-shared {
  margin: 4px 12px 6px;
  font-size: 12px;
  color: #aab3c8;
  line-height: 1.5;
  z-index: 3;
}
.tribe-shared .lbl {
  display: block;
  color: var(--gold);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 1px;
}

/* ============================================================
   การ์ดอัพคลาส (Class)
   ============================================================ */
.class-condition {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 12px 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 16%, rgba(6, 8, 13, 0.8)), rgba(6, 8, 13, 0.8));
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  z-index: 3;
  font-size: 12.5px;
  color: #eef;
}
.class-condition .lbl {
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--paper-dim);
  font-weight: 700;
}
.card.class .card-art {
  height: 168px;
}

/* ============================================================
   หน้า Gallery
   ============================================================ */
body.page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #1c2233 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, #161a28 0%, transparent 60%),
    #0b0d13;
  color: var(--paper);
  font-family: "Sarabun", "Noto Sans Thai", sans-serif;
  padding-bottom: 80px;
}
.page-head {
  text-align: center;
  padding: 44px 16px 8px;
}
.page-head h1 {
  font-family: "Cinzel", serif;
  font-size: 40px;
  margin: 0;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff, #d4b06a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 30px rgba(212, 176, 106, 0.25);
}
.page-head .sub {
  color: #9aa3b8;
  margin-top: 6px;
  font-size: 14px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 18px 16px;
  position: sticky;
  top: 0;
  background: rgba(11, 13, 19, 0.96);
  border-bottom: 1px solid #1d2230;
  backdrop-filter: blur(6px);
  z-index: 50;
}
#root > section { scroll-margin-top: 90px; }
.filters button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid #2a3040;
  background: #141824;
  color: #c9d1e4;
  cursor: pointer;
  transition: all 0.15s ease;
}
.filters button:hover { border-color: var(--gold); color: #fff; }
.filters button.active {
  background: linear-gradient(135deg, #f0c06a, #d4934a);
  color: #14100a;
  border-color: #f0c06a;
}
.section-title {
  font-family: "Cinzel", serif;
  font-size: 18px;
  letter-spacing: 1.5px;
  color: var(--gold);
  margin: 34px 0 4px;
  padding: 0 28px;
  text-transform: uppercase;
}
.section-title small {
  font-family: "Sarabun", sans-serif;
  color: #7d869c;
  font-size: 12px;
  letter-spacing: 0.3px;
  text-transform: none;
  margin-left: 10px;
}
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  padding: 14px 28px 0;
  justify-content: flex-start;
}
.page-foot {
  text-align: center;
  color: #6b7288;
  font-size: 11.5px;
  margin-top: 60px;
  line-height: 1.7;
}
.page-foot a { color: #9aa3b8; }

/* ---------- ปรับหน้าจอเล็ก ---------- */
@media (max-width: 720px) {
  :root { --card-w: 272px; --card-h: 392px; }
  .card-art { height: 128px; }
  .card.tribe .card-art { height: 158px; }
  .card.class .card-art { height: 142px; }
  .card-name { font-size: 18px; }
  .grid { justify-content: center; }
}
