/* ============================================================
   base —— reset、版面骨架、頂/底導覽、美術槽佔位樣式
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --pointer-x: 50%;
  --pointer-y: 16%;
  --parallax-x: 0px;
  --parallax-y: 0px;
}
html, body { height: 100%; overflow-x: clip; }
body {
  font-family: var(--font);
  background:
    linear-gradient(rgba(0, 229, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 77, 255, .035) 1px, transparent 1px),
    radial-gradient(1000px 520px at 78% -8%, rgba(124, 77, 255, .22) 0, transparent 58%),
    radial-gradient(820px 460px at -8% 6%, rgba(0, 229, 255, .16) 0, transparent 54%),
    radial-gradient(640px 340px at 50% 100%, rgba(255, 61, 127, .08) 0, transparent 58%),
    var(--bg);
  background-size: 36px 36px, 36px 36px, auto, auto, auto, auto;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(120deg, transparent 0 46%, rgba(0, 229, 255, .05) 47%, transparent 49% 100%),
    linear-gradient(240deg, transparent 0 58%, rgba(124, 77, 255, .06) 59%, transparent 61% 100%);
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; color: inherit; border: none; background: none; cursor: pointer; }
input, select, textarea { font-family: inherit; }
h1, h2, h3 { line-height: 1.25; }

#app { min-height: 100%; display: flex; flex-direction: column; }

#view {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-7);
}

/* ---------- Soft Store skin：降低 AI / 賽博感 ---------- */
body {
  background:
    linear-gradient(135deg, rgba(24,169,153,.08) 0 14%, transparent 14% 100%),
    linear-gradient(62deg, transparent 0 69%, rgba(255,122,102,.10) 69% 70.5%, transparent 70.5% 100%),
    radial-gradient(560px 300px at var(--pointer-x) var(--pointer-y), rgba(255,255,255,.82), transparent 68%),
    linear-gradient(180deg, #f7f9fc 0, var(--bg) 42%, #eef3f7 100%);
}
body::before {
  background:
    linear-gradient(180deg, rgba(255,255,255,.62), transparent 46%),
    radial-gradient(1px 1px at 22px 18px, rgba(23,33,43,.075) 1px, transparent 1.5px),
    repeating-linear-gradient(0deg, transparent 0 42px, rgba(23,33,43,.025) 42px 43px),
    repeating-linear-gradient(90deg, transparent 0 42px, rgba(23,33,43,.018) 42px 43px);
  background-size: auto, 28px 28px, auto, auto;
  mask-image: none;
}
body::after {
  content: "";
  position: fixed;
  inset: -80px;
  z-index: -1;
  pointer-events: none;
  opacity: .8;
  background:
    linear-gradient(118deg, transparent 0 10%, rgba(24,169,153,.13) 10% 11%, transparent 11% 100%),
    linear-gradient(118deg, transparent 0 82%, rgba(24,169,153,.10) 82% 83%, transparent 83% 100%),
    linear-gradient(68deg, transparent 0 73%, rgba(255,122,102,.13) 73% 74.5%, transparent 74.5% 100%),
    linear-gradient(150deg, transparent 0 28%, rgba(91,110,225,.08) 28% 29%, transparent 29% 100%),
    repeating-linear-gradient(135deg, transparent 0 68px, rgba(23,33,43,.026) 68px 69px, transparent 69px 116px);
  transform: translate3d(calc(var(--parallax-x) * .28), calc(var(--parallax-y) * .28), 0);
  transition: transform .18s ease-out;
}
.topbar {
  background: var(--overlay);
  border-bottom-color: rgba(216, 225, 234, .9);
  box-shadow: 0 1px 0 rgba(23, 33, 43, .04), 0 8px 24px rgba(24, 34, 45, .06);
}
.searchbar {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: none;
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring-cyan);
}
.topnav > a.active {
  color: var(--text);
  text-shadow: none;
}
.topnav > a::after {
  background: var(--accent);
  height: 3px;
}
.badge-count {
  background: var(--accent-2);
  color: #fff;
  box-shadow: none;
}
.art-img:not(.card__art) {
  border-color: rgba(216, 225, 234, .8);
  box-shadow: none;
}
.toast {
  background: var(--text);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
}
@media (max-width: 860px) {
  .bottomnav {
    background: var(--overlay);
    border-top-color: var(--line);
  }
  .bottomnav > a.active .bn-ico { filter: none; }
}

/* ---------- 頂欄 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-4);
  background:
    linear-gradient(90deg, rgba(0, 229, 255, .06), transparent 28%, rgba(124, 77, 255, .07)),
    var(--overlay);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 rgba(0, 229, 255, .12), 0 10px 30px rgba(0, 0, 0, .45);
}
.brand { display: flex; align-items: center; flex: none; }
.brand-logo { font-weight: 800; letter-spacing: .5px; font-size: 18px; color: var(--text); }
.searchbar {
  flex: 1; max-width: 520px;
  display: flex; align-items: center; gap: var(--sp-2);
  background: linear-gradient(180deg, rgba(255,255,255,.035), transparent), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 8px 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.025);
}
.searchbar:focus-within { border-color: rgba(0, 229, 255, .72); box-shadow: var(--ring-cyan), var(--glow-cyan); }
.searchbar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px;
}
.searchbar input::placeholder { color: var(--text-dim); }
.search-clear { width: 22px; height: 22px; flex: none; border-radius: 50%; color: var(--text-dim); font-size: 12px; background: var(--surface-2); }
.search-clear:hover { color: var(--text); }

/* 切頁淡入 */
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#view.view-in { animation: viewIn .22s ease both; }
@media (prefers-reduced-motion: reduce) { #view.view-in { animation: none; } }
.topnav { display: flex; align-items: center; gap: var(--sp-5); margin-left: auto; }
.topnav > a {
  position: relative;
  color: var(--text-soft); font-size: 14px; font-weight: 700;
  padding: 8px 0;
}
.topnav > a:hover { color: var(--text); }
.topnav > a.active { color: var(--accent); text-shadow: 0 0 14px rgba(0,229,255,.45); }
.topnav > a::after {
  content: ""; position: absolute; left: 50%; right: 50%; bottom: 2px; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: .18s ease;
}
.topnav > a:hover::after, .topnav > a.active::after { left: 0; right: 0; }
.nav-cart { display: flex; align-items: center; gap: 6px; position: relative; }

/* ---------- 底部導覽（手機）---------- */
.bottomnav { display: none; }

/* ---------- 計數徽章 ---------- */
.badge-count {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; line-height: 1;
  background: linear-gradient(135deg, var(--badge-hot), var(--accent-2)); color: #fff;
  border-radius: var(--r-pill);
  box-shadow: 0 0 14px rgba(255, 61, 127, .38);
}
.badge-count[data-count]:not(.on) { display: none; }

/* ---------- 美術槽佔位（白膜）：有配色 + 代表符號的封面磚 ---------- */
.art-slot {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  container-type: size;
  border-radius: var(--r-md);
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.12), transparent 42%, rgba(0,0,0,.28)),
    radial-gradient(120% 120% at 28% 22%, hsl(var(--h, 220) 95% 68% / .55), transparent 55%),
    linear-gradient(150deg, hsl(var(--h, 220) 70% 42%), hsl(calc(var(--h, 220) + 40) 72% 28%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), inset 0 0 30px rgba(0, 229, 255, .12);
}
.art-slot__emoji {
  position: relative; z-index: 1;
  font-size: 40cqmin; line-height: 1;
  filter: drop-shadow(0 3px 9px rgba(0,0,0,.38));
}
.art-slot--round { border-radius: var(--r-pill); }

/* Codex 換上真圖後的樣式（取代同位置的 .art-slot 佔位）*/
.art-img { width: 100%; display: block; object-fit: cover; border-radius: var(--r-md); background: var(--surface); }
.art-img:not(.card__art) { border: 1px solid rgba(255,255,255,.045); box-shadow: inset 0 0 0 1px rgba(0,229,255,.04); }
.art-img.is-round { border-radius: var(--r-pill); }
.art-img.card__art { border-radius: 0; }
/* id / 尺寸文字：正常模式隱藏，只在「🎨 美術槽」開發模式由 ::after 標示 */
.art-slot__id, .art-slot__size { display: none; }

/* 內嵌字形佔位（icon / logo）：白膜用 emoji 暫代 */
.glyph { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.glyph--sm { font-size: 14px; }

/* ---------- 「標示美術槽」模式 ---------- */
body.show-slots [data-art-slot] {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
  position: relative;
}
body.show-slots [data-art-slot]::after {
  content: attr(data-art-slot) " · " attr(data-art-size);
  position: absolute; left: 0; bottom: 100%;
  font: 700 10px/1.4 var(--font);
  background: var(--accent-2); color: #2a0f08;
  padding: 1px 5px; border-radius: 4px 4px 4px 0;
  white-space: nowrap; z-index: 5; pointer-events: none;
}

/* ---------- 美術槽切換鈕 ---------- */
.slot-toggle {
  position: fixed; right: 16px; bottom: 20px; z-index: 60;
  padding: 9px 14px; font-size: 13px; font-weight: 700;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}
body.show-slots .slot-toggle { background: var(--accent-2); color: #2a0f08; border-color: transparent; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 70;
  opacity: 0; pointer-events: none; transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   RWD —— 窄螢幕（手機）
   ============================================================ */
@media (max-width: 860px) {
  .topnav { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .brand-logo img { width: 98px !important; }
  .searchbar { max-width: none; min-width: 0; padding: 8px 10px; }
  .searchbar input { min-width: 0; }
  #view { padding-bottom: calc(var(--bottomnav-h) + var(--sp-6)); }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: var(--bottomnav-h);
    background:
      linear-gradient(90deg, rgba(0,229,255,.08), rgba(124,77,255,.08)),
      var(--overlay);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line-soft);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav > a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--text-dim); font-size: 11px; font-weight: 600; position: relative;
  }
  .bottomnav > a.active { color: var(--accent); }
  .bottomnav > a.active .bn-ico { filter: drop-shadow(0 0 10px rgba(0,229,255,.55)); }
  .bn-ico { font-size: 20px; }
  .bn-cart .badge-count { position: absolute; top: 6px; right: 50%; margin-right: -22px; }
  .slot-toggle { bottom: calc(var(--bottomnav-h) + 12px); }
  .toast { bottom: calc(var(--bottomnav-h) + 16px); }
}
