/* ═══════════════════════════════════════════════════════════════════════
   KOZMETİKLER · ortak çizim kuralları
   Every cosmetic is drawn from `data-cosm` on a host element built by
   dom/cosmetic-render.js. Its decorative layers are plain spans
   (.cosmL1 …, each with a `data-part` name) plus their ::before/::after.

   Category art lives next to this file, one file per slot. This file holds
   what every category shares:
     · design tokens (geometry, timing, glow)
     · layer mechanics and stacking (status is never covered)
     · motion scopes: where looping art may move
     · the window-hidden pause and forced-colors fallbacks

   Motion rules for every art file:
     · animate only transform and opacity (one-shot reveals may clip-path)
     · declare animations only inside
       @media (prefers-reduced-motion: no-preference)
     · a looping animation's first keyframe is its resting pose: outside a
       motion scope loops are paused on that frame
     · the base style (no animation) is the reduced-motion look
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* Avatar geometry. A decoration box is 1.36 × the avatar, so in
     `radial-gradient(closest-side, …)` the avatar edge sits at 73.5%. */
  --cosm-edge: 73.5%;
  --cosm-hair: 1.1px;
  --cosm-line: 1.6px;

  /* Timing. Loops are slow; one-shot effects finish within ~3.5s. */
  --cosm-dur-flash: 1.1s;
  --cosm-dur-pulse: 3.2s;
  --cosm-dur-shimmer: 6.5s;
  --cosm-dur-orbit: 14s;
  --cosm-dur-drift: 22s;
  --cosm-ease-breathe: cubic-bezier(0.45, 0, 0.55, 1);
  --cosm-ease-sweep: cubic-bezier(0.55, 0, 0.3, 1);
  --cosm-ease-settle: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Glow. Applied as static drop-shadows or box-shadows, never animated. */
  --cosm-glow-soft: 0.35;
  --cosm-glow-strong: 0.6;

  /* Collection swatches, used by the market filters and headings. */
  --cosm-col-minimal: #c9ccd3;
  --cosm-col-signal: #2dd4bf;
  --cosm-col-stage: #fb923c;
  --cosm-col-crimson: #ef4444;
  --cosm-col-midnight: #8b9cf6;
  --cosm-col-cyber: #f062d8;
  --cosm-col-astral: #a78bfa;
  --cosm-col-heritage: #d9b36a;
  --cosm-col-lounge: #86d9b0;
  --cosm-col-roulette: #1fa36b;
  --cosm-col-blackjack: #e5c579;
  --cosm-col-mines: #6ee7b7;
  --cosm-col-football: #9bd5a5;
  --cosm-col-aviator: #f3c483;
  --cosm-col-slot: #ffd84d;
  --cosm-col-candy: #ff9ccd;
  --cosm-col-penalty: #7cc6f2;
  --cosm-col-uno: #ff7a6b;
  --cosm-col-kingo: #b99cf0;
  --cosm-col-war: #c3ccd8;
  --cosm-col-bass: #74e3d5;
  --cosm-col-devil: #e8b47e;
  --cosm-col-tombstone: #f5ad79;
  --cosm-col-duel: #edc585;
  --cosm-col-donation: #b9d8b0;
  --cosm-col-velvet: #dbadca;
  --cosm-col-tape: #c9b991;
  --cosm-col-abyssal: #82c1b9;
  --cosm-col-pocket: #a5ba98;
  --cosm-col-duat: #e6c779;
  --cosm-col-powder: #f38dce;
  --cosm-col-sparta: #e5aaa0;
  --cosm-col-konoha: #ff9a3c;
  --cosm-col-dragon: #f0743c;
  --cosm-col-printstream: #e0d6f3;
  --cosm-col-ronaldo: #ff5a64;
  --cosm-col-gothic: #c4a1ed;
  --cosm-col-cathedral: #d2b77d;
  --cosm-col-manifest: #f5a0d8;
  --ps-x: 36%;
  --ps-y: 24%;
  --ps-sheen: 0.43;
  --ps-angle: 145deg;
}

[data-cosm-material="printstream"] {
  --ps-pearl: conic-gradient(from var(--ps-angle) at var(--ps-x) var(--ps-y),
    #f5cfe7, #fcfdff 13%, #b8edf4 28%, #d9cbf5 43%, #fff 56%, #f4bfdc 70%, #c0e6ef 85%, #f5cfe7);
}

/* Shared material motion moves a reflection layer, never the name or the silhouette. */
@keyframes cosmPrintstreamFlow {
  0%, 100% { transform: translateX(-5%) rotate(-3deg) scale(1.1); opacity: 0.55; }
  50% { transform: translateX(5%) rotate(3deg) scale(1.1); opacity: 1; }
}
@keyframes cosmPrintstreamGlint {
  0%, 25%, 100% { opacity: 0; transform: translateX(-120%) skewX(-18deg); }
  38% { opacity: 0.55; }
  65% { opacity: 0; transform: translateX(240%) skewX(-18deg); }
}

/* ─── Layer mechanics ─── */
.cosmL {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cosmL::before,
.cosmL::after {
  content: none;
  position: absolute;
  pointer-events: none;
}

/* Avatar decorations overflow the square avatar box on every side. */
.hasCosmDeco {
  overflow: visible;
}

.cosmDeco {
  position: absolute;
  inset: -18%;
  z-index: 2;
  pointer-events: none;
}

/* Status dots stay above decorations: status is never hidden. */
.hasCosmDeco > .participantStatusDot,
.hasCosmDeco > .onlineUserPresenceDot,
.hasCosmDeco > .selfStatusDot,
.hasCosmDeco > .cosmProfileStatusDot {
  z-index: 3;
}

/* The tile edge already marks a speaker. Keep its avatar decoration free of a second ring,
   which can overlap ornaments that extend beyond the decoration box. */
.participantRing.hasCosmDeco::before,
.participantRing.hasCosmDeco::after {
  content: none;
}

/* Nameplates sit behind their host's content and never change its layout. */
:where(.hasCosmPlate) {
  position: relative;
}

.hasCosmPlate {
  isolation: isolate;
  /* Space kept free at the plate's right end (for example the member-list voice icon). */
  --cosm-plate-end: 0px;
}

/* The host is its own stacking context, so a plate at z-index -1 paints above the host's
   background and below all of its content, including bare text nodes. */
.cosmPlate {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  contain: paint;
  border-radius: inherit;
  pointer-events: none;
}

/* Frames and effects cover a profile card. */
.hasCosmFrame,
.hasCosmEffect {
  isolation: isolate;
}

.cosmFrame {
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
}

.cosmFrame .cosmL {
  border-radius: inherit;
}

.cosmEffect {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

/* ─── Motion scopes ───
   Looping art rests on its first keyframe everywhere, and moves only where
   someone is looking at it: voice tiles, the profile card, the market
   preview, and member-list rows or market cards while hovered or focused.
   Each item's `animation` shorthand resets the play state, so these three
   rules are !important and ordered: rest by default, run in a motion
   scope, and hold still whenever the window is hidden (same specificity as
   the scope rule, declared later). */
:is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL,
:is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL::before,
:is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL::after {
  animation-play-state: paused !important;
}

/* Signature chat emblems share the scope gate; the author text never animates. */
.cosmAccent::before {
  animation-play-state: paused !important;
}

:is(.cosmMotion, .participantCard, .cosmProfilePopover, .onlineUserRow:hover, .onlineUserRow:focus-visible,
  .cosmCard:hover, .cosmCard:focus-visible, .cosmCard.isSelected, .cosmAchievement:hover, .cosmAchievement:focus-visible,
  .cosmAchievement.isSelected) :is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL,
:is(.cosmMotion, .participantCard, .cosmProfilePopover, .onlineUserRow:hover, .onlineUserRow:focus-visible,
  .cosmCard:hover, .cosmCard:focus-visible, .cosmCard.isSelected, .cosmAchievement:hover, .cosmAchievement:focus-visible,
  .cosmAchievement.isSelected) :is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL::before,
:is(.cosmMotion, .participantCard, .cosmProfilePopover, .onlineUserRow:hover, .onlineUserRow:focus-visible,
  .cosmCard:hover, .cosmCard:focus-visible, .cosmCard.isSelected, .cosmAchievement:hover, .cosmAchievement:focus-visible,
  .cosmAchievement.isSelected) :is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL::after {
  animation-play-state: running !important;
}

/* Chat avatar art moves only while its message is hovered or keyboard-focused. */
:is(.chatMessage:hover, .chatMessage:focus-within, .chatAvatarHovered) .cosmDeco .cosmL,
:is(.chatMessage:hover, .chatMessage:focus-within, .chatAvatarHovered) .cosmDeco .cosmL::before,
:is(.chatMessage:hover, .chatMessage:focus-within, .chatAvatarHovered) .cosmDeco .cosmL::after {
  animation-play-state: running !important;
}

:is(.cosmMotion, .cosmCard:hover, .cosmCard:focus-visible, .cosmCard.isSelected,
  .chatMessage:hover, .chatMessage:focus-visible) .cosmAccent::before,
.cosmAccent:is(:hover, :focus-visible)::before {
  animation-play-state: running !important;
}

/* Market cards and achievement rows at rest drop their loops altogether. A paused animation still
   keeps its layer composited, and a full grid of them (well over a hundred layers) made every
   frame of the open market re-layerize: scrolling cost several times more main-thread work.
   Hovering, focusing or selecting a card starts its art from the beginning. */
:is(.cosmCard, .cosmAchievement):not(:hover, :focus-visible, .isSelected) :is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL,
:is(.cosmCard, .cosmAchievement):not(:hover, :focus-visible, .isSelected) :is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL::before,
:is(.cosmCard, .cosmAchievement):not(:hover, :focus-visible, .isSelected) :is(.cosmDeco, .cosmPlate, .cosmFrame) .cosmL::after {
  animation: none !important;
}

:is(.cosmCard, .chatMessage):not(:hover, :focus-visible, .isSelected):not(:is(.cosmMotion, .cosmMotion *)) .cosmAccent:not(:hover, :focus-visible)::before {
  animation: none !important;
}

/* Effects play once on a live profile card. Market posters show the resting look. */
.isPoster > .cosmEffect .cosmL,
.isPoster > .cosmEffect .cosmL::before,
.isPoster > .cosmEffect .cosmL::after {
  animation: none !important;
}

/* Hidden or unfocused window: every cosmetic holds still. */
:root[data-cosm-paused] :is(.cosmDeco, .cosmPlate, .cosmFrame, .cosmEffect) .cosmL,
:root[data-cosm-paused] :is(.cosmDeco, .cosmPlate, .cosmFrame, .cosmEffect) .cosmL::before,
:root[data-cosm-paused] :is(.cosmDeco, .cosmPlate, .cosmFrame, .cosmEffect) .cosmL::after {
  animation-play-state: paused !important;
}

:root[data-cosm-paused] .cosmAccent::before {
  animation-play-state: paused !important;
}

/* High-contrast modes keep plain text and drop decorative art. */
@media (forced-colors: active) {
  .cosmDeco,
  .cosmPlate,
  .cosmFrame,
  .cosmEffect {
    display: none;
  }
}
