/* assets/video-layout.css — Claim 4 / Figure 06
 * 상단: 번역 영상 레이어 (영상 프레임 버퍼)
 * 하단: 번역 메시지 레이어 (#chat-box 메시지 버퍼)
 */
.sc-video-container {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    touch-action: manipulation;
    flex-shrink: 0;
}

.sc-video-container.hidden {
    display: none !important;
}

/* Fig 6: 화면을 상·하 프레임으로 고정 분할 */
body.sc-video-active main {
    min-height: 0;
    overflow: hidden;
}

body.sc-video-active section.sc-video-fig6,
body.sc-video-active section.sc-surface {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* 상단 프레임 — 고정 분할 · stage만 세로 스크롤(참여자 타일 증가 시) */
body.sc-video-active #video-container.sc-video-layer-upper,
body.sc-video-active #video-container {
    display: flex;
    flex-direction: column;
    flex: 0 0 48%;
    height: 48%;
    max-height: 48%;
    min-height: 160px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background: #0a0a0a;
    overflow: hidden;
    position: relative;
}

/* 영상 스테이지: 격자 미적용 시 flex-wrap 폴백 */
body.sc-video-active #video-stage.sc-video-stage:not(.sc-video-grid),
body.sc-video-active #video-stage:not(.sc-video-grid) {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: 100%;
    padding: 6px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.7) rgba(15, 23, 42, 0.4);
}

body.sc-video-active #video-stage::-webkit-scrollbar {
    width: 8px;
}
body.sc-video-active #video-stage::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.7);
    border-radius: 8px;
}
body.sc-video-active #video-stage::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.35);
}

/* 하단 프레임 — 번역 메시지 레이어 (메시지 + 입력) 고정 분할 */
body.sc-video-active #chat-message-layer.sc-video-layer-lower,
body.sc-video-active #chat-message-layer {
    flex: 1 1 52%;
    min-height: 0;
    max-height: 52%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--chat, var(--panel, #fff));
    border-top: 1px solid var(--border, #e2e8f0);
}

body.sc-video-active #chat-message-layer #chat-box,
body.sc-video-active #chat-box {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 0.5rem;
    /* TTL>0 메시지 확인용 스크롤바 표시 */
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.7) rgba(226, 232, 240, 0.6);
    -ms-overflow-style: auto;
}

body.sc-video-active #chat-message-layer #chat-box::-webkit-scrollbar,
body.sc-video-active #chat-box::-webkit-scrollbar {
    display: block;
    width: 8px;
}
body.sc-video-active #chat-message-layer #chat-box::-webkit-scrollbar-thumb,
body.sc-video-active #chat-box::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.7);
    border-radius: 8px;
}
body.sc-video-active #chat-message-layer #chat-box::-webkit-scrollbar-track,
body.sc-video-active #chat-box::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.6);
}

body.sc-video-active #chat-message-layer .sc-composer-wrap,
body.sc-video-active .sc-composer-wrap {
    flex: 0 0 auto;
    flex-shrink: 0;
    background: var(--chat, var(--panel, #fff));
    border-top: 1px solid var(--border, #e2e8f0);
    z-index: 5;
}

.sc-video-stage {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    width: 100%;
    min-height: 100%;
    height: auto;
    padding: 6px;
    box-sizing: border-box;
}

.sc-video-tile-wrap {
    position: relative;
    flex: 1 1 calc(50% - 6px);
    width: calc(50% - 6px);
    min-width: 140px;
    height: clamp(120px, 42vh, 220px);
    min-height: 120px;
    max-height: 240px;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
    /* 참여순서 order 적용용 */
    order: 0;
}

.sc-video-tile-label {
    position: absolute;
    left: 6px;
    bottom: 6px;
    z-index: 6;
    max-width: calc(100% - 12px);
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.72);
    color: #f8fafc;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.sc-video-tile-label.sc-owner-peer-clickable {
    pointer-events: auto;
    cursor: pointer;
}
.sc-video-tile-label.sc-owner-peer-clickable:hover,
.sc-video-tile-label.sc-owner-peer-active {
    outline: 2px solid rgba(165, 180, 252, 0.9);
    outline-offset: 1px;
}

/* 승인 전 로고 플레이스홀더 (참여순서 타일) */
.sc-video-logo-placeholder {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    pointer-events: none;
}

.sc-video-logo-placeholder.sc-video-logo-reinvite {
    pointer-events: auto;
    cursor: pointer;
}

.sc-video-logo-placeholder.sc-video-logo-reinvite:active {
    opacity: 0.88;
}

.sc-video-logo-placeholder.hidden {
    display: none !important;
}

.sc-video-logo-placeholder img {
    width: min(42%, 120px);
    height: auto;
    max-height: 45%;
    object-fit: contain;
    opacity: 0.92;
}

.sc-video-tile-wrap.sc-video-live .sc-video-tile.sc-video-has-stream {
    opacity: 1;
}

.sc-video-tile {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: cover;
    border-radius: 8px;
    background: #111;
}

.sc-video-local {
    transform: scaleX(-1);
}

.sc-video-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 30;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 9999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.sc-video-close:active {
    transform: scale(0.95);
}

.sc-subtitle-layer {
    position: absolute;
    bottom: 10%;
    left: 5%;
    right: 5%;
    text-align: center;
    z-index: 20;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.sc-subtitle-layer span {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    display: inline-block;
    max-width: 100%;
    word-break: keep-all;
}

.sc-subtitle-layer.fade-out {
    opacity: 0;
}

/* 발화 닉네임 — 해당 화자 영상 타일 정중앙 */
.sc-speaker-nick-layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 25;
    pointer-events: none;
    transition: opacity 0.35s ease;
    padding: 8px;
    box-sizing: border-box;
}

.sc-speaker-nick-layer.hidden {
    display: none !important;
}

.sc-speaker-nick-layer.fade-out {
    opacity: 0;
}

.sc-speaker-nick-layer .sc-speaker-nick {
    display: inline-block;
    max-width: 100%;
    color: #fff;
    font-size: clamp(1.5rem, 6.5vw, 2.75rem);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.95),
        0 0 18px rgba(0, 0, 0, 0.75);
    word-break: keep-all;
    padding: 4px 8px;
}

/* 채팅: 같은 줄 — 타이머 + 닉네임: 메시지 */
.sc-msg-oneline {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 8px;
}

.sc-msg-oneline .sc-timer {
    flex: 0 0 auto;
}

.sc-msg-oneline .sc-timer.sc-timer-pending {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
}

.sc-msg-oneline .msg-body-text {
    flex: 1 1 auto;
    min-width: 0;
}

/* 화상 중: 채팅창 상단 개설자/참여자 닉 바 숨김 (영상 타일 하단 닉은 유지) */
body.sc-video-active #participant-bar {
    display: none !important;
}

/* 화상 연결 중: 최상단 헤더(언어·로고·ActsLala·링크복사) 숨김 */
body.sc-video-active header.sc-header {
    display: none !important;
}

/* 노트북 화상 하반부: 메시지 2열 */
@media (min-width: 768px) {
    body.sc-video-active #chat-message-layer #chat-box.sc-chat-split,
    body.sc-video-active #chat-box.sc-chat-split {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem 0.75rem;
        align-content: start;
    }
}

/* 공통 인원별 가로 격자 (phone / wide) */
body.sc-video-active #video-stage.sc-video-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-content: stretch;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    gap: 4px;
    padding: 4px;
    overflow-x: hidden;
    box-sizing: border-box;
}

body.sc-video-active #video-stage.sc-video-grid[data-scroll-rows="0"] {
    overflow-y: hidden;
}

body.sc-video-active #video-stage.sc-video-grid[data-scroll-rows="1"] {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

body.sc-video-active #video-stage.sc-video-grid .sc-video-row {
    display: flex;
    flex-direction: row;
    gap: 4px;
    width: 100%;
    min-width: 0;
    flex-shrink: 0;
}

body.sc-video-active #video-stage.sc-video-grid[data-scroll-rows="0"] .sc-video-row {
    flex: 1 1 0;
    min-height: 0;
}

body.sc-video-active #video-stage.sc-video-grid[data-scroll-rows="1"] .sc-video-row {
    flex: 0 0 calc((100% - 8px) / 3);
    height: calc((100% - 8px) / 3);
    min-height: calc((100% - 8px) / 3);
    max-height: calc((100% - 8px) / 3);
}

body.sc-video-active #video-stage.sc-video-grid .sc-video-tile-wrap {
    position: relative;
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 100%;
    min-height: 0;
    max-height: none;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
    order: 0;
}

/* PC·태블릿 wide: 타일 라벨 약간 축소 가능 */
body.sc-video-active #video-stage.sc-video-grid-wide .sc-video-tile-label {
    font-size: clamp(9px, 0.85vw, 12px);
    padding: 1px 6px;
}

@media (max-width: 640px) {
    body.sc-video-active #video-container.sc-video-layer-upper,
    body.sc-video-active #video-container {
        flex: 0 0 40%;
        height: 40%;
        max-height: 40%;
        min-height: 140px;
    }

    body.sc-video-active #chat-message-layer.sc-video-layer-lower,
    body.sc-video-active #chat-message-layer {
        flex: 1 1 60%;
        max-height: 60%;
    }

    body.sc-video-active #video-stage.sc-video-grid-phone .sc-video-tile-label {
        font-size: 10px;
        padding: 1px 6px;
    }

    .sc-subtitle-layer span {
        font-size: 0.9rem;
        padding: 4px 10px;
    }

    .sc-speaker-nick-layer .sc-speaker-nick {
        font-size: clamp(1.35rem, 8vw, 2.2rem);
    }
}
