/* ================================================================
   member-animation.css  —  Mobile-portrait transparent overlay
   Title frame LEFT · Sprite RIGHT (compact row, anchored top)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;600;700;800&display=swap');

/* ทุก overlay ต้องไม่แสดง scrollbar ใน OBS/CEF — ซ่อน scrollbar ทุก browser (ไม่แตะ overflow/layout) */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { display: none; }

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Hide legacy elements for script compatibility */
#ma-user, #ma-user-avatar, #frame-img {
    display: none !important;
}

html,
body {
    width: 100vw;
    height: 100vh;
    background: transparent;
    overflow: visible;
}

/* Mobile-portrait stage — 1080x1920 fixed canvas */
.ma-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 1000px;
    height: 1000px;
    pointer-events: none;
}

/* Row that holds title + sprite, near the top of the mobile area */
.ma-row {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    display: none;
    /* hidden by default; shown via .ma-row.show */
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 0 0 6%;
    /* sprite flush to the container's right edge */
    gap: 0;
    height: 20%;
    opacity: 0;
}

.ma-row.show {
    display: flex;
    opacity: 1;
}

/* ----- Enter / Exit animations -----
   Frame slides in from the left, sprite from the right, badge fades in.
   On hide (.ma-row losing .show), the row uses a quick fade-out via
   opacity transition; the inner pieces use keyframes for entry. */
.ma-row.show .ma-frame-wrap {
    animation: ma-frame-in 1s cubic-bezier(.18, .89, .32, 1.28) both;
}

.ma-row.show .sprite-video {
    animation: ma-sprite-in 1s cubic-bezier(.18, .89, .32, 1.28) both;
}

.ma-row.show .ma-user {
    animation: ma-user-in 1s ease-out 0.25s both;
}

.ma-row {
    transition: opacity 1s ease-in;
}

.ma-row.hiding {
    opacity: 0;
}

@keyframes ma-frame-in {
    0% {
        transform: translateX(-120%) scale(0.85);
        opacity: 0;
    }

    60% {
        transform: translateX(8%) scale(1.03);
        opacity: 1;
    }

    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes ma-sprite-in {
    0% {
        transform: translateX(140%) scale(0.7);
        opacity: 0;
    }

    55% {
        transform: translateX(-6%) scale(1.08);
        opacity: 1;
    }

    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes ma-user-in {
    0% {
        transform: translateY(40%) scale(0.6);
        opacity: 0;
    }

    70% {
        transform: translateY(-6%) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Exit animations — applied when JS adds .hiding before removing .show */
.ma-row.show.hiding .ma-frame-wrap {
    animation: ma-frame-out 1s ease-in both;
}

.ma-row.show.hiding .sprite-video {
    animation: ma-sprite-out 1s ease-in both;
}

.ma-row.show.hiding .ma-user {
    animation: ma-user-out 0.8s ease-in both;
}

@keyframes ma-frame-out {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateX(-130%) scale(0.85);
        opacity: 0;
    }
}

@keyframes ma-sprite-out {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateX(150%) scale(0.7);
        opacity: 0;
    }
}

@keyframes ma-user-out {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(30%) scale(0.7);
        opacity: 0;
    }
}

/* LEFT — notify badge container */
.ma-frame-wrap {
    position: relative;
    width: auto;
    max-width: 650px;
    height: auto;
    flex-shrink: 0;
}

/* คอนเทนเนอร์หลัก */
.notify-badge {
    display: inline-flex;
    align-items: center;
    justify-content: space-between; 
    background: linear-gradient(-45deg, rgba(0, 210, 255, 0.8), rgba(58, 123, 213, 0.8), rgba(0, 201, 255, 0.8), rgba(146, 254, 157, 0.8));
    background-size: 300% 300%;
    animation: gradient-move 8s ease infinite;
    width: auto;
    gap: 20px;
    padding: 6px 24px 6px 6px; 
    border-radius: 50px;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); /* ลดเงาลงนิดหน่อยให้ดูนุ่มนวล */
}

@keyframes gradient-move {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* จัดกลุ่มส่วนด้านซ้าย */
.left-content {
    display: flex;
    align-items: center;
    gap: 15px; 
}

/* รูป Avatar ใน Badge */
.ma-user-avatar-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    object-fit: cover;
    background: #333;
    flex-shrink: 0;
}

/* ป้ายเลเวล */
.level-tag {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.25); 
    border: 1.5px solid rgba(255, 255, 255, 0.4); 
    padding: 4px 14px 4px 6px;
    border-radius: 25px;
    gap: 8px;
}

/* ไอคอน 'LV' / 'VI' (ใจส้ม TikTok) */
.vi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #ff7a00; /* TikTok orange heart color */
    flex-shrink: 0;
}

.vi-icon svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
    filter: drop-shadow(0 1px 4px rgba(255, 122, 0, 0.6)); /* orange glow */
}

/* ตัวเลขเลเวล */
.level-number {
    font-size: 18px;
    font-weight: 800;
}

/* ชื่อผู้ใช้ */
.username {
    font-size: 18px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3); /* ลดความเข้มของเงาตัวอักษรลงนิดหน่อย */
    color: white;
}

/* สถานะด้านขวา */
.status-text {
    font-size: 18px;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    color: white;
}

.frame-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    /* exact fit — wrap already has the right aspect */
    object-position: center center;
    position: relative;
    z-index: 2;
    /* sits ABOVE the avatar so the frame ring overlaps it */
}

/* User badge: avatar slot occupies the LEFT 645px of the 3500-wide frame,
   nickname fills the remaining band on the right.
   Sizes are expressed as % of the frame so they scale with the wrap. */
.ma-user {
    position: absolute;
    inset: 0;
    /* fill the frame wrap */
    z-index: 5;
    /* whole user layer ABOVE frame-img (z=2) */
    color: #fff;
    /* System fallbacks so OBS CEF can render even if Google Fonts is blocked. */
    font-family: 'Noto Sans Thai', 'Segoe UI', 'Tahoma', 'Leelawadee UI', sans-serif;
    /* size relative to the title-frame height so it scales with the frame,
       not the browser viewport (works correctly in OBS browser sources) */
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    -webkit-text-stroke: 0 transparent;
    paint-order: normal;
    text-shadow: none;
    pointer-events: none;
}

#ma-user-name {
    /* Right band: starts after the avatar slot (645/3500) and ends near right edge.
       When .ma-user has the .no-avatar class, expand to fill the entire band. */
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(1300 / 3500 * 100%);
    right: 0;
    padding-right: 1%;
    display: block;
    overflow: hidden;
    z-index: 3;
    /* font-size set inline by JS based on band height — fallback below */
    font-size: max(18px, 14cqh);
    color: #fff;
    -webkit-text-stroke: 0 transparent;
    paint-order: normal;
    text-shadow: none;
    /* Vertical centering via line-height matching band height. */
    line-height: 1;
    text-align: left;
}

.ma-gold {
    color: #ffd700;
    /* Gold */
}

#ma-user-name-inner {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    vertical-align: middle;
    /* Vertically centre the inner text by aligning its mid-line with the
       band's mid-line via a sibling pseudo (see ::before below). */
}

#ma-user-name::before {
    /* Inline-block with full band height to align inner span via vertical-align:middle */
    content: "";
    display: inline-block;
    height: 100%;
    vertical-align: middle;
    width: 0;
}

#ma-user-name-inner.ma-marquee {
    display: inline-block;
    width: auto;
    max-width: none;
    text-overflow: clip;
    animation: ma-marquee var(--ma-scroll-dur, 5s) linear both;
}

@keyframes ma-marquee {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(0);
    }

    /* Wait during fade-in and a bit more */
    80% {
        transform: translateX(var(--ma-scroll-dist, 0));
    }

    /* Reach end before fade-out starts */
    100% {
        transform: translateX(var(--ma-scroll-dist, 0));
    }

    /* Stay at end */
}

/* Name always starts from the same point regardless of avatar presence,
   so rows align cleanly when multiple members flash in succession. */

.ma-user-avatar {
    /* Centred on the circular hole in the artwork.
       Hole approx: cx ≈ 380 px, diameter ≈ 560 px (within 3500 × 926). */
    position: absolute;
    width: calc(560 / 3500 * 100%);
    /* ~16% wide */
    aspect-ratio: 1;
    top: 50%;
    left: calc(900 / 3500 * 100%);
    /* circle centre x */
    transform: translate(-50%, -50%);
    border-radius: 50%;
    object-fit: cover;
    background: #333;
    border: none;
    /* let the artwork's ring be the visible border */
    z-index: 1;
    /* BEHIND the frame so the frame ring overlaps the avatar */
}

/* RIGHT — sprite video, taller so the character pops above the frame */
.sprite-video {
    display: block;
    width: 70%;
    height: auto;
    margin-left: 0;
    margin-bottom: -8%;
    object-fit: contain;
    background: transparent;
    flex-shrink: 0;
}

/* ── Split-mode layouts ──────────────────────────────────────────────
   Each browser source shows only its part; OBS handles positioning.  */

/* frame_title-only: sprite is hidden, frame fills available space */
.ma-row.ma-frame-only .sprite-video {
    display: none !important;
}

.ma-row.ma-frame-only .ma-frame-wrap {
    width: 100%;
    max-width: 650px;
    aspect-ratio: unset;
}

/* sprite-only: frame is hidden, sprite fills the row */
.ma-row.ma-sprite-only .ma-frame-wrap {
    display: none !important;
}

.ma-row.ma-sprite-only .sprite-video {
    width: 80%;
    margin-bottom: -8%;
}