/* ================================================================
   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');

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

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: 33%;
    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 — title frame (long horizontal art)
   Native asset size: 3500 × 926  (aspect ratio ≈ 3.78 : 1)
   We size by width and let aspect-ratio derive the height so the avatar/name
   overlay always lines up with the frame's text band, regardless of viewport. */
.ma-frame-wrap {
    position: relative;
    width: 30%;
    aspect-ratio: 3500 / 926;
    height: auto;
    flex-shrink: 0;
    container-type: size;
    container-name: maframe;
}

/* Fallback band when no frame artwork is supplied — match the in-app
   cast-list pill style: dark navy rounded card, subtle border, drop shadow. */
.ma-frame-wrap.no-frame {
    background: #1f2a44;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.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(670 / 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: 60%;
    aspect-ratio: 3500 / 926;
}

/* 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%;
}