/* ============================================================
   peer-host.css · 对端主播同源实例与辅助端切换动画
   ------------------------------------------------------------
   对端主播本体同时拥有 .phone.peer-host，内部 UI 完全复用主主播样式。
   本文件只负责辅助端机位、切换按钮和实例 id 改写后的少量作用域补偿。
   ============================================================ */

.auxiliary-view-switcher {
    position: fixed;
    z-index: 120;
    top: 50%;
    left: calc(50% + 204px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transform: translateY(-50%);
    transition: left 420ms cubic-bezier(0.2, 0.82, 0.24, 1);
}

.auxiliary-view-switcher .auxiliary-view-toggle {
    position: relative;
    inset: auto;
    width: 44px;
    height: 112px;
    flex: 0 0 auto;
    transform: none;
    border-radius: 0 18px 18px 0;
    transition: width 320ms ease, height 320ms ease, border-radius 320ms ease,
        color 220ms ease, background 220ms ease, border-color 220ms ease;
}

.auxiliary-view-switcher .auxiliary-view-toggle span:last-child {
    writing-mode: vertical-rl;
    letter-spacing: 2px;
}

.peer-host-toggle {
    z-index: 120;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 0;
    border: 1px solid rgba(var(--brand-3-rgb), 0.24);
    color: rgba(255, 255, 255, 0.9);
    background:
        linear-gradient(135deg, rgba(var(--brand-2-rgb), 0.3), rgba(var(--brand-1-rgb), 0.14)),
        rgba(13, 15, 22, 0.88);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.peer-host-toggle[hidden] {
    display: none !important;
}

.peer-host-toggle-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand-3);
    box-shadow: 0 0 10px rgba(var(--brand-3-rgb), 0.72);
}

.peer-host-toggle[aria-expanded="true"] {
    border-color: rgba(var(--brand-3-rgb), 0.48);
    background:
        linear-gradient(135deg, rgba(var(--brand-1-rgb), 0.62), rgba(var(--brand-2-rgb), 0.34)),
        rgba(13, 15, 22, 0.92);
}

body.audience-viewer-open:not(.audience-viewer-closing) .auxiliary-view-switcher,
body.peer-host-open:not(.peer-host-closing) .auxiliary-view-switcher {
    left: calc(50% - 15px);
}

body.audience-viewer-open:not(.audience-viewer-closing) .auxiliary-view-switcher .auxiliary-view-toggle,
body.peer-host-open:not(.peer-host-closing) .auxiliary-view-switcher .auxiliary-view-toggle {
    inset: auto;
    width: 30px;
    height: 84px;
    border-color: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    color: rgba(255, 255, 255, 0.56);
    background: rgba(16, 18, 24, 0.7);
}

.phone.peer-host {
    --anchor-avatar: url("../assets/peer-host-avatar.png?v=1");
    flex: 0 0 390px;
    opacity: 0;
    transform: translateX(54px) scale(0.985);
    transform-origin: 0 50%;
    transition: opacity 300ms ease, transform 420ms cubic-bezier(0.2, 0.82, 0.24, 1);
}

.phone.peer-host[hidden] {
    display: none !important;
}

.phone.peer-host.is-visible {
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* 主播邀请：复用公共抽屉进退场，只补充对端实例内的邀请信息层级与双操作布局。 */
.peer-host .peer-host-invite-sheet {
    z-index: 30;
    min-height: 318px;
    padding: 10px 20px 24px;
    text-align: center;
}

.peer-host-invite-kicker {
    position: relative;
    z-index: 1;
    min-height: 46px;
    padding: 5px 2px 0;
    color: rgba(255, 255, 255, 0.84);
    font-size: 15px;
    font-weight: 600;
    line-height: 22px;
    text-align: left;
}

.peer-host-invite-identity {
    position: relative;
    z-index: 1;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.peer-host-invite-avatar-wrap {
    position: relative;
    width: 76px;
    height: 76px;
    margin-bottom: 12px;
}

.peer-host-invite-avatar {
    width: 100%;
    height: 100%;
    display: block;
    border: 3px solid color-mix(in srgb, var(--brand-2) 78%, #fff);
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 0 0 3px rgba(var(--brand-2-rgb), 0.1),
        0 10px 25px rgba(0, 0, 0, 0.24);
}

.peer-host-invite-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.peer-host-invite-kind-badge {
    position: absolute;
    right: -3px;
    bottom: -2px;
    z-index: 2;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: #fff;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--brand-3), var(--brand-2) 48%, var(--brand-1));
    box-shadow:
        0 5px 12px rgba(var(--brand-1-rgb), 0.34),
        inset 0 1px 1px rgba(255, 255, 255, 0.34);
}

.peer-host-invite-link-icon,
.peer-host-invite-pk-icon {
    display: none;
}

.peer-host-invite-sheet[data-invite-kind="link"] .peer-host-invite-link-icon {
    width: 23px;
    height: 18px;
    display: block;
    stroke: currentColor;
    stroke-width: 3.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.peer-host-invite-sheet[data-invite-kind="pk"] .peer-host-invite-pk-icon {
    display: block;
    font-size: 10.5px;
    font-weight: 900;
    font-style: italic;
    line-height: 1;
    letter-spacing: -0.7px;
    text-shadow: 0 1px 2px rgba(15, 8, 32, 0.34);
    transform: translateX(-0.6px);
}

.peer-host-invite-identity strong {
    color: #fff;
    font-size: 17px;
    font-weight: 650;
    line-height: 24px;
}

.peer-host-invite-viewers {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.48);
    font-size: 12px;
    line-height: 18px;
}

.peer-host-invite-actions {
    position: relative;
    z-index: 1;
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.peer-host-invite-button {
    height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 13px;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
}

.peer-host-invite-button.reject {
    color: rgba(255, 255, 255, 0.74);
    background: rgba(255, 255, 255, 0.09);
    font-variant-numeric: tabular-nums;
}

.peer-host-invite-button.accept {
    background: linear-gradient(135deg, #43d5ff, #5379ff);
    box-shadow: 0 8px 22px rgba(69, 152, 255, 0.28);
}

.peer-host-invite-button:active {
    transform: scale(0.97);
}

body.peer-host-open {
    gap: 34px;
}

body.peer-host-open > .phone:not(.peer-host) {
    transition: transform 420ms cubic-bezier(0.2, 0.82, 0.24, 1);
}

body.peer-host-entering > .phone:not(.peer-host),
body.peer-host-closing > .phone:not(.peer-host) {
    transform: translateX(212px);
}

/* 主端部分连麦样式使用唯一 id 提升优先级；克隆实例改写 id 后在此补回同一规则。 */
.peer-host [data-peer-source-id="coMicSheet"] {
    z-index: 27;
    max-height: calc(100% - 132px);
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    overscroll-behavior: none;
}

.peer-host [data-peer-source-id="coMicSheet"] .comic-sheet-header .drawer-title {
    grid-column: 2;
    margin-bottom: 0;
    line-height: 20px;
    text-align: center;
}

.peer-host [data-peer-source-id="coMicSheet"] .comic-section + .comic-section {
    margin-top: 12px;
}

@media (max-width: 900px) {
    .auxiliary-view-switcher,
    body.audience-viewer-open .auxiliary-view-switcher,
    body.peer-host-open .auxiliary-view-switcher {
        top: 18px;
        right: 18px;
        left: auto;
        flex-direction: row;
        gap: 8px;
        transform: none;
    }

    .auxiliary-view-switcher .auxiliary-view-toggle,
    body.audience-viewer-open .auxiliary-view-switcher .auxiliary-view-toggle,
    body.peer-host-open .auxiliary-view-switcher .auxiliary-view-toggle {
        width: auto;
        min-width: 92px;
        height: 40px;
        flex-direction: row;
        padding: 0 13px;
        border-radius: 999px;
    }

    .auxiliary-view-switcher .auxiliary-view-toggle span:last-child {
        writing-mode: horizontal-tb;
        letter-spacing: 0;
    }

    body.peer-host-open {
        gap: 0;
    }

    body.peer-host-open > .phone:not(.peer-host) {
        visibility: hidden;
    }

    .phone.peer-host {
        position: fixed;
        z-index: 100;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .phone.peer-host.is-visible {
        transform: translate(-50%, -50%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .phone.peer-host,
    .auxiliary-view-switcher,
    body.peer-host-open > .phone:not(.peer-host) {
        transition-duration: 1ms;
    }
}
