/*
 * itemIcon.css — 아이템 아이콘, 설명 카드(툴팁), 꾸민 글자 (게임·편집기 공용)
 *
 * 아이콘 그림은 32×32 픽셀아트라서, 흐려지지 않도록 정확히 1배·2배·3배 크기로만 보여 줘요.
 *   sm = 32px(1배) · md = 64px(2배) · lg = 96px(3배)
 */

.item-icon {
  --item-color: #8c8273;
  --gem: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 64px;
  height: 64px;
  vertical-align: middle;
  user-select: none;
}
.item-icon.size-sm { width: 32px; height: 32px; }
.item-icon.size-lg { width: 96px; height: 96px; }

.item-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* 그림이 없을 때: 대표색 + 이름 첫 글자 (모서리를 계단 모양으로 깎은 타일) */
.item-icon.no-image {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.35), transparent 55%),
    var(--item-color);
  clip-path: polygon(
    0 12%, 6% 12%, 6% 6%, 12% 6%, 12% 0, 88% 0, 88% 6%, 94% 6%, 94% 12%, 100% 12%,
    100% 88%, 94% 88%, 94% 94%, 88% 94%, 88% 100%, 12% 100%, 12% 94%, 6% 94%, 6% 88%, 0 88%
  );
  box-shadow: inset 0 0 0 3px rgba(40, 26, 16, 0.55), inset 0 -6px 0 rgba(40, 26, 16, 0.2);
}
.item-icon-glyph {
  font-family: 'Song Myung', 'Gowun Batang', serif;
  font-size: 30px;
  line-height: 1;
  color: #fffaf0;
  text-shadow: 0 2px 0 rgba(40, 26, 16, 0.6);
}
.item-icon.size-sm .item-icon-glyph { font-size: 16px; }
.item-icon.size-lg .item-icon-glyph { font-size: 44px; }

/* 희귀도: 왼쪽 위 작은 보석 */
.item-icon.rarity-uncommon { --gem: #5f9a62; }
.item-icon.rarity-rare { --gem: #8a62c4; }
.item-icon.rarity-legendary { --gem: #e0a92e; }
.item-icon.rarity-uncommon::before,
.item-icon.rarity-rare::before,
.item-icon.rarity-legendary::before {
  content: '';
  position: absolute;
  left: -2px;
  top: -2px;
  z-index: 2;
  width: 8px;
  height: 8px;
  background: var(--gem);
  box-shadow: 0 0 0 2px #fff6e0, 0 0 0 3px rgba(58, 39, 24, 0.6);
  transform: rotate(45deg);
}
.item-icon.size-sm::before { width: 6px; height: 6px; left: -1px; top: -1px; }
.item-icon.rarity-legendary img { filter: drop-shadow(0 0 3px rgba(240, 190, 70, 0.9)); }

/* 모르는 아이템 (도감) */
.item-icon.is-unknown {
  color: var(--ink-soft, #8a7258);
  font-family: 'Song Myung', serif;
  font-size: 26px;
  background: rgba(139, 90, 52, 0.08);
  box-shadow: inset 0 0 0 2px rgba(139, 90, 52, 0.35);
}
.item-icon.size-sm.is-unknown { font-size: 16px; }
.item-icon.is-silhouette img { filter: brightness(0) opacity(0.28); }
.item-icon.is-silhouette::before { display: none; }
.item-icon.is-silhouette.no-image { background: rgba(58, 39, 24, 0.22); box-shadow: none; }
.item-icon.is-silhouette .item-icon-glyph { visibility: hidden; }
.item-icon.is-missing { color: #c0533f; font-weight: bold; box-shadow: inset 0 0 0 2px #c0533f; }

/* 개수 (오른쪽 아래) */
.item-icon-count {
  position: absolute;
  right: -6px;
  bottom: -5px;
  z-index: 2;
  min-width: 22px;
  padding: 0 4px;
  background: #fff8e8;
  box-shadow: 0 0 0 2px #3a2718;
  color: #3a2718;
  font: 700 12px/18px 'Gowun Batang', serif;
  text-align: center;
}
.item-icon.size-sm .item-icon-count { right: -8px; bottom: -6px; min-width: 16px; font-size: 10px; line-height: 14px; }

/* 품질 별 (오른쪽 위 — 왼쪽 위는 희귀도 보석 자리): ★ 좋음 · ★★ 훌륭함 · ★★★ 걸작 */
.item-icon-grade {
  position: absolute;
  right: -5px;
  top: -6px;
  z-index: 2;
  padding: 0 3px;
  background: #fff8e8;
  box-shadow: 0 0 0 2px #3a2718;
  color: #b8860b;
  font: 700 10px/14px 'Gowun Batang', serif;
  letter-spacing: -1px;
  white-space: nowrap;
}
.item-icon.grade-2 .item-icon-grade { color: #c0392b; }
.item-icon.grade-3 .item-icon-grade { background: #3a2718; color: #ffd75e; box-shadow: 0 0 0 2px #e0a92e, 0 0 6px rgba(255, 200, 60, 0.8); }
.item-icon.size-sm .item-icon-grade { right: -6px; top: -7px; font-size: 8px; line-height: 11px; }
.item-icon.size-lg .item-icon-grade { font-size: 14px; line-height: 18px; }
.tt-grade { font-weight: 700; color: #b8860b; }
.tt-grade.grade-3 { color: #c0392b; }

/* 원소 배지 · 효능 태그 */
.trait-line { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.attr-icon { width: 16px; height: 16px; image-rendering: pixelated; vertical-align: -3px; flex: none; }
.trait-attr { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px 0 3px; background: color-mix(in srgb, var(--attr) 16%, #fffaf0); box-shadow: 0 0 0 1.5px var(--attr); color: var(--attr); font-size: 12px; font-weight: 700; line-height: 18px; white-space: nowrap; }
.trait-attr.is-special { background: #12302a; color: #8fe0c8; box-shadow: 0 0 0 1.5px #2e6b5e, 0 0 6px rgba(80, 200, 170, 0.5); }
.trait-tag { font-size: 12px; color: #7a6a58; line-height: 18px; white-space: nowrap; }
.trait-tag.is-special { color: #7a3fa0; font-weight: 700; }

/* ───────── 설명 카드 ───────── */
.tooltip {
  --face: #fbf4e2;
  --line: #3a2718;
  --hi: rgba(255, 255, 255, 0.7);
  --lo: rgba(94, 70, 48, 0.15);
  --px: 3px;
  position: fixed;
  z-index: 1000;
  max-width: 300px;
  padding: 11px 14px 12px;
  background-color: var(--face);
  box-shadow:
    inset 0 var(--px) 0 0 var(--hi),
    inset 0 calc(-1 * var(--px)) 0 0 var(--lo),
    0 calc(-1 * var(--px)) 0 0 var(--line),
    0 var(--px) 0 0 var(--line),
    calc(-1 * var(--px)) 0 0 0 var(--line),
    var(--px) 0 0 0 var(--line),
    0 calc(2 * var(--px)) 0 0 rgba(58, 39, 24, 0.2);
  color: #3a2718;
  font-family: 'Gowun Batang', 'Batang', serif;
  font-size: 14px;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}
.tooltip.is-visible { opacity: 1; transform: none; }
.tooltip .tt-name { font-family: 'Song Myung', serif; font-size: 18px; color: #74281c; }
.tooltip .tt-meta { margin-bottom: 6px; font-size: 12px; color: #8a7258; }
.tooltip .tt-battle { margin-top: 6px; color: #8b2f22; font-size: 13px; font-weight: 700; }
.tooltip .tt-price { margin-top: 6px; padding-top: 5px; border-top: 2px dotted rgba(139, 90, 52, 0.35); font-size: 13px; color: #7d5a1e; }

/* 꾸민 글자: 줄바꿈 그대로 보이게 */
.tf { white-space: pre-line; }
.tf-unknown { outline: 1px dashed #c0533f; outline-offset: 1px; color: #c0533f; }
