/*
 * MK FASHION · item styles (Phase 1). Loaded only when a feature flag is on: mk_fashion_css_tag().
 * Performance rules: every animation moves only transform/opacity (compositor, no repaint),
 * no filter:blur, no animated box-shadow; every box has a fixed size (no layout shift);
 * everything stops under prefers-reduced-motion and while off-screen (.mk-anim-off from mk-offscreen.js).
 *
 * Markup (classes come from mk_fashion_item_class()):
 *   name   <span class="mkf-user"><span class="mkf-name mkf-nc-…" data-text="NAME">NAME</span>…</span>
 *   frame  <span class="mkf-frame mkf-fr-…" style="--mkf-size:48px"><img src="…" alt=""></span>
 *   title  <span class="mkf-title mkf-tt-…">ฉายา</span>
 *   banner <div class="mkf-banner mkf-rb-…">…</div>   bubble <div class="mkf-bubble mkf-cb-…">…</div>
 *   cursor <div class="mkf-cursor mkf-cu-…">…</div>
 */

/* ── keyframes (transform / opacity only) ── */
@keyframes mkf-spin { to { transform: rotate(360deg); } }
@keyframes mkf-breathe { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }
@keyframes mkf-twinkle { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes mkf-sweep { 0% { transform: translateX(-120%) skewX(-18deg); } 35%, 100% { transform: translateX(330%) skewX(-18deg); } }

/* ── username + verified tick ── */
.mkf-user { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; vertical-align: middle; }
.mkf-name { position: relative; display: inline-block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkf-vb { display: inline-flex; flex: none; width: 16px; height: 16px; line-height: 0; cursor: help; }
.mkf-vb__svg { display: block; width: 16px; height: 16px; }

/* ── name colours ── */
.mkf-nc-mint { color: #34d399; }
.mkf-nc-sky, .mkf-nc-sunset, .mkf-nc-aurora,
.mkf-nc-sunset::after, .mkf-nc-aurora::after {
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
.mkf-nc-sky { background-image: linear-gradient(90deg, #38bdf8, #818cf8); }
.mkf-nc-sunset { background-image: linear-gradient(90deg, #fb923c, #f43f5e 55%, #e879f9); }
.mkf-nc-aurora { background-image: linear-gradient(90deg, #34d399, #22d3ee 45%, #a78bfa); }
/* glow layer: same text, brighter gradient, only its opacity animates */
.mkf-nc-sunset::after, .mkf-nc-aurora::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0;
  animation: mkf-breathe 3.2s ease-in-out infinite;
}
.mkf-nc-sunset::after { background-image: linear-gradient(90deg, #fde68a, #fdba74, #fbcfe8); }
.mkf-nc-aurora::after { background-image: linear-gradient(90deg, #fef9c3, #fde68a 40%, #ffffff); animation-duration: 2.6s; }

/* ── titles (ฉายา): fixed height pill ── */
.mkf-title {
  position: relative; display: inline-flex; align-items: center; flex: none; height: 18px; padding: 0 7px;
  border-radius: 999px; font-size: 11px; line-height: 18px; font-weight: 600; white-space: nowrap;
  overflow: hidden; contain: paint; vertical-align: middle;
}
.mkf-tt-plain { color: #cbd5e1; border: 1px solid rgba(203, 213, 225, .35); line-height: 16px; }
.mkf-tt-steel { color: #e2e8f0; background: linear-gradient(135deg, #475569, #1e293b); }
.mkf-tt-royal { color: #fff; background: linear-gradient(135deg, #7c3aed, #4338ca); }
.mkf-tt-mythic { color: #3b2600; background: linear-gradient(135deg, #fde68a, #f59e0b 55%, #b45309); }
.mkf-tt-mythic::before { content: "\2726"; margin-right: 4px; font-size: 10px; }
.mkf-tt-newyear { color: #fff7ed; background: linear-gradient(135deg, #dc2626, #b91c1c 60%, #f59e0b); }
.mkf-tt-royal::after, .mkf-tt-mythic::after, .mkf-tt-newyear::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: translateX(-120%) skewX(-18deg); animation: mkf-sweep 4.5s ease-in-out infinite;
}
.mkf-tt-mythic::after { animation-duration: 3.6s; }

/* ── avatar frames: ring = ::before behind the picture; the picture covers its centre ── */
.mkf-frame {
  --mkf-size: 48px; --mkf-ring: 3px;
  position: relative; display: inline-block; flex: none; width: var(--mkf-size); height: var(--mkf-size);
  border-radius: 50%; isolation: isolate; vertical-align: middle;
}
.mkf-frame > img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #0c0d15; }
.mkf-frame::before, .mkf-frame::after {
  content: ""; position: absolute; inset: calc(var(--mkf-ring) * -1); border-radius: 50%; pointer-events: none;
}
.mkf-frame::before { z-index: 0; }
.mkf-frame::after { z-index: 2; }
.mkf-fr-silver::before { background: linear-gradient(135deg, #f8fafc, #94a3b8 45%, #e2e8f0 60%, #64748b); }
.mkf-fr-silver::after, .mkf-fr-nebula::after { content: none; }
.mkf-fr-ocean::before { background: linear-gradient(135deg, #67e8f9, #0ea5e9 50%, #1d4ed8); }
.mkf-fr-ocean::after {
  z-index: -1; inset: calc(var(--mkf-ring) * -1 - 6px);
  background: radial-gradient(circle, transparent 60%, rgba(56, 189, 248, .45) 66%, transparent 74%);
  animation: mkf-breathe 3.4s ease-in-out infinite;
}
.mkf-fr-nebula::before { background: conic-gradient(#a855f7, #ec4899, #6366f1, #22d3ee, #a855f7); animation: mkf-spin 6s linear infinite; }
.mkf-fr-phoenix { --mkf-ring: 3.5px; }
.mkf-fr-phoenix::before { background: conic-gradient(#fde68a, #f59e0b, #dc2626, #f97316, #fde68a); animation: mkf-spin 4s linear infinite; }
.mkf-fr-phoenix::after {
  inset: calc(var(--mkf-ring) * -1 - 2px);
  background: radial-gradient(circle at 50% 3px, #fff 0 1.5px, rgba(253, 230, 138, .95) 2.5px, transparent 5px);
  animation: mkf-spin 2.6s linear infinite reverse;
}
.mkf-fr-frost::before { background: linear-gradient(135deg, #f0f9ff, #bae6fd 40%, #7dd3fc 60%, #e0f2fe); }
.mkf-fr-frost::after {
  inset: calc(var(--mkf-ring) * -1 - 3px);
  background:
    radial-gradient(circle at 50% 2px, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 88% 30%, #fff 0 1.2px, transparent 2.2px),
    radial-gradient(circle at 12% 72%, #fff 0 1.2px, transparent 2.2px),
    radial-gradient(circle at 70% 94%, #fff 0 1px, transparent 2px);
  animation: mkf-twinkle 2.4s ease-in-out infinite;
}

/* ── ranking banners: art on ::before (behind content), moving light on ::after ── */
.mkf-banner { position: relative; isolation: isolate; overflow: hidden; contain: paint; }
.mkf-banner::before, .mkf-banner::after { content: ""; position: absolute; pointer-events: none; }
.mkf-banner::before { inset: 0; z-index: -1; border-radius: inherit; }
.mkf-banner::after { top: 0; bottom: 0; left: 0; width: 30%; z-index: -1; transform: translateX(-120%) skewX(-18deg); }
.mkf-rb-slate::before { background: linear-gradient(135deg, #334155, #1e293b 60%, #0f172a); }
.mkf-rb-slate::after { content: none; }
.mkf-rb-tide::before { background: linear-gradient(120deg, #0c4a6e, #0369a1 45%, #0e7490); }
.mkf-rb-tide::after { background: linear-gradient(90deg, transparent, rgba(186, 230, 253, .22), transparent); animation: mkf-sweep 6s ease-in-out infinite; }
.mkf-rb-galaxy::before {
  background:
    radial-gradient(circle at 12% 30%, rgba(255, 255, 255, .8) 0 1px, transparent 1.6px),
    radial-gradient(circle at 38% 75%, rgba(255, 255, 255, .6) 0 1px, transparent 1.6px),
    radial-gradient(circle at 66% 22%, rgba(255, 255, 255, .7) 0 1px, transparent 1.6px),
    radial-gradient(ellipse at 80% 60%, rgba(236, 72, 153, .35), transparent 55%),
    linear-gradient(135deg, #1e1b4b, #312e81 50%, #4c1d95);
}
.mkf-rb-galaxy::after {
  inset: 0; width: auto; transform: none;
  background:
    radial-gradient(circle at 24% 62%, #fff 0 1.2px, transparent 2px),
    radial-gradient(circle at 52% 40%, #fff 0 1px, transparent 1.8px),
    radial-gradient(circle at 88% 28%, #fff 0 1.2px, transparent 2px);
  animation: mkf-twinkle 3s ease-in-out infinite;
}
.mkf-rb-dragon { box-shadow: inset 0 0 0 1px rgba(251, 191, 36, .55); }
.mkf-rb-dragon::before { background: radial-gradient(ellipse at 85% 50%, rgba(251, 191, 36, .35), transparent 60%), linear-gradient(120deg, #450a0a, #991b1b 50%, #c2410c); }
.mkf-rb-dragon::after { background: linear-gradient(90deg, transparent, rgba(253, 230, 138, .35), transparent); animation: mkf-sweep 5s ease-in-out infinite; }

/* ── chat bubbles (double class beats the chat's own bubble colours) ── */
.mkf-bubble { position: relative; overflow: hidden; }
.mkf-bubble.mkf-cb-cloud { background: #f1f5f9; color: #0f172a; border: 1px solid #e2e8f0; }
.mkf-bubble.mkf-cb-mint { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #064e3b; border: 1px solid #6ee7b7; }
.mkf-bubble.mkf-cb-candy { background: linear-gradient(135deg, #f472b6, #a855f7); color: #fff; border: 1px solid rgba(255, 255, 255, .25); }
.mkf-bubble.mkf-cb-candy::after {
  content: ""; position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; pointer-events: none;
  background: radial-gradient(circle, #fff 0 1.5px, transparent 2.5px), linear-gradient(#fff, #fff) center / 1px 8px no-repeat, linear-gradient(#fff, #fff) center / 8px 1px no-repeat;
  animation: mkf-twinkle 2.2s ease-in-out infinite;
}
.mkf-bubble.mkf-cb-golden {
  color: #fef3c7; border: 1px solid transparent;
  background: linear-gradient(#1c1404, #1c1404) padding-box, linear-gradient(135deg, #fde68a, #b45309 50%, #fde68a) border-box;
}
.mkf-bubble.mkf-cb-golden::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 30%; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(253, 230, 138, .18), transparent);
  transform: translateX(-120%) skewX(-18deg); animation: mkf-sweep 5.5s ease-in-out infinite;
}

/* ── cursors: static SVG, mouse / trackpad only ── */
@media (pointer: fine) {
  .mkf-cu-ring { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='%2334d399' stroke-width='2'/%3E%3Ccircle cx='12' cy='12' r='2.2' fill='%2334d399'/%3E%3C/svg%3E") 12 12, auto; }
  .mkf-cu-neon { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M3 2v18l5-5 3.6 7 2.6-1.2-3.5-6.8H18z' fill='%2322d3ee' stroke='%230e7490' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") 3 2, auto; }
  .mkf-cu-star { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M12 2l2.9 6.3 6.9.7-5.2 4.6 1.5 6.8L12 16.9l-6.1 3.5 1.5-6.8L2.2 9l6.9-.7z' fill='%23a855f7' stroke='%23fff' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") 12 12, auto; }
  .mkf-cu-crown { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Cpath d='M3 2v18l5-5 3.6 7 2.6-1.2-3.5-6.8H18z' fill='%23fbbf24' stroke='%2378350f' stroke-width='1.2' stroke-linejoin='round'/%3E%3Cpath d='M17 20l1.5-4 2.5 2.2 2.5-2.2 1.5 4z' fill='%23fde68a' stroke='%2378350f' stroke-width='.9' stroke-linejoin='round'/%3E%3C/svg%3E") 3 2, auto; }
}

/* ── battery savers ── */
.mk-anim-off, .mk-anim-off::before, .mk-anim-off::after { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  .mkf-name::after, .mkf-title::after, .mkf-frame::before, .mkf-frame::after,
  .mkf-banner::after, .mkf-bubble::after { animation: none !important; }
  /* moving lights disappear; glow layers stay off; rings and stars stay as still pictures */
  .mkf-name::after, .mkf-title::after, .mkf-fr-ocean::after, .mkf-rb-tide::after,
  .mkf-rb-dragon::after, .mkf-cb-golden::after { opacity: 0 !important; }
}

/* ── Phase 3: ring overlay for the site's existing round avatars ──
 * <span class="mkf-ring mkf-fr-…"> inside a position:relative avatar box. Same frame classes as .mkf-frame;
 * the ring is masked to a band just outside the picture, so the avatar stays visible underneath. */
.mkf-ring { --mkf-ring: 3px; position: absolute; inset: 0; z-index: 9; border-radius: 50%; pointer-events: none; isolation: isolate; }
.mkf-ring::before, .mkf-ring::after {
  content: ""; position: absolute; inset: calc(var(--mkf-ring) * -1); border-radius: 50%; pointer-events: none;
}
.mkf-ring::before {
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--mkf-ring) - .5px), #000 calc(100% - var(--mkf-ring)));
          mask: radial-gradient(farthest-side, transparent calc(100% - var(--mkf-ring) - .5px), #000 calc(100% - var(--mkf-ring)));
}
.mkf-ring.mkf-fr-phoenix { --mkf-ring: 3.5px; }

/* ── Phase 3: profile banner (ปกโปรไฟล์) ── */
.mkf-pbanner { position: relative; display: block; width: 100%; height: 92px; border-radius: 16px; margin-bottom: 14px; overflow: hidden; contain: paint; background: #0c0d15; }
.mkf-pbanner.mkf-img > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Phase 3: chat bubbles inside the chat window (beats .mk-chat-row.is-me .mk-chat-bub) ── */
.mk-chat-row .mk-chat-bub.mkf-bubble.mkf-cb-cloud { background: #f1f5f9; color: #0f172a !important; border: 1px solid #e2e8f0; }
.mk-chat-row .mk-chat-bub.mkf-bubble.mkf-cb-mint { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #064e3b !important; border: 1px solid #6ee7b7; }
.mk-chat-row .mk-chat-bub.mkf-bubble.mkf-cb-candy { background: linear-gradient(135deg, #f472b6, #a855f7); color: #fff !important; border: 1px solid rgba(255, 255, 255, .25); }
.mk-chat-row .mk-chat-bub.mkf-bubble.mkf-cb-golden {
  color: #fef3c7 !important; border: 1px solid transparent;
  background: linear-gradient(#1c1404, #1c1404) padding-box, linear-gradient(135deg, #fde68a, #b45309 50%, #fde68a) border-box;
}

@media (prefers-reduced-motion: reduce) {
  .mkf-ring::before, .mkf-ring::after { animation: none !important; }
  .mkf-ring.mkf-fr-ocean::after { opacity: 0 !important; }
}

/* ── Phase 4: no sideways scrolling on phones ──
 * A long name + verified tick + title (ฉายา) shrinks inside its box instead of widening it: the title pill
 * may shorten with "…" (text only, never numbers); the tick never shrinks. */
.mkf-user > .mkf-name { flex: 0 1 auto; }
.mkf-user > .mkf-title { display: inline-block; flex: 0 1 auto; min-width: 0; max-width: 100%; text-overflow: ellipsis; }

/* the member's own avatar in the navbar wears the MK FASHION ring over its 2 px accent border */
.avatar-ring-sm > .mkf-ring { inset: -2px; }

/* live-synced placeholders (window.mkfShell) */
[data-mkf-me-banner][hidden], [data-mkf-me-av] > .mkf-ring[hidden] { display: none !important; }
