/* assets/css/avatar-creator.css
   Avatar switcher (Settings → Profile) and the avatar creator modal.

   Previously the modal styling lived as an inline <style> blob inside
   avatar-engine.js, half of it fighting a wall of u-* utilities on the same
   elements, and several classes (.ub-av-rand-btn) had no rules at all — which is
   why the dialog rendered as unstyled browser buttons. It also hardcoded a purple
   accent (#6c7fff) that has nothing to do with the product.

   No :root tokens are declared here by design — app.css owns those. Note the
   house vocabulary, which is easy to get wrong:
     --line              a FULL border shorthand ("1px solid rgba(...)"),
                         so it is used as `border: var(--line)`, never as a colour
     --ui-border-subtle  border COLOUR
     --ui-border-strong  border COLOUR, heavier
     --text-muted        secondary TEXT colour  (--muted is a near-black fill!)
     --ui-surface-soft   faint raised surface
*/

/* =====================================================================
   Avatar switcher
   Replaces a pair of native radios that were accent-coloured purple and sat
   beside a single preview, so you could not see what you were switching to.
   ===================================================================== */

.avsw {
  border: var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.avsw-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.avsw-current {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ui-surface-raised);
  display: block;
}

.avsw-current img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avsw-headtext h3 { margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.avsw-headtext p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.avsw-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.avsw-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--ui-border-subtle);
  background: var(--ui-surface-soft);
  cursor: pointer;
  transition: border-color var(--ui-motion-fast) ease, background-color var(--ui-motion-fast) ease;
}

.avsw-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.avsw-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.avsw-card.is-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

/* Selected tick — only filled in on the active card. */
.avsw-check {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--ui-border-strong);
}

.avsw-card.is-active .avsw-check {
  border-color: var(--primary);
  background: var(--primary);
}

.avsw-card.is-active .avsw-check::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: solid #04252c;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.avsw-thumb {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--ui-surface-raised);
}

.avsw-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avsw-empty {
  font-size: 10.5px;
  line-height: 1.2;
  text-align: center;
  color: var(--text-muted);
  padding: 0 6px;
}

.avsw-name { font-size: 13px; font-weight: 600; }
.avsw-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* =====================================================================
   Creator modal
   ===================================================================== */

.avc {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 22px;
  min-height: 460px;
}

/* ---- live preview column ---- */

.avc-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 22px;
  border-right: var(--line);
}

.avc-preview {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ui-surface-raised);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}

.avc-preview svg { display: block; width: 100%; height: 100%; }

.avc-shuffle { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.avc-shufbtn {
  padding: 8px 6px;
  border-radius: 9px;
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--ui-motion-fast) ease, border-color var(--ui-motion-fast) ease;
}

.avc-shufbtn:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border-color: color-mix(in srgb, var(--primary) 50%, transparent);
}

.avc-shufbtn--all {
  grid-column: span 2;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  color: var(--primary);
}

/* ---- customiser column ---- */

.avc-panel { display: flex; flex-direction: column; min-width: 0; }

.avc-tabs {
  display: flex;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: var(--line);
  margin-bottom: 4px;
}

.avc-tab {
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color var(--ui-motion-fast) ease, background-color var(--ui-motion-fast) ease;
}

.avc-tab:hover { color: var(--text); background: var(--strans); }
.avc-tab.is-active { color: var(--primary); }

.avc-tab.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -11px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
}

.avc-controls {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding: 14px 10px 4px 0;
  scrollbar-width: thin;
}

.avc-group + .avc-group { margin-top: 18px; }

.avc-grouptitle {
  margin: 0 0 9px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
}

/* ---- colour swatches ---- */

.avc-swatches { display: flex; flex-wrap: wrap; gap: 9px; }

.avc-swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--ui-border-strong);
  background: var(--sw);
  cursor: pointer;
  transition: transform var(--ui-motion-fast) ease, box-shadow var(--ui-motion-fast) ease;
}

.avc-swatch:hover { transform: scale(1.1); }

.avc-swatch.is-active {
  transform: scale(1.1);
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

/* "No backdrop" must read as empty rather than as a black swatch. */
.avc-swatch--none {
  background:
    linear-gradient(45deg, transparent 44%, var(--danger) 44%, var(--danger) 56%, transparent 56%),
    var(--ui-surface-raised);
}

/* ---- option tiles (each previews the whole avatar with one part swapped) ---- */

.avc-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}

.avc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 7px 4px 6px;
  border-radius: 11px;
  border: 1px solid var(--ui-border-subtle);
  background: var(--ui-surface-soft);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--ui-motion-fast) ease, background-color var(--ui-motion-fast) ease, color var(--ui-motion-fast) ease;
}

.avc-tile:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  color: var(--text);
}

.avc-tile.is-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--text);
}

/* The thumbnail is the real avatar SVG, zoomed onto the head so the part being
   chosen is what you actually see. */
.avc-tile-art {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ui-surface-raised);
}

.avc-tile-art svg {
  display: block;
  width: 150%;
  height: 150%;
  margin: -20% 0 0 -25%;
}

.avc-tile-label {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .avc-swatch, .avc-tile, .avc-tab, .avc-shufbtn, .avsw-card { transition: none; }
}
