/* Sigils, race portraits and the sigil board (scripts/lib/components/sigil.mjs), from the
   home page's character-creation board. A class is a round icon in a pixel ring; the chosen
   one gets a 3px ring and its name in the class color. A class the chosen race cannot play
   dims to 38% and stays focusable. The green New flag marks a new pairing. */

/* ---------- Class sigil ---------- */

.wfg-sigil {
  --wfg-sigil-state: 1;
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: .4rem;
  padding: .5rem .2rem .35rem;
  color: var(--ink-2);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  opacity: var(--wfg-sigil-state);
  transition: opacity var(--t);
}
/* A class the race cannot play: the icon dims, the name stays readable (ink-3, 6.4:1). */
.wfg-sigil.is-dim .wfg-sigil-ring { opacity: .38; }
.wfg-sigil.is-dim b { color: var(--ink-3); }
span.wfg-sigil { cursor: default; }
.wfg-sigil-ring {
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--edge), 0 0 0 2px var(--edge-inner);
}
.wfg-sigil-ring img { width: 2.3rem; height: 2.3rem; border-radius: 50%; }
.wfg-sigil b { font-family: var(--font-ui); font-size: .82rem; font-weight: 400; color: var(--ink-2); }
.wfg-sigil-new, .wfg-race-new {
  padding: .02rem .32rem;
  border-radius: var(--r-ctl);
  background: var(--new);
  font: 400 .56rem/1.5 var(--font-ui);
  font-style: normal;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bg);
}
.wfg-sigil-new { position: absolute; top: .2rem; right: calc(50% - 2.2rem); }
.wfg-sigil-new.is-toggle { display: none; }
.wfg-sigil-only { font: 400 .66rem/1.2 var(--font-ui); letter-spacing: .02em; }
.wfg-sigil-only[data-faction="alliance"] { color: var(--alliance); }
.wfg-sigil-only[data-faction="horde"] { color: var(--horde-text); }
a.wfg-sigil:hover b, .wfg-radio:checked + .wfg-sigil b { color: var(--accent-text); }
.wfg-radio:checked + .wfg-sigil { opacity: 1; }
.wfg-radio:checked + .wfg-sigil .wfg-sigil-ring { box-shadow: 0 0 0 1px var(--edge), 0 0 0 3px var(--accent); }
/* A dimmed class that is chosen stays gray: the ring marks the choice, never a playable look. */
.wfg-radio:checked + .wfg-sigil.is-dim .wfg-sigil-ring { opacity: .7; box-shadow: 0 0 0 1px var(--edge), 0 0 0 3px var(--ink-3); }
.wfg-radio:checked + .wfg-sigil.is-dim b { color: var(--ink-2); }
.wfg-radio:focus-visible + .wfg-sigil, .wfg-radio:focus-visible + .wfg-race { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) {
  .wfg-sigil:hover .wfg-sigil-ring { box-shadow: 0 0 0 1px var(--edge), 0 0 0 2px var(--line-strong); }
  .wfg-radio:checked + .wfg-sigil:hover .wfg-sigil-ring { box-shadow: 0 0 0 1px var(--edge), 0 0 0 3px var(--accent); }
}

/* ---------- Race sigil ---------- */

.wfg-race {
  --wfg-faction: var(--line-strong);
  position: relative;
  display: grid;
  justify-items: center;
  gap: .3rem;
  padding: .35rem .2rem;
  border: 1px solid transparent;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--t);
}
.wfg-race[data-faction="alliance"] { --wfg-faction: var(--alliance); }
.wfg-race[data-faction="horde"] { --wfg-faction: var(--horde); }
.wfg-race.is-dim { opacity: .38; }
span.wfg-race { cursor: default; }
.wfg-race img {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  object-fit: cover;
  object-position: top;
  border-radius: 50%;
  background: var(--panel-2);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 12%, transparent);
}
.wfg-race span { display: grid; line-height: 1.2; overflow-wrap: normal; }
.wfg-race b { font-weight: 600; color: var(--ink); }
.wfg-race small { font-size: .72rem; color: var(--ink-3); }
.wfg-race-new { position: absolute; top: 0; right: 0; }
.wfg-race.is-row { display: flex; align-items: center; gap: .7rem; min-height: 3.25rem; padding: .35rem .55rem .35rem .4rem; text-align: left; }
.wfg-race.is-row .wfg-race-new { position: static; flex: none; margin-left: auto; white-space: nowrap; font-size: .6rem; padding: .05rem .4rem; }
.wfg-race:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.wfg-radio:checked + .wfg-race { border-color: color-mix(in srgb, var(--wfg-faction) 55%, transparent); background: color-mix(in srgb, var(--wfg-faction) 12%, transparent); opacity: 1; }
.wfg-radio:checked + .wfg-race img { box-shadow: 0 0 0 1px var(--edge), 0 0 0 3px var(--accent); }

/* ---------- Portrait stage ---------- */

.wfg-portrait {
  position: relative;
  aspect-ratio: 240 / 274;
  overflow: hidden;
  border: 1px solid var(--edge-inner);
  border-radius: 999px 999px 0 0;
  background: var(--panel-2);
}
.wfg-portrait.has-faction-edge[data-faction="alliance"] { border-color: var(--alliance); }
.wfg-portrait.has-faction-edge[data-faction="horde"] { border-color: var(--horde); }
.wfg-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* ---------- Sigil board: the verdict follows the checked sigil ---------- */

.wfg-board { display: grid; gap: .75rem; min-width: 0; }
.wfg-sigils { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: .5rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.wfg-sigils legend {
  float: left;
  grid-column: 1 / -1;
  width: 100%;
  margin-bottom: .5rem;
  padding: 0 0 .5rem;
  border-bottom: 1px solid var(--hairline);
  font: 400 .72rem/1.3 var(--font-ui);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.wfg-verdict { display: none; }
.wfg-board:has(.wfg-sigils > input:nth-of-type(1):checked) .wfg-verdict:nth-child(1),
.wfg-board:has(.wfg-sigils > input:nth-of-type(2):checked) .wfg-verdict:nth-child(2),
.wfg-board:has(.wfg-sigils > input:nth-of-type(3):checked) .wfg-verdict:nth-child(3),
.wfg-board:has(.wfg-sigils > input:nth-of-type(4):checked) .wfg-verdict:nth-child(4),
.wfg-board:has(.wfg-sigils > input:nth-of-type(5):checked) .wfg-verdict:nth-child(5),
.wfg-board:has(.wfg-sigils > input:nth-of-type(6):checked) .wfg-verdict:nth-child(6),
.wfg-board:has(.wfg-sigils > input:nth-of-type(7):checked) .wfg-verdict:nth-child(7),
.wfg-board:has(.wfg-sigils > input:nth-of-type(8):checked) .wfg-verdict:nth-child(8),
.wfg-board:has(.wfg-sigils > input:nth-of-type(9):checked) .wfg-verdict:nth-child(9),
.wfg-board:has(.wfg-sigils > input:nth-of-type(10):checked) .wfg-verdict:nth-child(10),
.wfg-board:has(.wfg-sigils > input:nth-of-type(11):checked) .wfg-verdict:nth-child(11),
.wfg-board:has(.wfg-sigils > input:nth-of-type(12):checked) .wfg-verdict:nth-child(12) { display: block; }
/* Without :has() the radios cannot swap the verdict, so every verdict shows as a list and
   each one's button reads as a plain link to its class: the class names become links. */
@supports not selector(:has(*)) {
  .wfg-verdict { display: block; padding-block: .4rem; border-top: 1px solid var(--hairline); }
  .wfg-verdict .wfg-btn--enter { min-height: 1.75rem; padding: 0; border: 0; background: none; box-shadow: none; font: 400 .9rem/1.4 var(--font-ui); text-decoration: underline; text-shadow: none; color: var(--accent-text); }
}

@media (max-width: 40rem) {
  .wfg-race.is-row { gap: .55rem; padding-right: .35rem; }
  .wfg-race.is-row .wfg-race-new { position: absolute; left: .15rem; top: .05rem; margin: 0; padding: 0 .25rem; font-size: .56rem; }
}

@media (prefers-reduced-motion: reduce) {
  .wfg-sigil, .wfg-sigil-ring, .wfg-race, .wfg-race img { transition: none; }
}
