/**
 * 弾幕コメント機能スタイル
 */

/* ============================================
   1. 画像ラッパーとオーバーレイ
============================================ */
.danmaku-image-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    overflow: visible;
}

.danmaku-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   2. 流れるコメント
============================================ */
.danmaku-comment {
    position: absolute;
    white-space: nowrap;
    font-weight: bold;
    font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    animation: danmaku-flow 8s linear forwards;
    left: -100%;
    transform: translateX(-100%);
}

@keyframes danmaku-flow {
    0% {
        left: -10%;
        transform: translateX(-100%);
    }
    100% {
        left: 110%;
        transform: translateX(0%);
    }
}

/* ============================================
   3. 固定位置のコメント矢印（PC専用）
============================================ */
.danmaku-comment-arrow {
    position: fixed;
    top: 70vh;
    right: 310px; /* 追尾フォームの左側に表示 */
    z-index: 998;
    display: flex;
    align-items: center;
    transform: translateY(-50%);
    pointer-events: none;
}

.danmaku-comment-arrow-pointer {
    font-size: 28px;
    color: var(--primary, #f09bc3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: arrow-pulse 1.5s ease-in-out infinite;
}

@keyframes arrow-pulse {
    0%, 100% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(5px);
        opacity: 0.7;
    }
}

/* ============================================
   4. 右側追尾フォーム
============================================ */
.danmaku-floating-form {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 280px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 999;
    overflow: hidden;
    transition: all 0.3s ease;
}

.danmaku-floating-form.minimized {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.danmaku-floating-form.minimized .danmaku-floating-body {
    display: none;
}

.danmaku-floating-form.minimized .danmaku-floating-header {
    padding: 12px;
    justify-content: center;
}

.danmaku-floating-form.minimized .danmaku-floating-title {
    display: none;
}

.danmaku-floating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--primary, #f09bc3);
    color: #fff;
}

.danmaku-floating-title {
    font-size: 14px;
    font-weight: bold;
}

.danmaku-floating-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.danmaku-floating-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

.danmaku-floating-body {
    padding: 15px;
}

.danmaku-floating-current {
    background: rgba(240, 155, 195, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    text-align: center;
}

#danmaku-current-image-display {
    font-size: 14px;
    font-weight: bold;
    color: var(--primary, #f09bc3);
}

.danmaku-floating-field {
    margin-bottom: 12px;
}

.danmaku-floating-field:last-of-type {
    margin-bottom: 15px;
}

.danmaku-floating-field label {
    display: block;
    font-size: 11px;
    font-weight: bold;
    color: #666;
    margin-bottom: 4px;
}

.danmaku-floating-field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

.danmaku-floating-field input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.danmaku-floating-field input[type="text"]:focus {
    outline: none;
    border-color: var(--primary, #f09bc3);
}

.danmaku-floating-colors {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.danmaku-floating-sizes {
    display: flex;
    gap: 4px;
}

.danmaku-floating-sizes .danmaku-size-btn {
    flex: 1;
    text-align: center;
}

/* Y位置ヒント表示 */
.danmaku-y-hint {
    background: rgba(240, 155, 195, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--primary, #f09bc3);
}

.danmaku-y-hint-text {
    font-size: 12px;
    color: var(--primary, #f09bc3);
    font-weight: bold;
}

.danmaku-floating-submit {
    width: 100%;
    padding: 12px;
    background: var(--primary, #f09bc3);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.danmaku-floating-submit:hover {
    background: var(--primary-hover, #e85a9c);
}

.danmaku-floating-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.danmaku-floating-status {
    margin-top: 10px;
    font-size: 12px;
    text-align: center;
    color: #28a745;
    min-height: 18px;
}

.danmaku-floating-status.error {
    color: #dc3545;
}

/* ============================================
   5. コメントフォーム弾幕オプション
============================================ */
.danmaku-options {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.danmaku-options-header {
    margin-bottom: 12px;
}

.danmaku-options-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.danmaku-options-row {
    margin-bottom: 12px;
}

.danmaku-options-row:last-child {
    margin-bottom: 0;
}

/* チェックボックスラベル */
.danmaku-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.danmaku-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    accent-color: var(--primary, #f09bc3);
}

.danmaku-checkbox-text {
    font-size: 14px;
    color: #555;
}

/* サブオプション */
.danmaku-sub-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.danmaku-option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.danmaku-option-group label {
    font-size: 12px;
    font-weight: bold;
    color: #666;
}

.danmaku-option-group select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    min-width: 100px;
}

.danmaku-current-image {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* カラーピッカー */
.danmaku-color-picker {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.danmaku-color-btn {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}

.danmaku-color-btn:hover {
    transform: scale(1.15);
}

.danmaku-color-btn.active {
    border-color: var(--primary, #f09bc3);
    box-shadow: 0 0 0 2px rgba(240, 155, 195, 0.3);
}

/* サイズピッカー */
.danmaku-size-picker {
    display: flex;
    gap: 4px;
}

.danmaku-size-btn {
    padding: 4px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}

.danmaku-size-btn:hover {
    background: #f0f0f0;
}

.danmaku-size-btn.active {
    background: var(--primary, #f09bc3);
    color: #fff;
    border-color: var(--primary, #f09bc3);
}

/* ============================================
   6. 弾幕ON/OFFトグル
============================================ */
.danmaku-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.danmaku-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--primary, #f09bc3);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.danmaku-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.danmaku-toggle-btn:active {
    transform: translateY(0);
}

.danmaku-toggle.disabled .danmaku-toggle-btn {
    background: #888;
}

.danmaku-toggle-icon {
    font-size: 16px;
}

.danmaku-toggle-status {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-size: 11px;
}

/* ============================================
   7. コメント一覧での弾幕情報表示
============================================ */
.comment-danmaku-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(240, 155, 195, 0.1);
    border-radius: 4px;
    font-size: 11px;
    color: #888;
    flex-wrap: wrap;
}

.comment-danmaku-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--primary, #f09bc3);
    color: #fff;
    border-radius: 3px;
    font-size: 10px;
}

.comment-danmaku-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #ddd;
}

.comment-danmaku-replay {
    display: inline-block;
    padding: 2px 8px;
    background: #e0e0e0;
    color: #666;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.comment-danmaku-replay:hover {
    background: #d0d0d0;
}

.comment-danmaku-page {
    display: inline-block;
    padding: 2px 8px;
    background: #f0f0f0;
    color: #666;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
}

/* ============================================
   8. スマホ用コメント一覧パネル
============================================ */
.danmaku-mobile-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60vh;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 20px 20px 0 0;
    z-index: 10001;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.danmaku-mobile-panel.open {
    transform: translateY(0);
}

.danmaku-mobile-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.danmaku-mobile-panel-title {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
}

.danmaku-mobile-panel-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.danmaku-mobile-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.danmaku-mobile-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    -webkit-overflow-scrolling: touch;
}

.danmaku-mobile-panel-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 40px 20px;
    font-size: 14px;
}

.danmaku-mobile-comment {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    transition: background 0.3s;
}

.danmaku-mobile-comment.new-comment {
    background: rgba(240, 155, 195, 0.3);
}

.danmaku-mobile-comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.danmaku-mobile-comment-page {
    font-size: 11px;
    font-weight: bold;
    color: var(--primary, #f09bc3);
    background: rgba(240, 155, 195, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
}

.danmaku-mobile-comment-date {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.danmaku-mobile-comment-body {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.danmaku-mobile-comment-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.danmaku-mobile-comment-text {
    font-size: 14px;
    color: #fff;
    line-height: 1.5;
    word-break: break-word;
}

.danmaku-mobile-comment-author {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-align: right;
}

.danmaku-mobile-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.danmaku-mobile-panel-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* パネルが開いているときにbodyのスクロールを無効化 */
body.danmaku-panel-open {
    overflow: hidden;
}

/* ============================================
   9. レスポンシブ対応
============================================ */
@media (max-width: 768px) {
    /* スマホでは弾幕を流さない */
    .danmaku-overlay {
        display: none !important;
    }

    /* コメント矢印もスマホでは非表示 */
    .danmaku-comment-arrow {
        display: none !important;
    }

    /* 追尾フォームをモバイル用に調整 */
    .danmaku-floating-form {
        position: fixed;
        top: auto;
        bottom: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        transform: none;
        max-height: 60vh;
        overflow-y: auto;
    }

    .danmaku-floating-form.minimized {
        left: auto;
        width: 50px;
        height: 50px;
    }

    .danmaku-options {
        padding: 12px;
    }

    .danmaku-sub-options {
        flex-direction: column;
        gap: 12px;
    }

    .danmaku-option-group {
        width: 100%;
    }

    .danmaku-option-group select {
        width: 100%;
    }

    .danmaku-color-picker {
        justify-content: flex-start;
    }

    .danmaku-size-picker {
        width: 100%;
    }

    .danmaku-size-btn {
        flex: 1;
        text-align: center;
    }

    /* モバイルでは弾幕トグルを小さく */
    .danmaku-toggle {
        bottom: 15px;
        right: 15px;
    }

    .danmaku-toggle-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .danmaku-toggle-text {
        display: none;
    }

    /* コメント一覧のページ情報 */
    .comment-danmaku-info {
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Y位置ヒントはスマホでは非表示 */
    .danmaku-y-hint {
        display: none;
    }
}

/* ============================================
   10. 弾幕コメントのアクセシビリティ
============================================ */
@media (prefers-reduced-motion: reduce) {
    .danmaku-comment {
        animation: none;
        display: none;
    }

    .danmaku-toggle {
        display: none;
    }

    .danmaku-floating-form {
        display: none;
    }

    .danmaku-comment-arrow {
        display: none;
    }
}
