/* ==========================================================================
   章节页播放器（/book/ting/{id}）
   样式对齐 pageplay.vue：深色卡片、#ea2c58 主色、内联 SVG 图标。
   独立成文件是为了不污染全站样式，也方便以后被别的页面复用。
   ========================================================================== */

.tp-card {
    position: relative;   /* 弹出面板的定位基准 */
    max-width: 420px;
    margin: 0 auto 18px;
    padding: 22px 20px 14px;
    border-radius: 16px;
    background: #0e0e12;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .30), 0 2px 10px rgba(0, 0, 0, .22);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.tp-cover-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.tp-cover {
    display: block;
    width: 200px;
    height: 200px;
    border-radius: 10px;
    object-fit: cover;
    background: #1a1a20;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
}

.tp-info {
    text-align: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.tp-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    color: #fff;
    word-break: break-all;
}

.tp-sub {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: #8e8e93;
    word-break: break-all;
}

/* ---------- 进度 ---------- */
.tp-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 2px;
}

.tp-time {
    flex: 0 0 44px;
    font-size: 12px;
    line-height: 1;
    color: #8e8e93;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.tp-range {
    flex: 1 1 auto;
    min-width: 0;
    height: 3px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 2px;
    /* 已播部分用渐变填充，--tp-p 由 JS 在 timeupdate 里更新 */
    background: linear-gradient(to right,
        #ea2c58 0%, #ea2c58 var(--tp-p, 0%),
        #2a2a31 var(--tp-p, 0%), #2a2a31 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.tp-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #ea2c58;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(234, 44, 88, .18);
}

.tp-range::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: 0;
    border-radius: 50%;
    background: #ea2c58;
    cursor: pointer;
}

/* ---------- 控制按钮 ---------- */
.tp-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 20px 0 12px;
}

.tp-btn,
.tp-play {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    outline: none;
}

.tp-btn:disabled {
    opacity: .32;
    cursor: default;
}

.tp-play {
    position: relative;      /* 加载转圈的定位基准 */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ea2c58;
    box-shadow: 0 8px 22px rgba(234, 44, 88, .38);
    transition: transform .12s ease;
}

.tp-play:active {
    transform: scale(.96);
}

/* ---------- 图标（内联 SVG，避免额外请求 / 字体依赖） ---------- */
.tp-ico {
    display: block;
    width: 26px;
    height: 26px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.tp-play .tp-ico {
    width: 24px;
    height: 24px;
}

.tp-ico-prev {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 5v14' stroke='%23ffffff' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M19 5.6L9.6 12 19 18.4z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.tp-ico-next {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 5v14' stroke='%23ffffff' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M5 5.6L14.4 12 5 18.4z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.tp-ico-back15 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='13.2' r='7.3' fill='none' stroke='%23ffffff' stroke-width='1.5'/%3E%3Cpath d='M8.6 3.2L6.2 5.6l2.4 2.4' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ctext x='12' y='16.2' font-size='7' font-weight='700' fill='%23ffffff' text-anchor='middle' font-family='Arial,Helvetica,sans-serif'%3E15%3C/text%3E%3C/svg%3E");
}

.tp-ico-fwd15 {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='13.2' r='7.3' fill='none' stroke='%23ffffff' stroke-width='1.5'/%3E%3Cpath d='M15.4 3.2L17.8 5.6l-2.4 2.4' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ctext x='12' y='16.2' font-size='7' font-weight='700' fill='%23ffffff' text-anchor='middle' font-family='Arial,Helvetica,sans-serif'%3E15%3C/text%3E%3C/svg%3E");
}

.tp-ico-play {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.4 5.4L19 12 8.4 18.6z' fill='%23ffffff'/%3E%3C/svg%3E");
}

.tp-ico-pause {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='7.6' y='5' width='3.6' height='14' rx='1.2' fill='%23ffffff'/%3E%3Crect x='12.8' y='5' width='3.6' height='14' rx='1.2' fill='%23ffffff'/%3E%3C/svg%3E");
}

/* ---------- 工具栏 ---------- */
.tp-tools {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
}

/* 提示单独一行，避免和三个按钮挤在一起 */
.tp-hint-row {
    min-height: 16px;
    margin-top: 8px;
    text-align: center;
}

.tp-tool {
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 14px;
    background: rgba(255, 255, 255, .04);
    color: #d9d9de;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    outline: none;
}

.tp-tool:hover {
    background: rgba(255, 255, 255, .08);
}

.tp-hint {
    min-height: 14px;
    font-size: 12px;
    line-height: 1;
    color: #ea2c58;
}

/* ---------- 无音频可播时的占位 ---------- */
.tp-empty {
    max-width: 420px;
    margin: 0 auto;
    padding: 26px 20px;
    border-radius: 14px;
    background: #f6f6f8;
    color: #8a8a90;
    font-size: 14px;
    text-align: center;
}

@media (max-width: 767px) {
    .tp-card {
        max-width: none;
        margin-bottom: 14px;
        padding: 18px 16px 12px;
    }

    .tp-cover {
        width: 160px;
        height: 160px;
    }
}

/* ==========================================================================
   弹出面板（倍速 / 定时 / 片头片尾 共用）
   定位在卡片内部，不遮挡整页，视觉上也更像"播放器的一部分"
   ========================================================================== */

.tp-sheet {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: flex-end;
    border-radius: 16px;
    overflow: hidden;
}

/* hidden 属性要显式处理，否则会被上面的 display:flex 覆盖掉 */
.tp-sheet[hidden] {
    display: none;
}

.tp-sheet-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, .55);
}

.tp-sheet-panel {
    position: relative;
    width: 100%;
    padding: 16px 18px 14px;
    background: #17171c;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .45);
}

.tp-sheet-title {
    margin-bottom: 12px;
    font-size: 13px;
    color: #8e8e93;
    text-align: center;
}

.tp-sheet-opts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.tp-opt {
    min-width: 64px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    color: #e6e6ea;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    outline: none;
}

.tp-opt:hover {
    background: rgba(255, 255, 255, .08);
}

.tp-opt.is-active {
    border-color: #ea2c58;
    background: rgba(234, 44, 88, .12);
    color: #ea2c58;
}

.tp-sheet-cancel {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 9px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    color: #b9b9c0;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

/* 片头 / 片尾输入行 */
.tp-skip-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.tp-skip-row label {
    font-size: 13px;
    color: #b9b9c0;
}

.tp-num {
    width: 64px;
    padding: 7px 8px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 8px;
    background: #0e0e12;
    color: #fff;
    font-size: 13px;
    text-align: center;
    outline: none;
}

.tp-sheet-save {
    display: block;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: #ea2c58;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

/* ==========================================================================
   全屏模式
   --------------------------------------------------------------------------
   两条腿走路：
   1) CSS 遮罩铺满视口（position:fixed）—— 所有浏览器都能用
   2) 尽量再调 requestFullscreen() —— 手机上进全屏能隐藏浏览器地址栏
   iOS Safari 不支持对普通元素调全屏，所以真正兜底的是第 1 条。
   ========================================================================== */

.tp-card.is-full {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;

    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 32px 22px calc(20px + env(safe-area-inset-bottom, 0px));
    /* overflow-y:auto 会连带把 overflow-x 也算成 auto，内部只要有一像素超宽
       就会在全屏底部冒出横向滚动条 —— 显式收掉 */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 内部元素在大屏上不要拉得太宽 */
.tp-card.is-full > * {
    width: 100%;
    max-width: 520px;
}

/* 封面在竖屏手机上按宽度取，桌面端封顶 260px */
.tp-card.is-full .tp-cover-wrap {
    margin-bottom: 26px;
}

.tp-card.is-full .tp-cover {
    width: min(56vw, 260px);
    height: min(56vw, 260px);
    border-radius: 14px;
}

.tp-card.is-full .tp-title {
    font-size: 19px;
}

.tp-card.is-full .tp-sub {
    font-size: 13px;
}

.tp-card.is-full .tp-progress {
    margin-top: 6px;
}

.tp-card.is-full .tp-controls {
    gap: 26px;
    margin: 30px 0 18px;
}

.tp-card.is-full .tp-play {
    width: 68px;
    height: 68px;
    box-shadow: 0 10px 28px rgba(234, 44, 88, .42);
}

.tp-card.is-full .tp-play .tp-ico {
    width: 28px;
    height: 28px;
}

.tp-card.is-full .tp-ico {
    width: 30px;
    height: 30px;
}

.tp-card.is-full .tp-tool {
    padding: 7px 14px;
    font-size: 13px;
}

/* 弹层在宽屏下居中收窄，否则底部面板会铺满整条边 */
.tp-card.is-full .tp-sheet-panel {
    max-width: 520px;
    margin: 0 auto;
}

/* 全屏时页面本身不许滚（JS 里也会设 body overflow，这里再兜一层） */
body.tp-full-lock {
    overflow: hidden;
}

/* 横屏手机：把封面缩掉，避免内容顶出去 */
@media (orientation: landscape) and (max-height: 480px) {
    .tp-card.is-full {
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .tp-card.is-full .tp-cover-wrap {
        display: none;
    }

    .tp-card.is-full .tp-controls {
        margin: 14px 0 10px;
    }
}

/* ==========================================================================
   加载中：播放按钮上的转圈
   --------------------------------------------------------------------------
   覆盖两个阶段：① 正在取音频地址（fetch）② 已设置 src、等音频服务器吐首块
   第二个阶段往往是最大的等待（实测首包 150~640ms），没有提示就是"点了没反应"。
   ========================================================================== */

.tp-play.is-loading .tp-ico {
    opacity: 0;
}

.tp-play.is-loading::after {
    content: '';
    position: absolute;
    /* inset:0 + margin:auto 是唯一不受 box-sizing 影响的居中方式
       （不能用 translate(-50%,-50%)，会和旋转动画的 transform 打架） */
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tp-spin .7s linear infinite;
}

@keyframes tp-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 系统开了"减少动态效果"时放慢，别让人难受 */
@media (prefers-reduced-motion: reduce) {
    .tp-play.is-loading::after {
        animation-duration: 1.8s;
    }
}
