/* =====================================================
   보라해 TTS Player — player.css
   サイトのデザイン変数に合わせて上書き可能
   ===================================================== */

/* ── 単体ラップ ── */
.btts-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(201, 168, 232, 0.14);
    border-radius: 16px;
    padding: 16px 18px;
    margin: 12px 0;
    transition: border-color 0.25s, background 0.25s;
    position: relative;
    overflow: hidden;
}

.btts-wrap::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(201,168,232,0.25), transparent);
}

.btts-wrap:hover {
    border-color: rgba(201, 168, 232, 0.3);
    background: rgba(201, 168, 232, 0.05);
}

/* ── テキスト ── */
.btts-texts {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.btts-kr {
    font-size: 1.15em;
    font-weight: 600;
    color: #fdfaff;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.btts-jp {
    font-size: 0.8em;
    color: rgba(201, 168, 232, 0.65);
    line-height: 1.4;
}

/* ── スピーカーバッジ（会話用）── */
.btts-speaker {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1;
}

.btts-speaker-a {
    background: rgba(155, 111, 208, 0.2);
    border: 1px solid rgba(155, 111, 208, 0.4);
    color: #c9a8e8;
}

.btts-speaker-b {
    background: rgba(255, 215, 0, 0.12);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
}

/* ── コントロール（再生ボタン＋速度） ── */
.btts-controls {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── 再生ボタン ── */
.btts-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(155, 111, 208, 0.5), rgba(201, 168, 232, 0.35));
    border: 1.5px solid rgba(201, 168, 232, 0.55);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(155, 111, 208, 0.2);
}

.btts-btn:hover {
    background: linear-gradient(135deg, rgba(155, 111, 208, 0.5), rgba(201, 168, 232, 0.35));
    border-color: rgba(201, 168, 232, 0.7);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(155, 111, 208, 0.35);
}

/* 再生中 */
.btts-btn.is-playing {
    background: linear-gradient(135deg, rgba(155, 111, 208, 0.5), rgba(201, 168, 232, 0.35));
    border-color: rgba(155, 111, 208, 0.7);
    color: #fff;
    animation: btts-ring 1s ease-in-out infinite;
}

@keyframes btts-ring {
    0%, 100% { box-shadow: 0 2px 8px rgba(155, 111, 208, 0.3); }
    50%       { box-shadow: 0 0 0 8px rgba(155, 111, 208, 0), 0 2px 8px rgba(155, 111, 208, 0.3); }
}

/* ローディング */
.btts-btn.is-loading .btts-btn-icon {
    animation: btts-spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes btts-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── 速度ボタン ── */
.btts-speed {
    flex-shrink: 0;
    min-width: 36px;
    height: 26px;
    border-radius: 13px;
    background: rgba(201, 168, 232, 0.08);
    border: 1px solid rgba(201, 168, 232, 0.18);
    color: rgba(201, 168, 232, 0.6);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 8px;
    transition: all 0.2s;
    line-height: 1;
    letter-spacing: -0.02em;
}

.btts-speed:hover {
    background: rgba(201, 168, 232, 0.15);
    border-color: rgba(201, 168, 232, 0.4);
    color: #fdfaff;
}

.btts-speed.is-slow {
    background: rgba(100, 200, 255, 0.12);
    border-color: rgba(100, 200, 255, 0.3);
    color: rgba(100, 200, 255, 0.85);
}

/* ── グループ（会話形式）── */
.btts-group {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(201, 168, 232, 0.12);
    border-radius: 20px;
    padding: 16px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* ── グループ再生ボタン ── */
.btts-group-play {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    margin-bottom: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    background: rgba(155, 111, 208, 0.12);
    border: 1px solid rgba(201, 168, 232, 0.25);
    color: rgba(201, 168, 232, 0.75);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.btts-group-play:hover {
    background: rgba(155, 111, 208, 0.22);
    border-color: rgba(201, 168, 232, 0.45);
    color: #e0d0f0;
}

.btts-group-play.is-playing {
    background: rgba(155, 111, 208, 0.25);
    border-color: rgba(155, 111, 208, 0.5);
    color: #e0d0f0;
}

.btts-group-play.is-loading .btts-group-play-icon {
    animation: btts-spin 0.8s linear infinite;
    display: inline-block;
}

.btts-group-play-icon {
    font-size: 10px;
}

/* ── グループ再生中のアクティブアイテム ── */
.btts-active {
    border-color: rgba(201, 168, 232, 0.4) !important;
    background: rgba(155, 111, 208, 0.1) !important;
}

.btts-group .btts-wrap {
    margin: 0;
    border-radius: 12px;
    border-color: rgba(201, 168, 232, 0.09);
    background: transparent;
}

/* スピーカーBは右寄せ */
.btts-group .btts-wrap:has(.btts-speaker-b) {
    flex-direction: row-reverse;
}

.btts-group .btts-wrap:has(.btts-speaker-b) .btts-texts {
    align-items: flex-end;
    text-align: right;
}

/* ── エラートースト ── */
.btts-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #f87171;
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.btts-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── ライトモード対応 ── */
body.light-mode .btts-wrap {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(139, 90, 191, 0.15);
}

body.light-mode .btts-wrap:hover {
    border-color: rgba(139, 90, 191, 0.35);
    background: white;
}

body.light-mode .btts-kr { color: #1e0a3c; }
body.light-mode .btts-jp { color: rgba(91, 45, 158, 0.55); }

body.light-mode .btts-btn {
    background: linear-gradient(135deg, rgba(139, 90, 191, 0.18), rgba(139, 90, 191, 0.08));
    border-color: rgba(139, 90, 191, 0.3);
    color: rgba(91, 45, 158, 0.85);
    box-shadow: 0 2px 8px rgba(139, 90, 191, 0.1);
}

body.light-mode .btts-btn:hover {
    background: linear-gradient(135deg, rgba(139, 90, 191, 0.3), rgba(139, 90, 191, 0.15));
    color: #1e0a3c;
    box-shadow: 0 4px 16px rgba(139, 90, 191, 0.2);
}

body.light-mode .btts-speed {
    background: rgba(139, 90, 191, 0.06);
    border-color: rgba(139, 90, 191, 0.18);
    color: rgba(91, 45, 158, 0.55);
}

body.light-mode .btts-speed:hover {
    background: rgba(139, 90, 191, 0.12);
    color: #1e0a3c;
}

body.light-mode .btts-speed.is-slow {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
    color: rgba(59, 130, 246, 0.8);
}

body.light-mode .btts-group {
    background: rgba(139, 90, 191, 0.03);
    border-color: rgba(139, 90, 191, 0.12);
}

body.light-mode .btts-group-play {
    background: rgba(139, 90, 191, 0.08);
    border-color: rgba(139, 90, 191, 0.2);
    color: rgba(91, 45, 158, 0.65);
}

body.light-mode .btts-group-play:hover {
    background: rgba(139, 90, 191, 0.15);
    border-color: rgba(139, 90, 191, 0.35);
    color: #5b2d9e;
}

body.light-mode .btts-group-play.is-playing {
    background: rgba(139, 90, 191, 0.18);
    border-color: rgba(139, 90, 191, 0.4);
    color: #5b2d9e;
}

body.light-mode .btts-active {
    border-color: rgba(139, 90, 191, 0.35) !important;
    background: rgba(139, 90, 191, 0.06) !important;
}

/* ── レスポンシブ ── */
@media (max-width: 480px) {
    .btts-kr { font-size: 1em; }
    .btts-btn { width: 36px; height: 36px; font-size: 12px; }
    .btts-speed { min-width: 32px; height: 24px; font-size: 10px; }
}
