/**
 * PATH: magembed-social-addon/assets/css/mx-social-front.css
 * Frontend styles — Social bar, bottom-sheet, animations.
 *
 * v1.3:
 *  - GLITCH FIX: animation only set on :hover — removed on mouseout →
 *    element returns cleanly via transition on transform+filter
 *  - NEWS TICKER: .mx-sheet-ticker + @keyframes mxs-ticker
 */

:root {
    --mxs-size: 40px;
    --mxs-color: #ffffff;
    --mxs-hover: #ff00ff;
    --mxs-sheet-bg: #0e0e1a;
    --mxs-sheet-border: #B700B7;
    --mxs-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --mxs-transition: 0.2s ease;
}

/* ============================================================
   INLINE SOCIAL BAR
   ============================================================ */
.magbei-social-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 10px 0;
}
.magbei-social-bar.mxs-layout-column { flex-direction: column; align-items: flex-start; }
.magbei-social-bar.mxs-layout-grid   { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--mxs-size), 1fr)); }

.mxs-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #1a1a2e !important;
    border: 1px solid #2a2a3e !important;
    border-radius: 8px;
    color: var(--mxs-color) !important;
    cursor: pointer;
    font-family: var(--mxs-font);
    font-size: 13px;
    font-weight: 600;
    padding: 0 12px;
    height: var(--mxs-size);
    min-width: var(--mxs-size);
    overflow: hidden;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    will-change: transform;
}
.mxs-btn:focus-visible { outline: 2px solid var(--mxs-hover); outline-offset: 2px; }
.mxs-btn.mxs-style-icon_only { padding: 0; }
.mxs-btn svg, .mxs-btn img   { width: 22px; height: 22px; display: block; flex-shrink: 0; }
.mxs-label { white-space: nowrap; }

/* ============================================================
   CORE TOOLBAR SHARE BUTTON
   ============================================================ */
.btn-share-trigger svg {
    width: var(--mxs-toolbar-icon-size, 22px) !important;
    height: var(--mxs-toolbar-icon-size, 22px) !important;
}

/* ============================================================
   NEON GLOW
   ============================================================ */
.mxs-btn.mxs-anim-neon_glow,
.mx-social-icon-btn.mxs-anim-neon_glow {
    transition: border-color var(--mxs-transition), color var(--mxs-transition),
                box-shadow var(--mxs-transition), background var(--mxs-transition);
}
.mxs-btn.mxs-anim-neon_glow:hover,
.mx-social-icon-btn.mxs-anim-neon_glow:hover {
    border-color: var(--mxs-hover) !important;
    color: var(--mxs-hover) !important;
    box-shadow: 0 0 14px var(--mxs-hover), 0 0 5px var(--mxs-hover) inset;
    background: rgba(0,0,0,0.4) !important;
}

/* ============================================================
   GLITCH — v1.3 FIX: clean idle → clean return on mouseout
   TECHNIQUE: no animation declared on idle state.
   On hover: animation assigned + transition:none (fires frame-0).
   On mouseout: :hover removed → animation gone → transform/filter
   reset to identity via the idle transition (0.12s). Ghost layers
   fade out via their opacity transition (0.08s).
   ============================================================ */
.mxs-btn.mxs-anim-glitch,
.mx-social-icon-btn.mxs-anim-glitch {
    transition: transform 0.12s ease, filter 0.12s ease,
                color var(--mxs-transition), border-color var(--mxs-transition);
}
.mxs-btn.mxs-anim-glitch::before,
.mxs-btn.mxs-anim-glitch::after,
.mx-social-icon-btn.mxs-anim-glitch::before,
.mx-social-icon-btn.mxs-anim-glitch::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    transition: opacity 0.08s ease;
}
/* HOVER — animations fire, transitions suppressed */
.mxs-btn.mxs-anim-glitch:hover,
.mx-social-icon-btn.mxs-anim-glitch:hover {
    animation: mxs-glitch-base 0.55s steps(1, end) infinite;
    transition: none;
    color: var(--mxs-hover) !important;
    border-color: var(--mxs-hover) !important;
}
.mxs-btn.mxs-anim-glitch:hover::before,
.mx-social-icon-btn.mxs-anim-glitch:hover::before {
    animation: mxs-glitch-cyan 0.55s steps(1, end) infinite;
    opacity: 1;
    box-shadow: -4px 0 0 #00ffff;
    transition: none;
}
.mxs-btn.mxs-anim-glitch:hover::after,
.mx-social-icon-btn.mxs-anim-glitch:hover::after {
    animation: mxs-glitch-magenta 0.55s steps(1, end) infinite;
    opacity: 1;
    box-shadow: 4px 0 0 #ff00ff;
    transition: none;
}
@keyframes mxs-glitch-base {
    0%   { transform: translate(0,0)       skewX(0deg);  filter: none; }
    10%  { transform: translate(-3px,1px)  skewX(-3deg); filter: hue-rotate(90deg)  brightness(1.4); }
    20%  { transform: translate(3px,-2px)  skewX(2deg);  filter: hue-rotate(180deg) brightness(1.2); }
    30%  { transform: translate(0,0)       skewX(0deg);  filter: none; }
    40%  { transform: translate(2px,2px)   skewX(-1deg); filter: hue-rotate(270deg) brightness(1.3); }
    50%  { transform: translate(-2px,-1px) skewX(3deg);  filter: hue-rotate(45deg); }
    60%  { transform: translate(0,0)       skewX(0deg);  filter: none; }
    70%  { transform: translate(4px,0)     skewX(-2deg); filter: brightness(1.5) saturate(2); }
    80%  { transform: translate(-1px,2px)  skewX(1deg);  filter: hue-rotate(135deg); }
    90%  { transform: translate(0,0)       skewX(0deg);  filter: none; }
    100% { transform: translate(0,0)       skewX(0deg);  filter: none; }
}
@keyframes mxs-glitch-cyan {
    0%   { opacity:0; clip-path:inset(0 0 100% 0);  transform:translate(0); }
    15%  { opacity:1; clip-path:inset(15% 0 70% 0); transform:translate(-5px,0); }
    25%  { opacity:1; clip-path:inset(60% 0 20% 0); transform:translate(-8px,1px); }
    35%  { opacity:0; clip-path:inset(0 0 100% 0);  transform:translate(0); }
    55%  { opacity:1; clip-path:inset(30% 0 50% 0); transform:translate(-4px,-1px); }
    65%  { opacity:0; clip-path:inset(0 0 100% 0);  transform:translate(0); }
    80%  { opacity:1; clip-path:inset(5% 0 85% 0);  transform:translate(-6px,0); }
    90%  { opacity:0; clip-path:inset(0 0 100% 0);  transform:translate(0); }
    100% { opacity:0; }
}
@keyframes mxs-glitch-magenta {
    0%   { opacity:0; clip-path:inset(100% 0 0 0);  transform:translate(0); }
    20%  { opacity:1; clip-path:inset(70% 0 10% 0); transform:translate(5px,0); }
    30%  { opacity:1; clip-path:inset(45% 0 35% 0); transform:translate(8px,-1px); }
    40%  { opacity:0; clip-path:inset(100% 0 0 0);  transform:translate(0); }
    60%  { opacity:1; clip-path:inset(80% 0 5% 0);  transform:translate(4px,2px); }
    70%  { opacity:0; clip-path:inset(100% 0 0 0);  transform:translate(0); }
    85%  { opacity:1; clip-path:inset(55% 0 25% 0); transform:translate(6px,-2px); }
    95%  { opacity:0; clip-path:inset(100% 0 0 0);  transform:translate(0); }
    100% { opacity:0; }
}

/* ============================================================
   SCANLINE
   ============================================================ */
.mxs-btn.mxs-anim-scanline,
.mx-social-icon-btn.mxs-anim-scanline {
    overflow: hidden;
    transition: border-color var(--mxs-transition), color var(--mxs-transition);
}
.mxs-btn.mxs-anim-scanline::after,
.mx-social-icon-btn.mxs-anim-scanline::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg, transparent, transparent 2px,
        rgba(255,255,255,0.04) 2px, rgba(255,255,255,0.04) 4px
    );
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.mxs-btn.mxs-anim-scanline:hover::after,
.mx-social-icon-btn.mxs-anim-scanline:hover::after { opacity: 1; }
.mxs-btn.mxs-anim-scanline:hover,
.mx-social-icon-btn.mxs-anim-scanline:hover {
    border-color: var(--mxs-hover) !important;
    color: var(--mxs-hover) !important;
}

/* Loading */
.mxs-btn.mxs-loading,
.mx-social-icon-btn.mxs-loading { opacity: 0.6; cursor: wait; pointer-events: none; }

/* ============================================================
   BOTTOM SHEET
   ============================================================ */
.mx-social-sheet {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    pointer-events: none;
}
.mx-social-sheet[data-open="true"] { pointer-events: all; }

.mx-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.35s ease;
    cursor: pointer;
}
.mx-social-sheet[data-open="true"] .mx-sheet-backdrop { background: rgba(0,0,0,0.78); }

.mx-sheet-panel {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--mxs-sheet-bg);
    border-top: 2px solid var(--mxs-sheet-border);
    border-radius: 18px 18px 0 0;
    padding: 20px 20px 36px;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 -8px 40px rgba(183,0,183,0.25);
    will-change: transform;
    max-height: 85vh;
    overflow-y: auto;
}
.mx-social-sheet[data-open="true"] .mx-sheet-panel { transform: translateY(0); }

@media (min-width: 769px) {
    .mx-sheet-panel {
        left: 50%; right: auto; bottom: 50%;
        transform: translate(-50%, 60%) scale(0.9);
        width: 480px;
        border-radius: 14px;
        border: 1px solid var(--mxs-sheet-border);
        opacity: 0;
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
    }
    .mx-social-sheet[data-open="true"] .mx-sheet-panel {
        transform: translate(-50%, 50%) scale(1);
        opacity: 1;
    }
}

.mx-sheet-handle {
    width: 40px; height: 4px;
    background: #333;
    border-radius: 2px;
    margin: 0 auto 18px;
}
@media (min-width: 769px) { .mx-sheet-handle { display: none; } }

/* Title: base reset only — typography injected inline from PHP.
   Specificity (2,2,1) via html body prefix + !important = bullet-proof.
   <style id="mx-social-fredoka-lock"> in footer HTML provides the same rule
   as a double-layer guarantee regardless of stylesheet load order.
   Element is a <div> not h3/h2 so theme heading resets don't target it. */
html body #mx-social-sheet .mx-sheet-title {
    display: block;
    width: 100%;
}

/* ============================================================
   SUB-HEADER (static)
   Only present in DOM when text is non-empty.
   ============================================================ */
.mx-sheet-subheader {
    display: block;
    width: 100%;
    font-family: 'Fredoka', sans-serif;
}
.mx-sheet-subheader a,
.mx-ticker-content a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.mx-sheet-subheader a:hover,
.mx-ticker-content a:hover { opacity: 1; }

/* ============================================================
   NEWS TICKER (right → left)
   Only present in DOM when text is non-empty.
   ============================================================ */
.mx-sheet-ticker {
    width: 100%;
    overflow: hidden;
    position: relative;
}
/* Edge fade */
.mx-sheet-ticker::before,
.mx-sheet-ticker::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    width: 24px;
    z-index: 2;
    pointer-events: none;
}
.mx-sheet-ticker::before {
    left: 0;
    background: linear-gradient(to right, var(--mxs-sheet-bg), transparent);
}
.mx-sheet-ticker::after {
    right: 0;
    background: linear-gradient(to left, var(--mxs-sheet-bg), transparent);
}
.mx-ticker-track {
    display: flex;
    width: max-content;
    animation: mxs-ticker 18s linear infinite;
}
/* Pause on hover so user can read / click link */
.mx-sheet-ticker:hover .mx-ticker-track { animation-play-state: paused; }

.mx-ticker-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-family: 'Fredoka', sans-serif;
}

/* Dot separator between ticker text and link */
.mx-ticker-dot {
    display: inline-block;
    width: 4px; height: 4px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.4;
    flex-shrink: 0;
    vertical-align: middle;
}

@keyframes mxs-ticker {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============================================================
   SHEET ICONS
   ============================================================ */
.mx-sheet-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding-bottom: 10px;
}

.mx-social-icon-btn {
    position: relative;
    background: #1a1a2e !important;
    border: 1px solid #2a2a3e !important;
    border-radius: 12px;
    color: var(--mxs-color) !important;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    width: 72px;
    font-family: var(--mxs-font);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    will-change: transform;
}
.mx-social-icon-btn svg,
.mx-social-icon-btn img { width: 28px; height: 28px; display: block; }
.mxs-icon-label {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.mx-sheet-close {
    position: absolute;
    top: 16px; right: 18px;
    background: transparent !important;
    border: none !important;
    color: #666 !important;
    font-size: 20px;
    cursor: pointer !important;
    transition: color 0.2s;
    line-height: 1;
    padding: 4px;
}
.mx-sheet-close:hover { color: #ff00ff !important; }

/* ============================================================
   TOAST
   ============================================================ */
.mxs-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1a2e;
    border: 1px solid #B700B7;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--mxs-font);
    font-size: 14px;
    z-index: 9999999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(183,0,183,0.3);
    white-space: nowrap;
}
.mxs-toast.mxs-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
