/* ==========================================================================
   شكل البروفايل: الصورة مع إطارها وخلفيتها، الغلاف، ونافذة الاختيار (profile-look.js)
   ========================================================================== */

/* الصورة بالإطار: الصورة قطرها --ph، والإطار والخلفية ياخذون 120/80 منها */
.look-av {
  --box: calc(var(--ph) * 1.5);
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--box); height: var(--box);
}
.look-av > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.look-av .look-photo { position: relative; z-index: 1; box-shadow: none !important; }
.look-av .look-frame { z-index: 2; }
.profile-card .look-av { margin: calc(var(--ph) * -0.25) -8px; }
.profile-card .look-av .look-photo { box-shadow: 0 6px 18px rgba(15, 60, 55, .16) !important; }

/* الغلاف فوق بطاقة البروفايل */
.profile-cover {
  flex: 0 0 calc(100% + 56px); height: 150px; margin: -28px -28px 0;
  background-size: cover; background-position: center;
}
.profile-card.with-cover { align-items: flex-start; padding-top: 28px; }
.profile-card.with-cover > .profile-cover { position: relative; z-index: 0; }
.profile-card.with-cover > :is(.avatar, .look-av) { margin-top: -62px; z-index: 1; }
.profile-card.with-cover > .avatar { box-shadow: 0 0 0 4px var(--surface), 0 10px 24px rgba(15, 60, 55, .18); }
.profile-card.with-cover > .look-av { margin-top: -86px; margin-bottom: -20px; }
.profile-card.with-cover .profile-info { padding-top: 6px; }
.profile-card.with-cover .profile-actions { align-self: center; }
@media (max-width: 760px) {
  /* بالتلفون: الغلاف، وتحته الصورة بالنص، وبعدها المعلومات والأزرار */
  .profile-card.with-cover { flex-direction: column; align-items: center; padding-top: 22px; }
  .profile-card.with-cover > .profile-cover { flex: none; align-self: stretch; height: 116px; margin: -22px -18px 0; }
  .profile-card.with-cover > .avatar { margin-top: -58px; }
  .profile-card.with-cover > .look-av { margin-top: -80px; margin-bottom: -18px; }
  .profile-card.with-cover :is(.profile-info, .profile-actions) { align-self: stretch; min-width: 0; }
  .profile-actions { flex-wrap: wrap; }
  .profile-actions .btn { flex: 1 1 auto; }
}

/* ---------- النافذة ---------- */
.look-picker { display: grid; gap: 14px; }
.look-preview { position: relative; border-radius: 16px; overflow: hidden; background: var(--surface-2); padding-bottom: 54px; }
.look-preview .profile-cover { margin: 0; height: 96px; display: block; }
.look-preview .profile-cover.is-empty { background: linear-gradient(135deg, color-mix(in srgb, var(--grad-a) 18%, var(--surface)), color-mix(in srgb, var(--grad-b) 10%, var(--surface))); }
.look-preview-av { position: absolute; inset-inline-start: 18px; bottom: 6px; display: grid; place-items: center; width: 108px; height: 108px; }
.look-preview-av > .avatar { box-shadow: 0 0 0 4px var(--surface); }
.look-tabs { justify-self: stretch; display: flex; }
.look-tabs button { flex: 1; }
.look-tabs button[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.look-panel { max-height: min(46vh, 420px); overflow-y: auto; overscroll-behavior: contain; padding: 2px 4px 6px; }
.look-panel[hidden] { display: none; }
.look-group { margin: 14px 2px 8px; font-size: .95rem; color: var(--muted); }
.look-hint { margin: 0 0 10px; font-size: .88rem; }
.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.look-grid-wide { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin-top: 10px; }
.look-opt {
  display: grid; place-items: center; min-height: 72px; padding: 4px; border-radius: 14px; cursor: pointer;
  border: 2px solid transparent; background: var(--surface-2); color: var(--muted); font: inherit;
  transition: border-color .15s, transform .15s;
}
.look-opt:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.look-opt:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.look-opt.is-on { border-color: var(--primary); background: var(--primary-soft, var(--surface)); }
.look-opt .look-av { --ph: 44px; }
.look-none { display: grid; place-items: center; gap: 2px; font-size: .75rem; }
.look-swatch { position: relative; width: 58px; height: 58px; }
.look-swatch svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.look-cover-sw { display: block; width: 100%; height: 52px; border-radius: 10px; background-size: cover; }
.look-grid-wide .look-opt { min-height: 64px; }
.look-upload { justify-self: start; }
@media (prefers-reduced-motion: reduce) { .look-opt { transition: none; } .look-opt:hover { transform: none; } }

/* ---------- تغيير الصورة بالضغط عليها ---------- */
.photo-change { position: relative; display: inline-grid; place-items: center; flex: none; cursor: pointer; border-radius: 50%; }
.photo-change-badge {
  position: absolute; z-index: 3; inset-block-end: 6%; inset-inline-end: 6%; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  box-shadow: 0 0 0 3px var(--surface), 0 4px 10px rgba(0, 0, 0, .2); transition: transform .15s;
}
.photo-change:has(.look-av) .photo-change-badge { inset-block-end: 20%; inset-inline-end: 20%; }
.photo-change:hover .photo-change-badge { transform: scale(1.1); }
.photo-change:focus-within { outline: 3px solid var(--primary); outline-offset: 4px; }
.profile-card .photo-change > .look-av { margin: 0; }
.profile-card .photo-change:has(.look-av) { margin: -24px -8px; }
.profile-card.with-cover > .photo-change { margin-top: -62px; z-index: 1; }
.profile-card.with-cover > .photo-change:has(.look-av) { margin-top: -86px; margin-bottom: -20px; }
.profile-card.with-cover > .photo-change > .avatar { box-shadow: 0 0 0 4px var(--surface), 0 10px 24px rgba(15, 60, 55, .18); }
@media (max-width: 760px) {
  .profile-card.with-cover > .photo-change { margin-top: -58px; }
  .profile-card.with-cover > .photo-change:has(.look-av) { margin-top: -80px; margin-bottom: -18px; }
}
.look-photo-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: -6px; }

/* ---------- الإيموجي بصف الاسم ---------- */
.name-badge {
  display: inline-block; margin-inline-start: .3em; font-size: .9em; line-height: 1; vertical-align: -.05em;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; font-weight: 400;
}
.name-badge.nb-sm { font-size: 1em; margin-inline-start: .25em; }
.nb-bounce { animation: nb-bounce 1.1s ease-in-out infinite; }
.nb-beat { animation: nb-beat 1.2s ease-in-out infinite; }
.nb-spin { animation: nb-spin 2.4s linear infinite; }
.nb-wiggle { animation: nb-wiggle 1.4s ease-in-out infinite; transform-origin: 50% 80%; }
.nb-float { animation: nb-float 2.2s ease-in-out infinite; }
.nb-glow { animation: nb-glow 1.8s ease-in-out infinite; }
@keyframes nb-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-.32em); } 60% { transform: translateY(-.32em) scaleY(.96); } }
@keyframes nb-beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.14); } }
@keyframes nb-spin { to { transform: rotate(360deg); } }
@keyframes nb-wiggle { 0%, 60%, 100% { transform: rotate(0); } 10%, 30%, 50% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } }
@keyframes nb-float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-.22em) rotate(4deg); } }
@keyframes nb-glow { 0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 220, 120, 0)); } 50% { filter: drop-shadow(0 0 .25em rgba(255, 210, 90, .95)); } }
@media (prefers-reduced-motion: reduce) { .name-badge { animation: none !important; } }

.look-preview-name {
  position: absolute; inset-inline-start: 136px; bottom: 14px; inset-inline-end: 12px;
  font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.look-anims { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.look-anim {
  min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.look-anim[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.look-anim:disabled { opacity: .45; cursor: not-allowed; }
.look-grid-emoji { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.look-grid-emoji .look-opt { min-height: 52px; }
.look-grid-emoji .look-opt .name-badge { margin: 0; font-size: 1.7rem; }
.look-grid-emoji .look-opt .look-none { font-size: .7rem; }

/* ---------- حركات الإطارات العشرة ---------- */
.look-frame .fx { transform-box: fill-box; transform-origin: center; }
.look-frame .fx-sway { animation: fx-sway 2.6s ease-in-out infinite; }
.look-frame .fx-bob { animation: fx-bob 2.4s ease-in-out infinite; }
.look-frame .fx-float { animation: fx-float 3s ease-in-out infinite; }
.look-frame .fx-twinkle { animation: fx-twinkle 1.8s ease-in-out infinite; }
.look-frame .fx-twitch { transform-origin: 50% 100%; animation: fx-twitch 3.2s ease-in-out infinite; }
.look-frame .fx-flap-l { transform-origin: 100% 50%; animation: fx-flap 1.6s ease-in-out infinite; }
.look-frame .fx-flap-r { transform-origin: 0% 50%; animation: fx-flap 1.6s ease-in-out infinite; }
.look-frame .fx-pulse { animation: fx-pulse 1.4s ease-in-out infinite; }
.look-frame .fx-orbit { animation: fx-spin 16s linear infinite; }
.look-frame .fx-orbit-rev { animation: fx-spin 3.5s linear infinite reverse; }
.look-frame .fx-notes { animation: fx-notes 2.6s ease-out infinite; }
.look-frame .fx-fall { animation: fx-fall 4.2s linear infinite; opacity: 0; }
/* لمسة: من تأشر على الصورة الحركة تصير أسرع */
:is(.look-av:hover, .photo-change:hover, .look-opt:hover) .look-frame .fx { animation-duration: .9s; }
:is(.look-av:hover, .photo-change:hover, .look-opt:hover) .look-frame :is(.fx-orbit, .fx-fall) { animation-duration: 3s; }
@keyframes fx-sway { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes fx-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3px) rotate(-3deg); } }
@keyframes fx-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3.5px); } }
@keyframes fx-twinkle { 0%, 100% { opacity: .25; transform: scale(.6) rotate(0); } 50% { opacity: 1; transform: scale(1.15) rotate(25deg); } }
@keyframes fx-twitch { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-14deg); } 82% { transform: rotate(8deg); } 88% { transform: rotate(-6deg); } }
@keyframes fx-flap { 0%, 100% { transform: scaleX(1) rotate(0); } 50% { transform: scaleX(.78) rotate(-6deg); } }
@keyframes fx-pulse { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.2); } 60% { transform: scale(.95); } }
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-notes { 0% { opacity: 0; transform: translateY(4px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px) rotate(12deg); } }
@keyframes fx-fall { 0% { opacity: 0; transform: translate(0, 0) rotate(0); } 12% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-10px, 96px) rotate(220deg); } }
.look-grid-frames { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.look-frame-opt { display: grid; justify-items: center; gap: 2px; font-size: .78rem; color: var(--text); }
.look-frame-opt .look-av { --ph: 48px; }
@media (prefers-reduced-motion: reduce) { .look-frame .fx { animation: none !important; opacity: 1 !important; } }
.look-cover-item { display: grid; gap: 4px; width: 100%; justify-items: center; font-size: .78rem; color: var(--text); }

/* ---------- إطارات 11–15 ---------- */
.look-frame .fx-tassel { transform-origin: 0% 0%; animation: fx-sway 2s ease-in-out infinite; }
.look-frame .fx-scan { animation: fx-scan 1.8s ease-in-out infinite; }
.look-frame .fx-glitch-a { animation: fx-glitch-a 2.4s steps(1) infinite; }
.look-frame .fx-glitch-b { animation: fx-glitch-b 2.4s steps(1) infinite; }
@keyframes fx-scan { 0%, 100% { transform: translateY(-8px); } 50% { transform: translateY(8px); } }
@keyframes fx-glitch-a { 0%, 100% { transform: translate(0, 0); } 8% { transform: translate(-2px, 1px); } 12% { transform: translate(2px, -1px); } 16% { transform: translate(0, 0); } 58% { transform: translate(1.5px, 0); } 61% { transform: translate(0, 0); } }
@keyframes fx-glitch-b { 0%, 100% { transform: translate(0, 0); } 8% { transform: translate(2px, -1px); } 12% { transform: translate(-2px, 1px); } 16% { transform: translate(0, 0); } 58% { transform: translate(-1.5px, 0); } 61% { transform: translate(0, 0); } }

/* ---------- الإيموجيات المتحركة (SVG) ---------- */
.name-badge.nb-svg { width: 1.05em; height: 1.05em; vertical-align: -.15em; }
.name-badge.nb-svg svg { display: block; width: 100%; height: 100%; overflow: visible; }
.look-grid-emoji .look-opt .name-badge.nb-svg { width: 30px; height: 30px; }
.nb-svg .bx { transform-box: fill-box; transform-origin: center; }
.nb-svg .bx-blink { animation: bx-blink 3.6s ease-in-out infinite; }
.nb-svg .bx-pulse { animation: fx-pulse 1.6s ease-in-out infinite; }
.nb-svg .bx-shackle { animation: bx-shackle 2.4s ease-in-out infinite; }
.nb-svg .bx-turn { transform-origin: 30% 50%; animation: bx-turn 2.4s ease-in-out infinite; }
.nb-svg .bx-crawl { animation: bx-crawl .9s ease-in-out infinite; }
.nb-svg .bx-cursor { animation: bx-cursor 1s steps(1) infinite; }
.nb-svg .bx-wave { animation: bx-wave 1.5s ease-in-out infinite; }
.nb-svg .bx-scan { animation: bx-scan 1.8s ease-in-out infinite; }
.nb-svg .bx-glow { animation: bx-glow 1.6s ease-in-out infinite; }
.nb-svg .bx-bob { animation: fx-float 2.2s ease-in-out infinite; }
.nb-svg .bx-page { transform-origin: 0% 50%; animation: bx-page 2.6s ease-in-out infinite; }
.nb-svg .bx-flag { transform-origin: 0% 50%; animation: bx-flag 1.2s ease-in-out infinite; }
.nb-svg .bx-sweep { animation: fx-spin 2.2s linear infinite; }
.nb-svg .bx-alt1 { animation: bx-alt 1.6s steps(1) infinite; }
.nb-svg .bx-alt2 { animation: bx-alt 1.6s steps(1) infinite reverse; }
@keyframes bx-blink { 0%, 88%, 100% { transform: scaleY(1); } 93% { transform: scaleY(.1); } }
@keyframes bx-shackle { 0%, 40%, 100% { transform: translateY(0); } 55%, 85% { transform: translateY(-2.5px); } }
@keyframes bx-turn { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-25deg); } }
@keyframes bx-crawl { 0%, 100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(6deg) translateY(-1px); } }
@keyframes bx-cursor { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes bx-wave { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes bx-scan { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(15px); } }
@keyframes bx-glow { 0%, 100% { opacity: .6; filter: none; } 50% { opacity: 1; filter: drop-shadow(0 0 2px currentColor); } }
@keyframes bx-page { 0%, 30% { transform: scaleX(1); } 60%, 100% { transform: scaleX(-1); } }
@keyframes bx-flag { 0%, 100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-6deg) scaleX(.92); } }
@keyframes bx-alt { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .nb-svg .bx { animation: none !important; } .nb-svg .bx-alt2 { opacity: 0; } }

/* ---------- إطارات 16–25 (سايبر) ---------- */
.look-frame .fx-radar { animation: fx-spin 2.8s linear infinite; }
.look-frame .fx-flame { transform-origin: 50% 100%; animation: fx-flame .9s ease-in-out infinite alternate; }
.look-frame .fx-shackle { animation: bx-shackle 2.6s ease-in-out infinite; }
.look-frame .fx-blink { animation: bx-cursor 1s steps(1) infinite; }
.look-frame .fx-scanx { animation: fx-scanx 2.2s ease-in-out infinite; }
@keyframes fx-flame { from { transform: scale(.85, .8); opacity: .75; } to { transform: scale(1.1, 1.2); opacity: 1; } }
@keyframes fx-scanx { 0%, 100% { transform: translateY(0); opacity: .2; } 50% { transform: translateY(88px); opacity: 1; } }
