/**
 * Diablo IV talisman stylesheet.
 * Author: vlad1116
 * Website: https://arpg-life.ru
 * Version: 0.4.0
 *
 * Shared by the admin builder (interactive) and the public planner
 * (read-only) — both render the same markup from assets/js/talisman.js.
 * Depends on class-mechanics.css being loaded first: talisman.js emits
 * .d4cm-panel/.d4cm-title/.d4cm-empty directly, reusing that stylesheet's
 * rules and CSS variables wholesale.
 *
 * UI matches the reference planner's talisman picker (checked live, and
 * against a screenshot of the user's own session): a circular
 * "wheel" — a central seal slot with 6 hexagonal charm slots arranged
 * around it at 60° increments, thin lines connecting center to each slot —
 * whose slots open a MODAL — search + category sidebar + a card grid where
 * every card already shows its full effect text (not hover-only). No
 * .d4cm-tooltip rule needed here — hover tooltips for seals/charms come
 * entirely from diablo4-items-tooltip's own .d4-tooltip-v2 component,
 * loaded separately.
 */

/* ---- talisman wheel (seal + 6 charm slots over the talisman artwork) --- */
/* The reference planner's look: the talisman artwork under a dark vignette,
   the seal in its round frame in the center, the charm slots' own frames
   (empty / locked) around it. Sized from the container's width (cqw), so
   it scales with the column it sits in. */

.d4t-wheel {
  position: relative;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 14px;
  container-type: inline-size;
  overflow: hidden;
  border-radius: 4px;
  background:
    radial-gradient(ellipse farthest-corner at center, transparent 45%, rgba(0, 0, 0, .8)),
    url('../images/talisman/background.webp') center / 120% auto no-repeat,
    #0d0b09;
  box-shadow: inset 0 0 32px #000, 0 0 0 1px #2a241b;
}

.d4t-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17cqw;
  aspect-ratio: 320 / 392;
  padding: 0;
  border: none;
  background: url('../images/talisman/charm-slot.webp') center / contain no-repeat;
  color: var(--d4cm-text);
  cursor: pointer;
  transition: filter .15s ease, transform .15s ease;
}

.d4t-slot:hover:not(:disabled) {
  filter: brightness(1.18);
  transform: translate(-50%, -50%) scale(1.06);
}

.d4t-slot:focus-visible {
  outline: 2px solid var(--d4cm-gold);
  outline-offset: 2px;
}

.d4t-slot--seal {
  z-index: 2;
  width: 23cqw;
  aspect-ratio: 340 / 376;
  background-image: url('../images/talisman/seal-slot.webp');
}

.d4t-slot.is-locked {
  background-image: url('../images/talisman/charm-slot-locked.webp');
  cursor: default;
}

.d4t-slot:disabled {
  cursor: default;
}

/* The item itself, square, centred in the frame. */
.d4t-slot__icon {
  width: 54%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.d4t-slot--seal .d4t-slot__icon { width: 50%; }

.d4t-slot__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .8));
}

/* A faint rarity glow behind a filled slot's item. */
.d4t-slot.is-filled .d4t-slot__icon { border-radius: 50%; }
.d4t-slot--r-magic.is-filled .d4t-slot__icon { box-shadow: 0 0 14px 2px rgba(111, 158, 255, .35); }
.d4t-slot--r-rare.is-filled .d4t-slot__icon { box-shadow: 0 0 14px 2px rgba(255, 255, 0, .3); }
.d4t-slot--r-legendary.is-filled .d4t-slot__icon { box-shadow: 0 0 14px 2px rgba(232, 120, 60, .35); }
.d4t-slot--r-unique.is-filled .d4t-slot__icon { box-shadow: 0 0 14px 2px rgba(220, 167, 121, .4); }
.d4t-slot--r-mythic.is-filled .d4t-slot__icon { box-shadow: 0 0 16px 3px rgba(176, 120, 255, .4); }
.d4t-slot--r-set.is-filled .d4t-slot__icon { box-shadow: 0 0 14px 2px rgba(74, 222, 128, .35); }

/* The frames themselves show empty and locked — no extra glyphs. */
.d4t-slot__plus,
.d4t-slot__lock {
  display: none;
}

.d4t-icon-missing {
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(45deg, #201912, #201912 4px, #14120f 4px, #14120f 8px);
}

.d4t-set-bonuses {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--d4cm-line);
  font-size: 13px;
}

.d4t-set-bonus {
  margin-bottom: 6px;
}

.d4t-set-bonus .is-active {
  color: var(--d4cm-gold);
  font-weight: 600;
}

/* ---- modal ---------------------------------------------------------- */

.d4t-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.d4t-modal {
  width: min(760px, 100%);
  max-height: min(640px, 100%);
  display: flex;
  flex-direction: column;
  background: #0f0e0c;
  border: 1px solid var(--d4cm-line);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  overflow: hidden;
  color: var(--d4cm-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.d4t-modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--d4cm-line);
  flex-wrap: wrap;
}

.d4t-modal__title {
  font-family: Georgia, serif;
  color: #f0ddba;
  font-size: 15px;
  margin-right: auto;
}

.d4t-modal__search input {
  width: 180px;
  padding: 6px 10px;
  background: #14120f;
  border: 1px solid var(--d4cm-line);
  border-radius: 4px;
  color: var(--d4cm-text);
  font-size: 13px;
}

.d4t-modal__search input:focus {
  outline: none;
  border-color: var(--d4cm-gold);
}

.d4t-modal__unequip {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--d4cm-line);
  border-radius: 4px;
  color: var(--d4cm-muted);
  font-size: 12px;
  cursor: pointer;
}

.d4t-modal__unequip:hover {
  border-color: #b04a4a;
  color: #e08080;
}

.d4t-modal__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--d4cm-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}

.d4t-modal__close:hover {
  background: #201912;
  color: var(--d4cm-text);
}

.d4t-modal__body {
  display: flex;
  min-height: 0;
  flex: 1;
}

.d4t-modal__body--no-sidebar .d4t-modal__grid {
  padding-left: 14px;
}

.d4t-modal__sidebar {
  width: 140px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-right: 1px solid var(--d4cm-line);
  overflow-y: auto;
}

.d4t-modal__category {
  text-align: left;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--d4cm-muted);
  font-size: 13px;
  cursor: pointer;
}

.d4t-modal__category:hover {
  background: #14120f;
  color: var(--d4cm-text);
}

.d4t-modal__category.is-active {
  background: #201912;
  color: var(--d4cm-gold);
  font-weight: 600;
}

.d4t-modal__grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  align-content: start;
}

/* ---- cards ------------------------------------------------------------ */

.d4t-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: #14120f;
  border: 1px solid var(--d4cm-line);
  border-radius: 5px;
  color: var(--d4cm-text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, opacity .15s ease;
}

.d4t-card:hover:not(:disabled) {
  border-color: #8c6a3f;
  background: #1a1610;
}

.d4t-card.is-equipped {
  border-color: var(--d4cm-gold);
  box-shadow: 0 0 10px rgba(232, 185, 113, .2);
}

.d4t-card.is-locked {
  opacity: .4;
  cursor: default;
}

.d4t-card:disabled {
  cursor: default;
}

.d4t-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.d4t-card__icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #0f0e0c;
  border: 1px solid var(--d4cm-line);
}

.d4t-card__icon img {
  width: 100%;
  height: 100%;
  /* contain, not cover: unique charm icons are tall (2:3) — cover cut off
     their top and bottom in the round frame. */
  object-fit: contain;
  display: block;
}

.d4t-card__heading {
  min-width: 0;
  flex: 1;
}

.d4t-card__name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.d4t-card__subtitle {
  font-size: 10.5px;
  color: var(--d4cm-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.d4t-card__equipped-badge {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--d4cm-gold);
  border: 1px solid var(--d4cm-gold);
  border-radius: 3px;
  padding: 2px 6px;
}

.d4t-card__section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.d4t-card__section-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--d4cm-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 3px;
}

.d4t-card__line {
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-line;
  color: #cfcdd6;
}

/* Rarity-tinted name text — mirrors diablo4-items-tooltip's own
   .d4-rarity-* convention (magic/rare/legendary/unique/mythic) so a
   talisman card's color language matches every other item tooltip on the
   site, not a new palette invented for just this tab. */
.d4t-rarity-magic .d4t-card__name { color: #6f9eff; }
.d4t-rarity-rare .d4t-card__name { color: #ffff00; }
.d4t-rarity-legendary .d4t-card__name { color: #e8783c; }
.d4t-rarity-unique .d4t-card__name { color: #dca779; }
.d4t-rarity-mythic .d4t-card__name { color: #e05fd4; }
.d4t-rarity-set .d4t-card__name { color: #4ade80; }

@media (max-width: 560px) {
  .d4t-modal__sidebar {
    width: 100px;
  }
  .d4t-modal__grid {
    grid-template-columns: 1fr;
  }
  .d4t-modal__search input {
    width: 120px;
  }
}

/* ---- Rolled affixes: blue/yellow charms and the seal's own -------------- */

.d4t-modal__tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid #2a241b;
}

.d4t-modal__tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: var(--d4cm-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.d4t-modal__tab:hover { color: var(--d4cm-text); }

.d4t-modal__tab.is-active {
  border-color: #2a241b;
  background: #14120f;
  color: var(--d4cm-gold);
}

.d4t-modal__body--rolled {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 12px 16px 16px;
  min-height: 0;
}

.d4t-rolled-chosen {
  display: grid;
  gap: 6px;
}

.d4t-rolled-hint {
  color: var(--d4cm-muted);
  font-size: 12px;
}

.d4t-rolled-pick {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #8c6a3f;
  border-radius: 3px;
  background: #1a1610;
  font-size: 13px;
}

.d4t-rolled-pick.is-legendary { border-color: #a8582c; }

.d4t-rolled-pick__value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--d4cm-muted);
  font-size: 12px;
  white-space: nowrap;
}

.d4t-rolled-pick__value input {
  width: 78px;
  padding: 3px 6px;
  border: 1px solid #3a3226;
  border-radius: 3px;
  background: #0f0e0c;
  color: var(--d4cm-text);
  font: inherit;
}

.d4t-rolled-pick__remove {
  border: none;
  background: transparent;
  color: var(--d4cm-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.d4t-rolled-pick__remove:hover { color: #e08080; }

.d4t-rolled-list {
  display: grid;
  align-content: start;
  gap: 4px;
  overflow-y: auto;
}

.d4t-rolled-group {
  margin-top: 8px;
  color: var(--d4cm-gold);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.d4t-rolled-row {
  padding: 7px 10px;
  border: 1px solid #2a241b;
  border-radius: 3px;
  background: #14120f;
  color: #cfcdd6;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.d4t-rolled-row:hover:not([disabled]) { border-color: #8c6a3f; background: #1a1610; }
.d4t-rolled-row.is-legendary { color: #f0b48a; }
.d4t-rolled-row[disabled] { opacity: .4; cursor: not-allowed; }

.d4t-rolled-pick__remove:focus-visible,
.d4t-rolled-row:focus-visible,
.d4t-modal__tab:focus-visible {
  outline: 2px solid var(--d4cm-gold);
  outline-offset: 1px;
}

@media (max-width: 600px) {
  .d4t-rolled-pick { grid-template-columns: 1fr auto; }
  .d4t-rolled-pick__value { grid-column: 1 / -1; }
}

/* The picker modal is appended to <body>, outside .d4cm-panel where the
   --d4cm-* colours are defined — give it its own copy. */
.d4t-modal-backdrop {
  --d4cm-gold: #e8b971;
  --d4cm-text: #ececf1;
  --d4cm-muted: #898793;
}

/* A unique charm at Mythic quality — toggle in its «Свойства» tab. */
.d4t-mythic-toggle { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; color: #e05fd4; font-weight: 600; cursor: pointer; }
.d4t-mythic-toggle input { accent-color: #b34bf0; width: 16px; height: 16px; margin: 0; }
.d4t-mythic-toggle input:focus-visible { outline: 2px solid #e05fd4; outline-offset: 2px; }

/* theme-guard:start — generated by tools/theme-guard.mjs, do not edit */
html body .d4t-slot:where(:hover, :focus) { border: none; background: url('../images/talisman/charm-slot.webp') center / contain no-repeat; color: var(--d4cm-text); }
html body .d4t-slot--seal:where(:hover, :focus) { background-image: url('../images/talisman/seal-slot.webp'); }
html body .d4t-modal__unequip:where(:hover, :focus) { background: transparent; border: 1px solid var(--d4cm-line); color: var(--d4cm-muted); }
html body .d4t-modal__close:where(:hover, :focus) { background: transparent; border: none; color: var(--d4cm-muted); }
html body .d4t-modal__category:where(:hover, :focus) { background: transparent; border: none; color: var(--d4cm-muted); }
html body .d4t-card:where(:hover, :focus) { background: #14120f; border: 1px solid var(--d4cm-line); color: var(--d4cm-text); }
html body .d4t-modal__tab:where(:hover, :focus) { border: 1px solid transparent; border-bottom: none; background: transparent; color: var(--d4cm-muted); }
html body .d4t-rolled-pick__remove:where(:hover, :focus) { border: none; background: transparent; color: var(--d4cm-muted); }
html body .d4t-rolled-row:where(:hover, :focus) { border: 1px solid #2a241b; background: #14120f; color: #cfcdd6; }
/* theme-guard:end */
