/* ==========================================================================
   ArtBili 播放器 · 皮肤
   B 站风格：深色底 + 粉色高亮，直角改圆角，弱化边框
   ========================================================================== */

:root {
    --bg: #0b0b10;
    --bg-soft: #121219;
    --panel: #191922;
    --line: rgba(255, 255, 255, 0.08);
    --text: #ececf3;
    --text-dim: #9a9aab;
    --accent: #fb7299;
    --accent-2: #ff9db8;
    --radius: 12px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    text-rendering: optimizeLegibility;
}

/* --------------------------------------------------------------------------
   播放器布局
   -------------------------------------------------------------------------- */

.app,
.stage {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
}

.app {
    overflow: hidden;
}

.stage {
    overflow: hidden;
    background: #000;
    /* 建立独立层叠上下文，避免 ArtPlayer 内部的 z-index:20 盖住加载层/标题栏 */
    isolation: isolate;
}

.player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

body.is-player {
    background: #000;
}

/* --------------------------------------------------------------------------
   顶部标题条（悬浮，不占播放区域）
   -------------------------------------------------------------------------- */

.topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px 40px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.topbar.is-hidden {
    opacity: 0;
    transform: translateY(-8px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 4px 14px rgba(251, 114, 153, 0.35);
}

.brand-logo {
    height: 24px;
    width: auto;
    display: block;
}

.video-title {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}

/* --------------------------------------------------------------------------
   加载态
   -------------------------------------------------------------------------- */

.loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 24px;
    text-align: center;
    background:
        radial-gradient(60% 60% at 50% 45%, rgba(251, 114, 153, 0.12), transparent 70%),
        radial-gradient(100% 100% at 50% 0%, #15151d 0%, #0a0a0e 70%);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.loading.is-gone {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    animation: ab-spin 0.85s linear infinite;
    margin-bottom: 16px;
}

.loader::after {
    content: "";
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 114, 153, 0.18), transparent 65%);
    animation: ab-pulse 1.8s ease-in-out infinite;
}

@keyframes ab-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ab-pulse {
    0%,
    100% {
        opacity: 0.45;
        transform: scale(0.9);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.05);
    }
}

.loading-text {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

.loading-hint {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-dim);
}

/* 等待动画：转圈之外再加一条来回流动的进度条 */
.loading-bar {
    position: relative;
    width: 180px;
    height: 3px;
    margin-top: 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.loading-bar i {
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    animation: ab-bar 1.15s ease-in-out infinite;
}

@keyframes ab-bar {
    0% {
        left: -40%;
    }
    100% {
        left: 100%;
    }
}

/* --------------------------------------------------------------------------
   失败态
   -------------------------------------------------------------------------- */

.fail {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 8, 12, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.fail[hidden] {
    display: none;
}

.fail-card {
    width: min(420px, 100%);
    padding: 32px 28px 26px;
    border-radius: 18px;
    text-align: center;
    background: linear-gradient(180deg, rgba(30, 30, 40, 0.96), rgba(20, 20, 28, 0.96));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.fail-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 14px;
    border-radius: 50%;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #ff5f7e, #ff8a5c);
    box-shadow: 0 8px 24px rgba(255, 95, 126, 0.35);
}

.fail-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
}

.fail-msg {
    margin: 0 0 22px;
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--text-dim);
    word-break: break-word;
}

.fail-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */

.btn {
    appearance: none;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 22px;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 10px 26px rgba(251, 114, 153, 0.32);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #fc85a6, #ffb0c6);
    box-shadow: 0 12px 30px rgba(251, 114, 153, 0.42);
}

/* --------------------------------------------------------------------------
   暂停广告
   -------------------------------------------------------------------------- */

.pause-ad {
    position: absolute;
    left: 50%;
    bottom: 96px;
    z-index: 4;
    transform: translateX(-50%);
    width: min(480px, 78vw);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.pause-ad[hidden] {
    display: none;
}

.pause-ad a {
    display: block;
    line-height: 0;
}

.pause-ad img {
    display: block;
    width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   首页（无 url 时）
   -------------------------------------------------------------------------- */

body.is-home {
    overflow: auto;
}

.home {
    position: relative;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.home-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(50% 45% at 18% 12%, rgba(251, 114, 153, 0.16), transparent 70%),
        radial-gradient(45% 40% at 85% 80%, rgba(92, 141, 255, 0.14), transparent 70%),
        linear-gradient(180deg, #101017, #08080c 60%);
}

.home-card {
    width: min(680px, 100%);
    padding: clamp(26px, 5vw, 46px);
    border-radius: 22px;
    background: rgba(23, 23, 31, 0.72);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.home-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 22px;
}

.brand-mark-lg {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.home-logo {
    height: 34px;
    width: auto;
}

.home-card h1 {
    margin: 0 0 8px;
    font-size: clamp(22px, 3.4vw, 28px);
    font-weight: 700;
    letter-spacing: 0.2px;
}

.home-desc {
    margin: 0 0 26px;
    font-size: 13.5px;
    color: var(--text-dim);
    line-height: 1.7;
}

.home-error {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    color: #ffb4c8;
    background: rgba(255, 95, 126, 0.12);
    border: 1px solid rgba(255, 95, 126, 0.28);
}

.home-form {
    display: flex;
    gap: 10px;
}

.home-form input {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.home-form input::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

.home-form input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 3px rgba(251, 114, 153, 0.16);
}

.home-form .btn {
    height: 48px;
    padding: 0 28px;
    border-radius: 12px;
}

.home-tip {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-dim);
}

.home-tip p {
    margin: 0 0 8px;
}

.home-tip code {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    color: #b9b9c9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.6;
    word-break: break-all;
    user-select: all;
}


/* --------------------------------------------------------------------------
   静音自动播放时的「开启声音」提示
   -------------------------------------------------------------------------- */

.sound-hint {
    position: absolute;
    left: 50%;
    bottom: 88px;
    z-index: 30;
    transform: translateX(-50%);
    /* 按要求停用「点击播放（带声音）」提示：不再显示 */
    display: none !important;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: 0;
    border-radius: 999px;
    background: rgba(251, 114, 153, 0.94);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    animation: ab-hint-float 2.6s ease-in-out infinite;
}

.sound-hint[hidden] {
    display: none;
}

.sound-hint:hover {
    background: #ff8fae;
}

.sound-hint svg {
    flex: 0 0 auto;
}

/* ArtPlayer / DPlayer 内部对子元素有 padding 重置，这里提高优先级 */
.art-video-player .sound-hint,
.dplayer .sound-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 13px;
    line-height: 1;
    min-height: 34px;
}

.art-video-player .sound-hint[hidden],
.dplayer .sound-hint[hidden],
.sound-hint[hidden] {
    display: none !important;
}

@keyframes ab-hint-float {
    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-3px);
    }
}

@media (max-width: 640px) {
    .sound-hint {
        bottom: 96px;
        font-size: 13px;
        padding: 10px 16px;
    }

    .art-video-player .sound-hint,
    .dplayer .sound-hint {
        bottom: 96px;
        padding: 10px 16px;
    }
}

/* 竖屏时：标题栏在上，视频按 16:9 显示，避免大片黑边和控制栏贴屏幕底部 */
@media (max-width: 820px) and (orientation: portrait) {
    body.is-player .app {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    body.is-player .topbar {
        position: static;
        flex: 0 0 auto;
        padding: 12px 14px;
        background: #0c0c12;
        border-bottom: 1px solid var(--line);
        opacity: 1;
        transform: none;
    }

    body.is-player .topbar.is-hidden {
        opacity: 1;
        transform: none;
    }

    body.is-player .stage {
        height: auto;
        width: 100%;
        aspect-ratio: 16 / 9;
        flex: 0 0 auto;
        max-height: none;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 10px 12px 30px;
        gap: 10px;
    }

    .brand-name {
        display: none;
    }

    .video-title {
        font-size: 13px;
    }

    .home-form {
        flex-direction: column;
    }

    .home-form .btn {
        width: 100%;
    }

    .fail-card {
        padding: 26px 20px 22px;
    }

    .pause-ad {
        bottom: 78px;
        width: 86vw;
    }
}

@media (max-height: 460px) and (orientation: landscape) {
    .topbar {
        padding: 8px 14px 24px;
    }

    .video-title {
        font-size: 12.5px;
    }
}

/* 尊重系统「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
    .loader,
    .loader::after {
        animation: none;
    }

    .sound-hint {
        animation: none;
    }

    .loading-bar i {
        animation: none;
        left: 30%;
    }

    .btn,
    .topbar,
    .loading {
        transition: none;
    }
}
