/* ============================================================
   玄天宗 · 點名召喚台 — style.css
   原則：CSS 只做版面與簡單過場（fade / scale / glow）。
   高質感視覺由 image2 靜態圖 + Blender 影片素材承擔。
   ============================================================ */

:root {
  --gold: #e8c66b;
  --gold-bright: #ffe9a8;
  --gold-deep: #9a7427;
  --ink-0: #070b16;
  --ink-1: #0d1326;
  --ink-2: #16203f;
  --r-color: #9fc6b8;
  --sr-color: #c19df5;
  --ssr-color: #ffd97a;
  --panel: rgba(9, 13, 28, 0.88);
  --hairline: rgba(232, 198, 107, 0.38);
  --font-kai: "Kaiti TC", "DFKai-SB", "KaiTi", "BiauKai", "Noto Serif TC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-kai);
  color: #e9e4d4;
  background: var(--ink-0);
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }
img.missing { visibility: hidden; }

/* ---------- 背景 ---------- */
#bg {
  position: fixed; inset: 0; z-index: 0;
  background-color: var(--ink-1);
  background-image:
    url("assets/images/bg_main.png"),
    radial-gradient(120% 90% at 50% 8%, #1c2c58 0%, #0d1326 55%, #070b16 100%);
  background-size: cover, cover;
  background-position: center, center;
}
#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(90% 75% at 50% 45%, transparent 45%, rgba(3, 5, 12, 0.62) 100%),
    linear-gradient(180deg, rgba(3, 5, 12, 0.45) 0%, transparent 18%, transparent 72%, rgba(3, 5, 12, 0.66) 100%);
}

/* ---------- 頂欄 ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 26px;
}
#sectName {
  color: var(--gold);
  font-size: 19px; letter-spacing: 0.38em;
  text-shadow: 0 0 14px rgba(232, 198, 107, 0.45);
}
#topActions { display: flex; gap: 10px; }

/* ---------- 按鈕 ---------- */
.btn {
  font-family: inherit; cursor: pointer;
  color: var(--gold);
  background: linear-gradient(180deg, rgba(38, 50, 94, 0.92), rgba(13, 18, 38, 0.96));
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 15px; letter-spacing: 0.18em;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s, transform 0.12s;
}
.btn:hover {
  border-color: var(--gold); color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(232, 198, 107, 0.35);
}
.btn:active { transform: scale(0.97); }
.btn-gold {
  color: #2a1f08;
  background: linear-gradient(180deg, #f1d489, #c49a3e 55%, #8f6c22);
  border-color: rgba(255, 233, 168, 0.65);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5);
  font-weight: bold;
}
.btn-gold:hover { color: #1d1503; box-shadow: 0 0 18px rgba(232, 198, 107, 0.6); }

/* ---------- 中央召喚台 ---------- */
#altar {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  padding-top: 30px;
}
#circleWrap {
  position: relative;
  width: min(46vmin, 480px);
  aspect-ratio: 1;
}
#circleWrap::before {
  /* 法陣圖載入失敗時的底環，平時藏在美術圖下方 */
  content: "";
  position: absolute; inset: 7%;
  border-radius: 50%;
  border: 1px solid rgba(232, 198, 107, 0.35);
  box-shadow: inset 0 0 46px rgba(232, 198, 107, 0.14), 0 0 24px rgba(232, 198, 107, 0.12);
}
#magicCircle {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  /* 法陣圖已 luma 轉真 alpha（黑底→透明），直接正常合成；
     不掛 mix-blend-mode 與 drop-shadow（全屏混合層會拖垮渲染） */
  animation: spin 26s linear infinite, breathe 4.5s ease-in-out infinite;
}
#idleCard {
  position: absolute; left: 50%; top: 50%;
  height: 46%;
  transform: translate(-50%, -56%);
  border-radius: 10px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6), 0 0 22px rgba(120, 180, 255, 0.25);
  animation: floatCard 4.6s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
@keyframes floatCard {
  0%, 100% { transform: translate(-50%, -56%); }
  50% { transform: translate(-50%, -62%); }
}
#altarHint {
  color: rgba(232, 198, 107, 0.78);
  letter-spacing: 0.55em; font-size: 15px;
  text-indent: 0.55em;
}

/* 主召喚鈕：image2 按鈕圖為主、CSS 漸層為備援 */
#btnSummon {
  position: relative;
  width: min(330px, 78vw); height: 84px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; border: none; background-color: transparent;
  background-image:
    url("assets/images/btn_summon.png"),
    radial-gradient(140% 180% at 50% -30%, #f2d68b 0%, #b9913c 42%, #6d531c 100%);
  /* 按鈕板圖含上下透明邊，垂直放大裁切讓金匾填滿按鈕 */
  background-size: 102% 215%, 100% 100%;
  background-position: center, center;
  background-repeat: no-repeat;
  border-radius: 12px;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 14px rgba(232, 198, 107, 0.3));
  transition: transform 0.15s, filter 0.2s;
}
#btnSummon:hover {
  transform: scale(1.04);
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 26px rgba(255, 222, 140, 0.55));
}
#btnSummon:active { transform: scale(0.97); }
.btn-summon-text {
  font-family: inherit;
  font-size: 24px; letter-spacing: 0.3em; text-indent: 0.3em;
  color: #2a1f08; font-weight: bold;
  text-shadow: 0 1px 2px rgba(255, 240, 200, 0.55);
}
.btn-summon-sub {
  font-size: 11px; letter-spacing: 0.25em;
  color: rgba(42, 31, 8, 0.66);
}
#counter {
  font-size: 14px; letter-spacing: 0.18em;
  color: #cbbf9a;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* ---------- 已抽紀錄 ---------- */
#logbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 24px 16px;
}
#logTitle {
  flex: none;
  color: rgba(232, 198, 107, 0.8);
  font-size: 14px; letter-spacing: 0.3em;
}
#logList {
  display: flex; gap: 8px; align-items: center;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin; scrollbar-color: rgba(232, 198, 107, 0.4) transparent;
}
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 13px;
  font-size: 13px; letter-spacing: 0.1em;
  color: #ddd5bf;
  background: rgba(10, 14, 30, 0.74);
  border: 1px solid rgba(170, 170, 170, 0.35);
  border-radius: 999px;
  white-space: nowrap;
}
.chip i { font-style: normal; font-size: 11px; opacity: 0.85; }
.chip.R   { border-color: var(--r-color);   color: var(--r-color); }
.chip.SR  { border-color: var(--sr-color);  color: var(--sr-color); }
.chip.SSR {
  border-color: var(--ssr-color); color: var(--ssr-color);
  box-shadow: 0 0 10px rgba(255, 217, 122, 0.45);
}

/* ---------- 名冊側欄 ---------- */
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(360px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--hairline);
  backdrop-filter: blur(8px);
  padding: 24px 22px;
  display: flex; flex-direction: column; gap: 13px;
  transform: translateX(105%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}
#drawer.open { transform: translateX(0); }
#drawer h2 {
  color: var(--gold); font-size: 20px;
  letter-spacing: 0.4em; font-weight: normal;
}
.drawer-hint { font-size: 13px; color: #9b937c; letter-spacing: 0.08em; }
#rosterInput {
  width: 100%; height: 200px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: #e9e4d4; font-family: inherit; font-size: 15px;
  line-height: 1.7; padding: 10px 12px;
  resize: vertical; outline: none;
}
#rosterInput:focus { border-color: var(--gold); }
.drawer-row { display: flex; gap: 10px; flex-wrap: wrap; }
.drawer-sep { border-top: 1px dashed rgba(232, 198, 107, 0.25); margin: 4px 0; }
.opt-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 14px; letter-spacing: 0.1em; color: #d8d0b8;
}
.opt-row input[type="checkbox"] { accent-color: var(--gold); width: 16px; height: 16px; }
#weightsRow .w-label { color: rgba(232, 198, 107, 0.85); letter-spacing: 0.2em; }
.w-item { display: inline-flex; align-items: center; gap: 4px; }
.w-item.ssr { color: var(--ssr-color); }
.w-item.sr  { color: var(--sr-color); }
.w-item.r   { color: var(--r-color); }
.w-item input {
  width: 52px; text-align: center;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--hairline); border-radius: 4px;
  color: inherit; font-family: inherit; font-size: 14px;
  padding: 3px 2px; outline: none;
}
.drawer-close { margin-top: auto; }

/* ---------- 召喚動畫層 ---------- */
#videoLayer {
  position: fixed; inset: 0; z-index: 50;
  opacity: 0; transition: opacity 0.35s ease;
}
#videoLayer.show { opacity: 1; }
#videoDim {
  position: absolute; inset: 0;
  background: rgba(2, 4, 12, 0.85);
}
#summonVideo {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  /* Blender 黑底渲染 → screen 混合，視覺上等同透明背景 */
  mix-blend-mode: screen;
}
#fxCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- SSR 爆光疊加 ---------- */
#ssrVideo {
  position: fixed; inset: 0; z-index: 65;
  width: 100%; height: 100%; object-fit: cover;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* ---------- 結果層 ---------- */
#resultLayer {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease;
}
#resultLayer.show { opacity: 1; }
#resultBackdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 60% at 50% 46%, rgba(72, 58, 18, 0.35) 0%, transparent 65%),
    rgba(4, 6, 16, 0.82);
}
#resultStage {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 26px;
}
#resultCard {
  position: relative;
  width: min(320px, 72vw, 52vh);
  aspect-ratio: 2 / 3;
  color: #ddd;
}
#resultCard.pop { animation: cardPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes cardPop {
  0% { transform: scale(0.62); opacity: 0; filter: brightness(2.4); }
  62% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); filter: brightness(1); }
}
#resultCardBg {
  position: absolute; inset: 5%;
  border-radius: 12px;
  background:
    radial-gradient(120% 90% at 50% 0%, #25315e 0%, #131a36 52%, #0a0e20 100%);
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.55);
}
#resultFrame {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: fill;
  pointer-events: none;
}
#resultInner {
  position: absolute; inset: 11% 14%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  text-align: center;
}
#resultRarity {
  position: absolute; top: 0;
  font-size: 16px; letter-spacing: 0.3em; text-indent: 0.3em;
  padding: 4px 16px;
  border: 1px solid currentColor; border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}
#resultName {
  font-size: clamp(40px, 9vmin, 62px);
  color: #fff; letter-spacing: 0.12em;
  text-shadow: 0 0 22px rgba(255, 235, 180, 0.5), 0 2px 8px rgba(0, 0, 0, 0.8);
}
#resultTitle {
  display: flex; align-items: center; justify-content: center;
  width: min(250px, 60vw);
  aspect-ratio: 2.4;
  background: url("assets/images/result_panel.png") center / contain no-repeat;
  font-size: 19px; letter-spacing: 0.3em; text-indent: 0.3em;
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}
#resultCard.R   { color: var(--r-color); }
#resultCard.SR  { color: var(--sr-color); }
#resultCard.SR  #resultCardBg { background: radial-gradient(120% 90% at 50% 0%, #33285e 0%, #1b1438 52%, #0d0a20 100%); }
#resultCard.SSR { color: var(--ssr-color); filter: drop-shadow(0 0 32px rgba(255, 217, 122, 0.5)); }
#resultCard.SSR #resultCardBg { background: radial-gradient(120% 90% at 50% 0%, #4d3c14 0%, #241a06 55%, #120d04 100%); }
#resultCard.SSR.pop { animation: cardPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1), ssrGlow 2.2s ease-in-out 0.6s infinite; }
@keyframes ssrGlow {
  0%, 100% { filter: drop-shadow(0 0 26px rgba(255, 217, 122, 0.42)); }
  50% { filter: drop-shadow(0 0 46px rgba(255, 226, 150, 0.72)); }
}
#resultActions { display: flex; gap: 16px; }

/* SSR 登場時的輕微震屏 */
body.ssr-shake #app { animation: shake 0.55s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -2px); }
}

/* ---------- 閃光 / 提示 ---------- */
#flash {
  position: fixed; inset: 0; z-index: 80; pointer-events: none;
  background: radial-gradient(circle at 50% 48%, rgba(255, 243, 210, 0.96) 0%, rgba(255, 255, 255, 0) 72%);
  opacity: 0;
}
#flash.boom { animation: flashFade 0.65s ease-out; }
@keyframes flashFade { from { opacity: 1; } to { opacity: 0; } }

#toast {
  position: fixed; top: 16%; left: 50%; z-index: 90;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 16px; letter-spacing: 0.2em;
  color: var(--gold-bright);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6), 0 0 18px rgba(232, 198, 107, 0.25);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
#toast.show { opacity: 1; }

/* ---------- 行動裝置 ---------- */
@media (max-width: 760px) {
  #sectName { font-size: 15px; letter-spacing: 0.22em; }
  .btn { padding: 7px 12px; font-size: 13px; }
  #circleWrap { width: min(62vmin, 360px); }
  #btnSummon { height: 72px; }
  .btn-summon-text { font-size: 20px; }
  #altarHint { font-size: 13px; }
  #logbar { padding: 8px 14px 12px; }
  #resultName { letter-spacing: 0.08em; }
}
