/* 闇蝕 Duskfall — Web Portal shared stylesheet
   Dark ARPG theme, mobile-first, responsive. Works cleanly at 380px width. */

:root {
  /* Base palette (mirrors the game web boot: deep violet-black) */
  --bg:        #07070a;
  --bg-2:      #0e0c16;
  --panel:     #14111f;
  --panel-2:   #1b1730;
  --border:    #302747;
  --border-2:  #47396b;
  --ink:       #d8d2e8;
  --ink-dim:   #9a92b4;
  --ink-faint: #6f6890;
  --accent:    #9a6adf;
  --accent-2:  #c9b8f0;
  --accent-deep:#4a2f7a;
  --good:      #4bd18a;
  --warn:      #f0a94c;
  --danger:    #e05b6a;

  /* Rarity tokens (match affixes.json rarity_tiers color_hex) */
  --r-common:    #c8c8c8; /* white  */
  --r-uncommon:  #4c8cff; /* blue / magic */
  --r-rare:      #ffe14c; /* yellow */
  --r-unique:    #c99a2e; /* gold   */
  --r-set:       #2ecc71; /* green  */
  --r-legendary: #ff8c1a; /* orange */

  --radius: 12px;
  --radius-sm: 8px;
  --tap: 44px; /* min touch target */
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC",
          "Microsoft JhengHei", system-ui, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #17122b 0%, rgba(7,7,10,0) 60%),
    var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: #fff; }

img { max-width: 100%; height: auto; }

h1, h2, h3 { color: var(--ink); font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.7rem; letter-spacing: .01em; }
h2 { font-size: 1.3rem; margin: 1.6rem 0 .8rem; }
h3 { font-size: 1.05rem; }

p { color: var(--ink-dim); }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(10,9,17,0.86);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }
.nav-brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; color: var(--accent-2); font-size: 1.02rem;
  letter-spacing: .04em; white-space: nowrap; margin-right: 8px;
  flex-shrink: 0;
}
.nav-brand img { width: 26px; height: 26px; border-radius: 7px; }
.nav-brand .en { font-size: .62rem; letter-spacing: .28em; color: var(--ink-faint); }
.nav-links { display: flex; gap: 2px; flex-shrink: 0; }
.nav a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 13px;
  color: var(--ink-dim); font-size: .95rem; font-weight: 600;
  border-radius: var(--radius-sm); white-space: nowrap;
}
.nav a:hover { background: var(--panel); color: var(--ink); }
.nav a.active { color: var(--accent-2); background: var(--panel-2); }

/* language toggle (header) */
.lang-toggle {
  display: inline-flex; align-items: center; margin-left: 6px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); overflow: hidden;
}
.lang-btn {
  min-height: 32px; padding: 0 11px; border: none; background: transparent;
  color: var(--ink-dim); font-size: .84rem; font-weight: 700; cursor: pointer;
  font-family: inherit; letter-spacing: .02em;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border-2); }
.lang-btn.on { background: var(--accent); color: #fff; }
.lang-btn:not(.on):hover { background: var(--panel-2); color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff; font-weight: 700; font-size: 1rem;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  box-shadow: 0 2px 14px rgba(122,74,200,.35);
  transition: transform .08s ease, box-shadow .15s ease;
}
.btn:hover { color: #fff; box-shadow: 0 4px 20px rgba(122,74,200,.5); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--border-2); box-shadow: none;
}
.btn.ghost:hover { background: var(--panel); border-color: var(--accent); }
.btn.sm { min-height: 36px; padding: 0 13px; font-size: .88rem; }

/* ---------- Cards / panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 48px 16px 40px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(122,74,200,.22) 0%, rgba(7,7,10,0) 65%);
}
.hero img.logo { width: 118px; height: 118px; border-radius: 26px;
  box-shadow: 0 8px 40px rgba(122,74,200,.4); border: 1px solid var(--border-2); }
.hero .title { font-size: 2.9rem; font-weight: 800; margin: 16px 0 2px;
  color: var(--accent-2); letter-spacing: .06em;
  text-shadow: 0 3px 24px rgba(0,0,0,.7); }
.hero .en { font-size: .8rem; letter-spacing: .5em; color: var(--ink-faint); margin-bottom: 10px; }
.hero .tagline { font-size: 1.1rem; color: var(--ink-dim); max-width: 620px; margin: 8px auto 22px; }
.hero .cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
@media (max-width: 560px) { .grid.two { grid-template-columns: 1fr; } }

/* ---------- Item card ---------- */
.item-card {
  display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color .15s ease, transform .08s ease, box-shadow .15s ease;
  text-align: left;
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(0,0,0,.5); }
.item-card .icon-wrap {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm);
  background: radial-gradient(ellipse at 50% 40%, #1c1730 0%, #0c0a15 100%);
  position: relative; overflow: hidden;
}
.item-card .icon-wrap svg { width: 74%; height: 74%; }
.item-card .badge-plus {
  position: absolute; top: 5px; right: 6px;
  font-size: .72rem; font-weight: 800; color: #fff;
  background: rgba(0,0,0,.55); border: 1px solid var(--border-2);
  border-radius: 6px; padding: 1px 6px;
}
.item-card .iname { font-weight: 700; font-size: .98rem; line-height: 1.2; }
.item-card .iaffix { display: flex; flex-wrap: wrap; gap: 4px; margin: 1px 0; }
.item-card .iaffix .aff {
  font-size: .72rem; line-height: 1.35; color: var(--accent-2);
  background: rgba(154,106,223,.12); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; white-space: nowrap;
}
.item-card .isub { font-size: .78rem; color: var(--ink-faint); }
.item-card .meta-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.item-card .price { font-weight: 800; color: var(--warn); font-size: .96rem; white-space: nowrap; }
.item-card .price::before { content: "◆ "; color: #d9b24a; }

/* rarity coloring for name + border glow */
.r-common    { color: var(--r-common); }
.r-uncommon  { color: var(--r-uncommon); }
.r-rare      { color: var(--r-rare); }
.r-unique    { color: var(--r-unique); }
.r-set       { color: var(--r-set); }
.r-legendary { color: var(--r-legendary); }
.rb-common    { border-color: rgba(200,200,200,.35); }
.rb-uncommon  { border-color: rgba(76,140,255,.55);  box-shadow: 0 0 0 1px rgba(76,140,255,.12) inset; }
.rb-rare      { border-color: rgba(255,225,76,.55);  box-shadow: 0 0 0 1px rgba(255,225,76,.12) inset; }
.rb-unique    { border-color: rgba(201,154,46,.7);   box-shadow: 0 0 14px rgba(201,154,46,.18) inset; }
.rb-set       { border-color: rgba(46,204,113,.65);  box-shadow: 0 0 14px rgba(46,204,113,.18) inset; }
.rb-legendary { border-color: rgba(255,140,26,.75);  box-shadow: 0 0 16px rgba(255,140,26,.22) inset; }

/* ---------- Chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 600; color: var(--ink-dim);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px;
}
.chip.update { color: #b9a2ff; border-color: rgba(154,106,223,.5); }
.chip.event  { color: #6fd7a0; border-color: rgba(46,204,113,.5); }
.chip.patch  { color: #f0c060; border-color: rgba(240,169,76,.5); }

/* ---------- Controls (search / sort) ---------- */
.controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 4px 0 18px;
}
.controls input[type="search"], .controls input[type="text"] {
  flex: 1 1 220px; min-height: var(--tap);
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); color: var(--ink);
  padding: 0 14px; font-size: 1rem;
}
.controls input:focus { outline: none; border-color: var(--accent); }
.controls select {
  min-height: var(--tap);
  background: var(--panel); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); color: var(--ink);
  padding: 0 12px; font-size: .95rem; font-weight: 600;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-row .pill {
  min-height: 36px; padding: 0 13px;
  display: inline-flex; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; color: var(--ink-dim); font-size: .86rem;
  font-weight: 600; cursor: pointer;
}
.filter-row .pill.active { background: var(--accent-deep); color: #fff; border-color: var(--accent); }

/* ---------- Tables (rankings) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius); }
table.rank {
  width: 100%; border-collapse: collapse; min-width: 640px;
  font-size: .92rem;
}
table.rank th, table.rank td { padding: 11px 12px; text-align: right; white-space: nowrap; }
table.rank th:first-child, table.rank td:first-child,
table.rank th.tl, table.rank td.tl { text-align: left; }
table.rank thead th {
  position: sticky; top: 0; background: var(--panel-2);
  color: var(--ink); font-weight: 700; border-bottom: 1px solid var(--border-2);
  cursor: pointer; user-select: none;
}
table.rank thead th:hover { color: var(--accent-2); }
table.rank thead th.sorted::after { content: " ▾"; color: var(--accent); }
table.rank tbody tr { border-bottom: 1px solid rgba(48,39,71,.5); cursor: pointer; }
table.rank tbody tr:hover { background: var(--panel); }
table.rank tbody tr:nth-child(even) { background: rgba(20,17,31,.4); }
table.rank .rank-no { color: var(--ink-faint); font-weight: 800; }
table.rank .rank-no.top { color: var(--warn); }
table.rank .cp { color: var(--accent-2); font-weight: 800; }

/* ---------- Stat blocks ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-box {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.stat-box .k { font-size: .74rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.stat-box .v { font-size: 1.4rem; font-weight: 800; color: var(--ink); margin-top: 2px; }
.stat-box .v.big { font-size: 1.9rem; color: var(--accent-2); }

/* ---------- UID / copy ---------- */
.uid-box {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px dashed var(--border-2);
  border-radius: var(--radius); padding: 16px 18px; margin: 16px 0;
}
.uid-box .uid-label { font-size: .78rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; }
.uid-box .uid-num {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 1.9rem; font-weight: 800; color: var(--accent-2);
  letter-spacing: .04em; word-break: break-all;
}
.note {
  background: rgba(240,169,76,.08); border: 1px solid rgba(240,169,76,.3);
  border-radius: var(--radius-sm); padding: 13px 15px; color: var(--ink-dim);
  font-size: .93rem; margin: 14px 0;
}
.note strong { color: var(--warn); }

/* ---------- Empty / error states ---------- */
.empty {
  text-align: center; padding: 60px 20px; color: var(--ink-faint);
}
.empty .big { font-size: 2.4rem; margin-bottom: 8px; opacity: .5; }
.empty .msg { font-size: 1.05rem; color: var(--ink-dim); }
.empty .sub { font-size: .88rem; color: var(--ink-faint); margin-top: 6px; }

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 22px 0; }
.pager .info { color: var(--ink-faint); font-size: .9rem; }

/* ---------- Section / feature ---------- */
.section { padding: 26px 0; }
.feature {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.feature .fi { font-size: 1.7rem; margin-bottom: 6px; }
.feature h3 { margin: 0 0 6px; color: var(--accent-2); }
.feature p { margin: 0; font-size: .93rem; }

/* class card */
.class-card { text-align: center; }
.class-card .cc-name { font-size: 1.3rem; font-weight: 800; color: var(--accent-2); }
.class-card .cc-en { font-size: .72rem; letter-spacing: .2em; color: var(--ink-faint); }
.class-card .cc-attr { margin-top: 8px; }

/* news post */
.news-post { border-left: 3px solid var(--accent-deep); padding: 4px 0 4px 14px; margin-bottom: 18px; }
.news-post .np-date { font-size: .78rem; color: var(--ink-faint); }
.news-post h3 { margin: 3px 0 5px; }
.news-post p { margin: 0; font-size: .94rem; }

/* zone list */
.zone-act { margin: 22px 0 10px; color: var(--accent-2); font-size: 1.05rem; font-weight: 700; }
.zone-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 8px;
}
.zone-row .zbadge {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: .95rem;
}
.zone-row .zname { font-weight: 700; }
.zone-row .zsub { font-size: .8rem; color: var(--ink-faint); }

/* equipped slot list */
.equip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border); margin-top: 40px;
  padding: 26px 16px calc(30px + env(safe-area-inset-bottom));
  text-align: center; color: var(--ink-faint); font-size: .84rem;
}
.footer a { color: var(--ink-dim); }
.footer .foot-note { max-width: 560px; margin: 8px auto 0; }

/* ---------- Loading spinner ---------- */
.loading { text-align: center; padding: 50px; color: var(--ink-faint); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* page heading block */
.page-head { padding: 26px 0 8px; }
.page-head .en { font-size: .72rem; letter-spacing: .3em; color: var(--ink-faint); }
.page-head p { margin: 6px 0 0; }

/* responsive type */
@media (max-width: 480px) {
  .hero .title { font-size: 2.2rem; }
  h1 { font-size: 1.45rem; }
  .uid-box .uid-num { font-size: 1.5rem; }
  .grid.cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
