/* A9X SOUND — L92e HORIZONTAL onyx audio bar, LIVE-FX edition (owner:
 * «صغيرها شوية بالعرض + افكت لايف فيجوال على كل الزراير والكلام… يحس إنها
 * بتتفاعل معاه»). Wide short grid, zero orange. No-build vanilla CSS;
 * RTL-safe logical properties; honors prefers-reduced-motion. */

.em-music { position: relative; }

/* ------------------------------------------------ icon: living onyx orb */
.em-music__orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(96, 99, 110, .5), rgba(9, 9, 11, .94) 72%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 0 0 1px rgba(255, 255, 255, .14), 0 3px 10px -2px rgba(0, 0, 0, .6);
  transition: box-shadow .35s, transform .25s;
}
.em-music__note { width: 15px; height: 15px; color: #eef0f6; filter: drop-shadow(0 0 4px rgba(255, 255, 255, .55)); transition: filter .3s, transform .3s; }
.em-icon-btn.em-music:hover .em-music__note { filter: drop-shadow(0 0 7px rgba(255, 255, 255, .9)); transform: translateY(-1px); }
.em-music__ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 68%, rgba(255, 255, 255, .75), rgba(203, 208, 220, .95), rgba(255, 255, 255, .75), transparent);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.4px), #000 calc(100% - 2.2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.4px), #000 calc(100% - 2.2px));
  opacity: .35;
  transition: opacity .35s;
}
/* idle: slow breathing — alive even before the first play */
.em-music .em-music__ring { animation: asm-breathe 4.2s ease-in-out infinite; }
@keyframes asm-breathe {
  0%, 100% { opacity: .22; transform: scale(1); }
  50% { opacity: .5; transform: scale(1.05); }
}
/* playing: comet ring + cool white glow */
.em-music.is-playing .em-music__ring { opacity: 1; animation: asm-spin 2.4s linear infinite; }
@keyframes asm-spin { to { transform: rotate(360deg); } }
.em-music.is-playing .em-music__orb {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 0 1px rgba(255, 255, 255, .45),
    0 0 18px rgba(255, 255, 255, .35), 0 0 44px rgba(160, 170, 190, .25);
  transform: scale(1.06);
}
.em-icon-btn.em-music:hover .em-music__orb { transform: scale(1.1); }
/* icon press feedback */
.em-icon-btn.em-music:active .em-music__orb { transform: scale(.94); }

/* equalizer: top-right badge */
.em-music__eq {
  position: absolute;
  inset-block-start: -5px;
  inset-inline-end: -4px;
  display: inline-flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 10px;
  padding: 2.5px 3px;
  border-radius: 5px;
  background: rgba(8, 8, 10, .9);
  border: 1px solid rgba(255, 255, 255, .32);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  opacity: .6;
  transition: opacity .3s;
}
.em-music__eq i {
  width: 2px;
  height: 3px;
  border-radius: 1px;
  background: linear-gradient(180deg, #ffffff, #9aa0ad);
  transform: scaleY(1);
  transform-origin: bottom;
}
.em-music.is-playing .em-music__eq { opacity: 1; box-shadow: 0 0 10px rgba(255, 255, 255, .45); }
.em-music.is-playing .em-music__eq i { animation: asm-eq 880ms ease-in-out infinite; }
.em-music.is-playing .em-music__eq i:nth-child(2) { animation-delay: 140ms; }
.em-music.is-playing .em-music__eq i:nth-child(3) { animation-delay: 280ms; }
.em-music.is-playing .em-music__eq i:nth-child(4) { animation-delay: 420ms; }
@keyframes asm-eq {
  0%, 100% { transform: scaleY(.4); }
  50% { transform: scaleY(1); }
}

/* ------------------------------------------------- popover (WIDE onyx bar) */
.em-pop--music {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline-end: 0;
  inset-inline-start: auto;
  z-index: 120;
  width: 328px;
  max-width: calc(100vw - 28px);
  padding: 9px 10px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  /* owner law: pure ONYX — the same deep void in light mode */
  background:
    radial-gradient(560px 180px at 12% -60%, rgba(255, 255, 255, .09), transparent 60%),
    radial-gradient(460px 160px at 96% -50%, rgba(190, 200, 220, .07), transparent 62%),
    linear-gradient(165deg, #141417 0%, #0a0a0d 55%, #040405 100%);
  box-shadow:
    0 26px 60px -18px rgba(0, 0, 0, .85),
    0 0 0 1px rgba(255, 255, 255, .05),
    0 0 28px -6px rgba(255, 255, 255, .18),
    inset 0 1px 0 rgba(255, 255, 255, .06);
  color: #eef0f6;
  font-family: inherit;
  animation: asm-in 240ms cubic-bezier(.2, .8, .3, 1);
  transform-origin: top;
  overflow: hidden;
  isolation: isolate;
  /* L92e horizontal bar-grid: brand band / track+transport band / vol+opts band / collections band */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "head    head"
    "track   transport"
    "vol     opts"
    "cols    cols";
  gap: 5px 10px;
}
/* animated silver sheen sweeping the panel */
.em-pop--music::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: -32%;
  width: 28%;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent, rgba(255, 255, 255, .06) 50%, transparent);
  mix-blend-mode: screen;
  animation: asm-sheen 9s ease-in-out 1.4s infinite;
}
@keyframes asm-sheen { 0%, 55% { transform: translateX(-80%); } 92%, 100% { transform: translateX(420%); } }
/* glowing top hairline */
.em-pop--music::after {
  content: "";
  position: absolute;
  inset-inline: 26px;
  inset-block-start: 0;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .8), transparent);
  box-shadow: 0 0 12px rgba(255, 255, 255, .5);
}
@keyframes asm-in {
  from { opacity: 0; transform: translateY(-7px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* band: brand + close */
.em-pop--music .em-pop__head--music {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  position: relative;
  z-index: 1;
}
.em-pop--music .em-pop__brand {
  font-family: 'Space Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: .18em;
  font-weight: 700;
  background: linear-gradient(92deg, #b9bec9 10%, #ffffff 55%, #cdd2dd 95%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: asm-brand 5s ease-in-out infinite;
}
@keyframes asm-brand { 0%, 100% { background-position: 0% 0; } 50% { background-position: 100% 0; } }
.em-music__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(238, 240, 246, .55);
  cursor: pointer;
  transition: opacity .2s, background .2s, color .2s, transform .18s, box-shadow .2s;
}
.em-music__close:hover { opacity: 1; background: rgba(255, 255, 255, .1); color: #ffffff; transform: rotate(90deg) scale(1.05); }
.em-music__close:active { transform: rotate(90deg) scale(.88); }
.em-music__close svg { width: 10px; height: 10px; }

/* the old stacked subtitle is retired in the horizontal bar */
.em-music__sub { display: none; }

/* band: track (left) + transport (right) */
.em-music__track {
  grid-area: track;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: linear-gradient(160deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .012) 60%);
}
.em-music__disc {
  position: relative;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
  background: radial-gradient(circle at 32% 30%, rgba(120, 126, 140, .45), rgba(10, 10, 13, .95) 74%);
  color: #e8ebf2;
  box-shadow: 0 0 10px -2px rgba(255, 255, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: box-shadow .3s;
}
.em-music__disc svg { width: 12px; height: 12px; }
.em-music__disc::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
  opacity: 0;
}
.em-music.is-playing .em-music__disc { animation: asm-disc 7s linear infinite; box-shadow: 0 0 14px -2px rgba(255, 255, 255, .5), inset 0 1px 0 rgba(255, 255, 255, .2); }
.em-music.is-playing .em-music__disc::after { opacity: 1; animation: asm-halo 2.6s ease-out infinite; }
.em-music.is-paused .em-music__disc { animation: none; }
@keyframes asm-disc { to { transform: rotate(360deg); } }
@keyframes asm-halo {
  0% { transform: scale(.9); opacity: .8; }
  70% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}
.em-music__meta { min-width: 0; flex: 1; }
.em-music__name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
  color: #ffffff;
}
/* L92e LIVE text FX while playing: silver shimmer sweeps across the brand */
.em-music.is-playing .em-music__name {
  background: linear-gradient(100deg, #ffffff 34%, #9aa3b8 48%, #ffffff 62%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: asm-shimmer 2.6s linear infinite;
}
@keyframes asm-shimmer {
  0% { background-position: 130% 0; }
  100% { background-position: -110% 0; }
}

.em-music__transport {
  grid-area: transport;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  position: relative;
  z-index: 1;
}
.em-music__tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(238, 240, 246, .75);
  cursor: pointer;
  transition: background .2s, color .2s, transform .15s, box-shadow .2s;
}
.em-music__tbtn:hover { background: rgba(255, 255, 255, .1); color: #ffffff; box-shadow: inset 0 0 8px rgba(255, 255, 255, .12), 0 0 10px -2px rgba(255, 255, 255, .3); transform: translateY(-1px); }
.em-music__tbtn:active { transform: scale(.9); }
.em-music__tbtn svg { width: 12px; height: 12px; transition: filter .25s; }
.em-music__tbtn:hover svg { filter: drop-shadow(0 0 5px rgba(255, 255, 255, .65)); }
.em-music__play {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f4f5f8, #c0c5d0);
  color: #101014;
  box-shadow: 0 6px 18px -6px rgba(255, 255, 255, .45), inset 0 1px 0 rgba(255, 255, 255, .9);
  transition: all .25s;
}
.em-music__play:hover {
  background: linear-gradient(135deg, #ffffff, #d2d6e0);
  box-shadow: 0 8px 22px -6px rgba(255, 255, 255, .65), 0 0 18px rgba(255, 255, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .95);
  transform: scale(1.06);
}
.em-music__play:active { transform: scale(.9); }
.em-music__play svg { width: 12px; height: 12px; }
.em-music__play.is-playing { background: linear-gradient(135deg, #1b1b20, #2b2b32); color: #dfe3ec; box-shadow: inset 0 2px 5px rgba(0, 0, 0, .6), 0 0 14px -4px rgba(255, 255, 255, .3); }
/* playing state: the play button pulses alive */
.em-music.is-playing .em-music__play.is-playing { animation: asm-pulse 2.2s ease-in-out infinite; }
@keyframes asm-pulse {
  0%, 100% { box-shadow: inset 0 2px 5px rgba(0, 0, 0, .6), 0 0 12px -4px rgba(255, 255, 255, .25); }
  50% { box-shadow: inset 0 2px 5px rgba(0, 0, 0, .6), 0 0 20px -2px rgba(255, 255, 255, .5); }
}

/* band: volume (left) + option chips (right) */
.em-music__volrow {
  grid-area: vol;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.em-music__mute { flex: 0 0 auto; }
.em-music__mute.is-on { color: #e7eaf1; }
.em-music__vol {
  flex: 1;
  height: 3px;
  min-width: 0;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 2px;
  background: linear-gradient(90deg, #f4f5f8 var(--fill, 45%), rgba(255, 255, 255, .1) var(--fill, 45%));
  outline: none;
  cursor: pointer;
  transition: box-shadow .2s;
}
.em-music__vol:hover { box-shadow: 0 0 8px rgba(255, 255, 255, .25); }
.em-music__vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #101014;
  border: 2.5px solid #eef0f6;
  box-shadow: 0 0 8px rgba(255, 255, 255, .6);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
}
.em-music__vol:active::-webkit-slider-thumb { transform: scale(1.25); box-shadow: 0 0 14px rgba(255, 255, 255, .9); }
.em-music__vol:disabled { opacity: .35; cursor: default; }

.em-music__optsrow {
  grid-area: opts;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  position: relative;
  z-index: 1;
}
.em-music__opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 7px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .025);
  color: rgba(238, 240, 246, .5);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .05em;
  cursor: pointer;
  transition: all .2s;
}
.em-music__opt svg { width: 11px; height: 11px; transition: filter .25s, transform .25s; }
.em-music__opt:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, .32);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, .07), 0 0 10px -2px rgba(255, 255, 255, .3);
  transform: translateY(-1px);
}
.em-music__opt:hover svg { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .6)); transform: scale(1.1); }
.em-music__opt:active { transform: scale(.9); }
.em-music__opt.is-on {
  color: #f4f5f8;
  border-color: rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .09);
  animation: asm-live 2.4s ease-in-out infinite;
}
@keyframes asm-live {
  0%, 100% { box-shadow: inset 0 0 10px rgba(255, 255, 255, .1), 0 0 8px -3px rgba(255, 255, 255, .3); }
  50% { box-shadow: inset 0 0 14px rgba(255, 255, 255, .16), 0 0 14px -2px rgba(255, 255, 255, .55); }
}
.em-music__opt[data-mode="one"]::after { content: '1'; font-weight: 800; }

/* band: collections chips */
.em-music__collections {
  grid-area: cols;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-block-start: 7px;
  border-block-start: 1px solid rgba(255, 255, 255, .08);
  position: relative;
  z-index: 1;
}
.em-music__loading { font-size: 8.5px; color: rgba(238, 240, 246, .38); }
.em-music__chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .025);
  color: rgba(238, 240, 246, .6);
  font-size: 8.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.em-music__chip:hover { color: #ffffff; border-color: rgba(255, 255, 255, .38); box-shadow: 0 0 8px -2px rgba(255, 255, 255, .35); transform: translateY(-1px); }
.em-music__chip:active { transform: scale(.92); }
.em-music__chip.is-on {
  color: #ffffff;
  border-color: rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .12);
  animation: asm-live 2.4s ease-in-out infinite;
}

/* error line — full-width band when shown */
.em-music__err {
  grid-column: 1 / -1;
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 120, 120, .35);
  background: rgba(255, 90, 90, .1);
  color: #ffb3b3;
  font-size: 9px;
}

/* ------------------------------------------------- L92e press flash — JS taps
   .asm-flash on any touched control; a white glow ring + lift pops and
   decays, so every press FEEDS BACK (CSP-safe, tiny, no libs). */
.em-pop--music .asm-flash,
#emMusicBtn.asm-flash .em-music__orb {
  animation: asm-flash 420ms cubic-bezier(.2, .8, .3, 1);
}
#emMusicBtn.asm-flash .em-music__orb {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 0 0 1px rgba(255, 255, 255, .55), 0 0 22px rgba(255, 255, 255, .6);
}
@keyframes asm-flash {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0), 0 0 0 0 rgba(255, 255, 255, .5); transform: scale(.94); }
  45% { box-shadow: inset 0 0 12px rgba(255, 255, 255, .35), 0 0 16px rgba(255, 255, 255, .55); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 rgba(255, 255, 255, 0); transform: none; }
}

/* ducked hint */
.em-pop--music.is-ducked .em-music__track { border-color: rgba(255, 255, 255, .45); box-shadow: 0 0 14px -4px rgba(255, 255, 255, .35); }

/* ------------------------------------------------- live heat indicator —
   the panel breathes with the adaptive score (driven by --a9x-heat 0..1) */
.em-pop--music::before { opacity: calc(0.55 + 0.9 * var(--a9x-heat, 0)); }
.em-pop--music::after { opacity: calc(0.55 + 0.65 * var(--a9x-heat, 0)); }
.em-music.is-playing .em-music__orb { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 0 1px rgba(255, 255, 255, .45), 0 0 calc(14px + 14px * var(--a9x-heat, 0)) rgba(255, 255, 255, calc(.28 + .25 * var(--a9x-heat, 0))), 0 0 44px rgba(160, 170, 190, .25); }

/* --------------------------------------------------------------- mobile */
@media (max-width: 760px) {
  .em-pop--music {
    position: fixed;
    inset-block-start: 64px;
    inset-inline: 12px;
    width: auto;
    max-width: none;
    /* mobile: the bar becomes one column, readable stack */
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "track"
      "transport"
      "vol"
      "opts"
      "cols";
  }
  .em-music__transport { justify-content: flex-start; }
  .em-music__optsrow { justify-content: flex-start; }
  .em-music__tbtn { width: 32px; height: 32px; }
}

/* ------------------------------------------------------------ reduced motion */
[data-a9x-motion="reduced"] .em-pop--music { animation: none; }
[data-a9x-motion="reduced"] .em-pop--music::before { animation: none; }
[data-a9x-motion="reduced"] .em-music .em-music__ring,
[data-a9x-motion="reduced"] .em-music.is-playing .em-music__ring { animation: none; opacity: .4; }
[data-a9x-motion="reduced"] .em-music__eq i { animation: none !important; }
[data-a9x-motion="reduced"] .em-music.is-playing .em-music__disc { animation: none; }
[data-a9x-motion="reduced"] .em-music.is-playing .em-music__disc::after { animation: none; opacity: 0; }
[data-a9x-motion="reduced"] .em-music__tbtn:active,
[data-a9x-motion="reduced"] .em-icon-btn.em-music:hover .em-music__orb { transform: none; }
[data-a9x-motion="reduced"] .em-pop--music .em-pop__brand { animation: none; }
[data-a9x-motion="reduced"] .em-music.is-playing .em-music__name { animation: none; -webkit-text-fill-color: currentColor; background: none; }
[data-a9x-motion="reduced"] .em-music.is-playing .em-music__play.is-playing { animation: none; }
[data-a9x-motion="reduced"] .em-music__opt.is-on,
[data-a9x-motion="reduced"] .em-music__chip.is-on,
[data-a9x-motion="reduced"] .em-pop--music .asm-flash,
[data-a9x-motion="reduced"] #emMusicBtn.asm-flash .em-music__orb { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .em-pop--music, .em-pop--music::before, .em-music .em-music__ring,
  .em-music.is-playing .em-music__ring, .em-music__eq i,
  .em-music.is-playing .em-music__disc, .em-music.is-playing .em-music__disc::after,
  .em-pop--music .em-pop__brand,
  .em-music.is-playing .em-music__name,
  .em-music.is-playing .em-music__play.is-playing,
  .em-music__opt.is-on, .em-music__chip.is-on,
  .em-pop--music .asm-flash, #emMusicBtn.asm-flash .em-music__orb { animation: none !important; }
  .em-music.is-playing .em-music__disc::after { opacity: 0; }
  .em-music.is-playing .em-music__name { -webkit-text-fill-color: currentColor; background: none; }
}
