/*
 * Pinkfong TV — TikTok Live / FreeReels-inspired full-bleed player with overlay chat
 */

:root {
    --nf-bg: #0b0b0f;
    --nf-surface: #16161a;
    --nf-surface-2: #24242a;
    --nf-surface-active: #34343c;
    --nf-border: rgba(255, 255, 255, 0.14);
    --nf-ink: #f5f5f7;
    --nf-ink-soft: rgba(245, 245, 247, 0.68);
    --nf-red: #ff3b30;
    --nf-red-hover: #ff5147;
    --ui-h: 44px;
    --ease-out: cubic-bezier(.22, .72, .2, 1);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--nf-bg);
    color: var(--nf-ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

button {
    cursor: pointer;
}

button:focus,
a:focus,
input:focus,
button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.is-hidden {
    display: none !important;
}

.icon-svg {
    width: 22px;
    height: 22px;
    flex: none;
}

/* -------------------------------------------------------------------------- */
/* Full-Bleed Stage                                                           */
/* -------------------------------------------------------------------------- */

.nf-stage-wrap {
    position: relative;
    width: 100%;
    height: 100svh;
    height: 100dvh;
    background: #000;
    overflow: hidden;
    user-select: none;
}

.nf-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    cursor: pointer;
}

.nf-video.is-fill {
    object-fit: cover;
}

.nf-video::cue {
    background: rgba(0, 0, 0, .72);
    color: #fff;
    font-size: 0.88em;
    font-weight: 700;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .92);
}

.nf-video.sub-sm::cue {
    font-size: 0.72em;
}

.nf-video.sub-md::cue {
    font-size: 0.88em;
}

.nf-video.sub-lg::cue {
    font-size: 1.08em;
}

/* Top & Full-Width Bottom Overlay Gradients */
.nf-hud-top,
.nf-hud-bottom {
    position: absolute;
    z-index: 10;
    transition: opacity .26s var(--ease-out), transform .26s var(--ease-out);
}

.nf-right-rail {
    position: absolute;
    z-index: 12;
    transition: opacity .26s var(--ease-out), transform .26s var(--ease-out);
}

.nf-icon-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nf-hud-top {
    top: 0;
    left: 0;
    right: 0;
    padding: clamp(12px, 2vh, 20px) clamp(12px, 2vw, 22px) 36px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .28) 60%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
}

/* Full width so gradient shadow never cuts vertically on the right */
.nf-hud-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 84px clamp(14px, 2.2vh, 22px) clamp(14px, 2.2vw, 24px);
    background: linear-gradient(to top, rgba(0, 0, 0, .86) 0%, rgba(0, 0, 0, .42) 60%, transparent 100%);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
}

.nf-stage-wrap.is-hud-visible .nf-hud-top,
.nf-stage-wrap.is-hud-visible .nf-hud-bottom {
    opacity: 1;
    transform: translateY(0);
}

.nf-stage-wrap.is-hud-visible .nf-hud-top {
    pointer-events: auto;
}

.nf-stage-wrap.is-idle {
    cursor: none;
}

.nf-top-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.nf-top-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: none;
}

.nf-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ui-h);
    height: var(--ui-h);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    text-decoration: none;
    flex: none;
    transition: background-color .16s ease, transform .16s var(--ease-out);
}

.nf-icon-btn:hover {
    background: rgba(255, 255, 255, .26);
    transform: scale(1.06);
}

.nf-icon-ghost {
    background: rgba(0, 0, 0, .36);
    backdrop-filter: blur(8px);
}

.nf-icon-btn.is-locked {
    background: var(--nf-red);
}

.nf-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 4px 12px;
    border: 0;
    border-radius: 999px;
    background: var(--nf-red);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    flex: none;
}

.nf-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    animation: nf-pulse 1.3s ease-in-out infinite alternate;
}

@keyframes nf-pulse {
    from {
        opacity: .45;
        transform: scale(.8);
    }
    to {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* -------------------------------------------------------------------------- */
/* Bottom-Left Stack: TikTok Floating Chat + Movie Title + Say Something      */
/* -------------------------------------------------------------------------- */

.nf-bottom-left-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    max-width: 380px;
    pointer-events: auto;
}

.nf-tiktok-feed {
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 14px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 22%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 22%);
}

.nf-tiktok-feed::-webkit-scrollbar {
    display: none;
}

.nf-tiktok-feed.is-chat-hidden,
.nf-tiktok-form.is-chat-hidden {
    display: none;
}

.tt-msg {
    align-self: flex-start;
    max-width: 100%;
    padding: 2px 14px;
    font-size: 13px;
    line-height: 1.4;
    color: #fff;
    word-break: break-word;
    text-shadow: 0 1px 4px rgba(0, 0, 0, .95), 0 2px 10px rgba(0, 0, 0, .7);
}

.tt-msg-system {
    color: #ffd6d4;
    font-size: 12px;
    font-weight: 700;
}

.tt-author {
    font-weight: 800;
    color: #ff8599;
    margin-right: 6px;
}

.nf-title-group {
    max-width: 100%;
    min-width: 0;
    padding: 0 14px;
}

.nf-top-left .nf-title-group {
    flex: 1;
    padding: 0 4px;
}

.nf-movie-title {
    margin: 0 0 2px;
    font-size: clamp(14px, 1.45vw, 18px);
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .8);
}

.nf-next-line {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, .78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
}

.nf-tiktok-form {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.nf-tiktok-input {
    flex: 1;
    min-width: 0;
    height: var(--ui-h);
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, .42);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    transition: background-color .16s ease;
}

.nf-tiktok-input:focus {
    background: rgba(0, 0, 0, .62);
}

.nf-tiktok-input::placeholder {
    color: rgba(255, 255, 255, .72);
}

.nf-tiktok-send {
    background: rgba(0, 0, 0, .42);
    backdrop-filter: blur(8px);
}

/* -------------------------------------------------------------------------- */
/* Right Floating Vertical Action Rail                                        */
/* -------------------------------------------------------------------------- */

.nf-right-rail {
    right: clamp(10px, 1.4vw, 16px);
    bottom: clamp(14px, 2.4vh, 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(6px);
}

.nf-stage-wrap.is-hud-visible .nf-right-rail {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.nf-right-rail.is-locked {
    opacity: 0 !important;
    pointer-events: none !important;
}

.nf-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
}

.nf-rail-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ui-h);
    height: var(--ui-h);
    border-radius: 50%;
    background: rgba(0, 0, 0, .42);
    backdrop-filter: blur(8px);
    color: #fff;
    transition: transform .16s var(--ease-out), background-color .16s ease;
}

.nf-rail-item:hover .nf-rail-circle {
    background: rgba(255, 255, 255, .24);
    transform: scale(1.08);
}

.nf-rail-item:active .nf-rail-circle {
    transform: scale(.92);
}

.nf-rail-item.is-active .nf-rail-circle {
    background: var(--nf-red);
}

.nf-rail-love {
    color: #ff4769;
}

.nf-rail-love svg {
    fill: currentColor;
}

.nf-rail-circle.is-attention {
    background: var(--nf-red);
    animation: nf-pulse 1.1s ease-in-out infinite alternate;
}

.nf-rail-label {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, .92);
    text-shadow: 0 1px 4px rgba(0, 0, 0, .85);
}

/* Center Play Button when Paused */
.nf-center-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    width: 72px;
    height: 72px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(6px);
    color: rgba(255, 255, 255, .92);
    display: grid;
    place-items: center;
    transition: transform .18s var(--ease-out), background-color .16s ease;
}

.nf-center-play:hover {
    transform: translate(-50%, -50%) scale(1.08);
    background: rgba(255, 59, 48, .88);
}

.nf-center-play-svg {
    width: 36px;
    height: 36px;
    margin-left: 3px;
}

/* Loading, Error, Lock Shield */
.nf-overlay-state {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px;
    background: rgba(11, 11, 15, .74);
    backdrop-filter: blur(6px);
    text-align: center;
    font-size: 15px;
    font-weight: 700;
}

.nf-error-img {
    width: 96px;
    height: auto;
}

.nf-primary-btn {
    min-height: var(--ui-h);
    padding: 10px 24px;
    border: 0;
    border-radius: 999px;
    background: var(--nf-red);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}

.nf-lock-shield {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 24px;
}

.nf-unlock-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: var(--ui-h);
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 999px;
    background: rgba(0, 0, 0, .78);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
}

/* -------------------------------------------------------------------------- */
/* Audio & Subtitles Bottom Sheet                                             */
/* -------------------------------------------------------------------------- */

.nf-sheet-backdrop {
    position: absolute;
    inset: 0;
    z-index: 18;
    background: rgba(0, 0, 0, .46);
}

.nf-bottom-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    max-width: 560px;
    max-height: 82dvh;
    overflow-y: auto;
    margin: 0 auto;
    padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0;
    background: #18181c;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, .72);
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: nf-sheet-up .22s var(--ease-out);
}

@keyframes nf-sheet-up {
    from {
        transform: translateY(24px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.nf-sheet-handle {
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .22);
    margin: 0 auto 2px;
    flex: none;
}

.nf-sheet-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nf-sheet-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nf-sheet-heading {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, .92);
}

.nf-segmented {
    display: flex;
    padding: 3px;
    border-radius: 10px;
    background: var(--nf-surface-2);
    gap: 3px;
}

.nf-seg-btn {
    flex: 1;
    min-height: 38px;
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--nf-ink-soft);
    font-size: 13.5px;
    font-weight: 600;
    transition: background-color .15s ease, color .15s ease;
}

.nf-seg-btn.is-selected {
    background: var(--nf-surface-active);
    color: #fff;
    font-weight: 700;
}

.nf-switch {
    position: relative;
    width: 48px;
    height: 28px;
    padding: 2px;
    border: 0;
    border-radius: 999px;
    background: #3a3a42;
    transition: background-color .18s ease;
}

.nf-switch.is-on {
    background: var(--nf-red);
}

.nf-switch-knob {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
    transition: transform .18s var(--ease-out);
}

.nf-switch.is-on .nf-switch-knob {
    transform: translateX(20px);
}

.nf-sub-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nf-sub-list.is-disabled {
    opacity: .4;
    pointer-events: none;
}

.nf-sub-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--nf-ink-soft);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: background-color .14s ease, color .14s ease;
}

.nf-sub-row:hover {
    background: rgba(255, 255, 255, .06);
}

.nf-sub-row.is-selected {
    background: var(--nf-surface-2);
    color: #fff;
    font-weight: 700;
}

.nf-sub-check {
    width: 18px;
    height: 18px;
    color: var(--nf-red);
    opacity: 0;
    flex: none;
}

.nf-sub-row.is-selected .nf-sub-check {
    opacity: 1;
}

/* -------------------------------------------------------------------------- */
/* Floating Hearts                                                            */
/* -------------------------------------------------------------------------- */

.nf-stage-hearts {
    position: absolute;
    right: 64px;
    bottom: 24px;
    width: 110px;
    height: 240px;
    pointer-events: none;
    z-index: 13;
}

.nf-floating-heart {
    position: absolute;
    bottom: 0;
    color: #ff4769;
    line-height: 1;
    animation: nf-heart-float 1.6s cubic-bezier(.22, .61, .36, 1) forwards;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5));
}

.nf-heart-svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    stroke: currentColor;
}

@keyframes nf-heart-float {
    0% {
        opacity: 0;
        transform: translate3d(0, 8px, 0) scale(.5);
    }
    18% {
        opacity: 1;
        transform: translate3d(var(--sway, 0px), -34px, 0) scale(1.15);
    }
    100% {
        opacity: 0;
        transform: translate3d(var(--sway-end, 0px), -190px, 0) scale(.85);
    }
}

/* -------------------------------------------------------------------------- */
/* Portrait Mobile                                                            */
/* -------------------------------------------------------------------------- */

@media (max-width: 720px) and (orientation: portrait) {
    :root {
        --ui-h: 40px;
    }

    .nf-video:not(.is-fill) {
        object-position: 50% 20%;
    }

    .nf-hud-bottom {
        padding: 36px clamp(10px, 1.4vw, 16px) calc(16px + env(safe-area-inset-bottom, 0px)) clamp(10px, 1.4vw, 16px);
    }

    .nf-bottom-left-stack {
        max-width: none;
        width: 100%;
    }

    .nf-tiktok-feed,
    .nf-title-group {
        padding-right: 62px;
    }

    .nf-right-rail {
        gap: 10px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--ui-h) + 12px);
    }

    .nf-rail-label {
        font-size: 10px;
    }

    .nf-tiktok-feed {
        max-height: 130px;
    }

    .nf-center-play {
        width: 62px;
        height: 62px;
    }
}

/* -------------------------------------------------------------------------- */
/* Short Landscape Phone Adaptation (Prevents right-rail vs topbar collision) */
/* -------------------------------------------------------------------------- */

@media (max-height: 540px) and (orientation: landscape) {
    :root {
        --ui-h: 36px;
    }

    .icon-svg {
        width: 18px;
        height: 18px;
    }

    .nf-hud-top {
        padding: 10px 14px 22px;
    }

    .nf-hud-bottom {
        padding: 24px 240px 12px 14px;
    }

    .nf-bottom-left-stack {
        gap: 6px;
        max-width: 340px;
    }

    .nf-tiktok-feed {
        max-height: 84px;
    }

    .nf-right-rail {
        flex-direction: row;
        right: 14px;
        bottom: 12px;
        gap: 8px;
        transform: translateY(6px);
    }

    .nf-stage-wrap.is-hud-visible .nf-right-rail {
        transform: translateY(0);
    }

    .nf-rail-label {
        display: none;
    }

    .nf-stage-hearts {
        right: 140px;
        bottom: 52px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
