/* Story Intro Page Styles */
body {
    background: var(--intro-bg);
}

.story-intro-page {
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 60px;
    padding: 10px;
    background-color: #1d1d27;
}

/* 스토리 헤더 */
.story-header {
    position: relative;
    padding: 40px 24px;
    margin-bottom: 40px;
    border-radius: 0 0 24px 24px;
    overflow: hidden;
    z-index: 1;
}

.header-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
}

.header-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(20px);
    opacity: 0.3;
    transform: scale(1.1);
}

.header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(15, 15, 23, 0.7) 0%, rgba(15, 15, 23, 0.95) 100%);
}

.header-content {
    position: relative;
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.header-left {
    flex-shrink: 0;
}

.cover-image {
    width: 250px;
    height: 350px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    
}

.cover-image img,
.cover-image video {
    width: 100%;
    height: 100%;
    object-fit: cover;   /* 핵심 */
    display: block;
}
.cover-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--intro-card) 0%, #2a2a3a 100%);
    font-size: 4rem;
    
}

.header-right {
    flex: 1;
    padding-top: 8px;
}

.story-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--intro-text);
    margin: 0 0 16px;
    line-height: 1.3;
}

.story-author {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        var(--intro-primary) 0%,
        var(--intro-accent) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden; /* 핵심 */
}

/* 이미지가 있을 때 */
.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 비율 유지 + 꽉 채우기 */
    border-radius: 50%;
    display: block;
}



.author-name {
    color: var(--intro-text-muted);
    font-size: 0.95rem;
}

.story-desc {
    font-size: 1rem;
    color: var(--intro-text);
    line-height: 1.6;
    margin: 0 0 20px;
    opacity: 0.9;
    margin-top: 10px;
}

.story-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--intro-text-muted);
}

.stat-icon {
    font-size: 1rem;
}

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--intro-card);
    border: 2px solid var(--intro-border);
    border-radius: 12px;
    color: var(--intro-text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.like-btn:hover {
    border-color: var(--intro-danger);
    background: rgba(239, 68, 68, 0.1);
}

.like-btn.liked {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--intro-danger);
    color: var(--intro-danger);
}

.like-icon {
    font-size: 1.2rem;
}

/* 콘텐츠 래퍼 */
.content-wrapper {
    padding: 0 24px;
}

/* 섹션 */
.section {
    margin-bottom: 48px;
}

.section-header {
    margin-bottom: 24px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--intro-text);
    margin: 0;
}

.title-icon {
    font-size: 1.5rem;
}

.comment-count {
    font-size: 0.9rem;
    color: var(--intro-text-muted);
    font-weight: 400;
}
.desc_img {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 48px 0;
}

.story-desc-image {
    width: 100%;
    max-width: 1000px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

.story-desc-image img {
    width: 100%;
    height: auto;
    display: block;
}



/* 캐릭터 그리드 - 모바일 스타일 카드 */
.character-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.character-card-link {
    text-decoration: none;
    color: inherit;
}

.character-card {
    background: var(--intro-card);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--intro-border);
    transition: all 0.3s;
}

.character-card:hover {
    transform: translateY(-6px);
    border-color: var(--intro-primary);
    box-shadow: 0 16px 35px rgba(99, 102, 241, 0.25);
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a25 0%, #2a2a3a 100%);
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.character-card:hover .card-image-wrapper img {
    transform: scale(1.05);
}

.card-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    opacity: 0.5;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 50px 14px 14px;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 50%, transparent 100%);
}

.card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 6px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.card-desc {
    font-size: 0.5rem;
    color: rgba(255,255,255,0.8);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    padding: 12px 14px;
    background: var(--intro-card);
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.card-tag {
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(167, 139, 250, 0.25) 100%);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--intro-accent);
}

.card-actions {
    display: flex;
    justify-content: flex-end;
}

.card-chat-btn {
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--intro-primary) 0%, #818cf8 100%);
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s;
}

.character-card:hover .card-chat-btn {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.card-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a25 0%, #2a2a3a 100%);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.character-card:hover .card-image img {
    transform: scale(1.08);
}

.image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    opacity: 0.5;
}

.card-body {
    padding: 20px;
}

.card-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--intro-text);
    margin: 0 0 8px;
}

.card-desc {
    font-size: 0.7rem;
    color: var(--intro-text-muted);
    line-height: 1.5;
    margin: 0 0 12px;
}

.card-quote {
    padding: 12px;
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--intro-primary);
    border-radius: 0 8px 8px 0;
    color: var(--intro-accent);
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.5;
}

.card-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--intro-border);
}

.action-btn {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.action-btn.chat-btn {
    background: linear-gradient(135deg, var(--intro-primary) 0%, #818cf8 100%);
    color: white;
}

.action-btn.chat-btn:hover {
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

/* 댓글 섹션 */
.comments-section {
    background: var(--intro-card);
    border-radius: 20px;
    padding: 24px;
    border: 1px solid var(--intro-border);
}

.comment-form {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--intro-border);
}

.form-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        var(--intro-primary) 0%,
        var(--intro-accent) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    flex-shrink: 0;
    overflow: hidden; /* 이미지 넘침 방지 */
}
/* 아바타 컨테이너 */
.comment-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    background-color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: bold;
    color: #555;
}

/* 사용자 이미지 */
.comment-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #4a90e2;
    transition: transform 0.2s;
}

.comment-avatar-img:hover {
    transform: scale(1.05);
}
/* =========================
   📊 스토리 독자 통계 영역
========================= */

#storyStatsView {
    margin-top: 48px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 30px;
}

/* 제목 */
#storyStatsView .section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================
   차트 그리드
========================= */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* =========================
   차트 카드
========================= */

.chart-container {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chart-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* 차트 제목 */
.chart-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
}

/* 캔버스 */
.chart-container canvas {
    width: 100% !important;
    height: 260px !important;
}

/* =========================
   반응형
========================= */

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-container canvas {
        height: 220px !important;
    }

    #storyStatsView {
        padding: 20px;
    }
}

/* placeholder */
.comment-avatar-placeholder {
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

/* 이미지가 있을 때 */
.form-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}



.form-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-input-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--intro-bg);
    border: 1px solid var(--intro-border);
    border-radius: 12px;
    color: var(--intro-text);
    font-size: 0.95rem;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.3s;
}

.form-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--intro-primary);
}

.form-input-wrapper textarea::placeholder {
    color: var(--intro-text-muted);
}

.submit-comment-btn {
    align-self: flex-end;
    padding: 10px 20px;
    background: var(--intro-primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-comment-btn:hover {
    background: #4f46e5;
}

.login-prompt {
    text-align: center;
    padding: 20px;
    background: var(--intro-bg);
    border-radius: 12px;
    margin-bottom: 24px;
    color: var(--intro-text-muted);
}

.login-prompt a {
    color: var(--intro-accent);
    text-decoration: none;
}

.login-prompt a:hover {
    text-decoration: underline;
}

/* 댓글 목록 */
.comments-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment-item {
    display: flex;
    gap: 12px;
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--intro-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--intro-text);
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.comment-avatar.small {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}

.comment-body {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.comment-author {
    font-weight: 600;
    color: var(--intro-text);
    font-size: 0.9rem;
}

.comment-date {
    font-size: 0.8rem;
    color: var(--intro-text-muted);
}

.comment-content {
    font-size: 0.95rem;
    color: var(--intro-text);
    line-height: 1.5;
    margin-bottom: 8px;
}

.comment-actions {
    display: flex;
    gap: 12px;
}

.comment-actions button {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--intro-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s;
}

.comment-actions button:hover {
    color: var(--intro-accent);
}

.comment-actions .delete-btn:hover {
    color: var(--intro-danger);
}

.replies-list {
    margin-top: 16px;
    padding-left: 20px;
    border-left: 2px solid var(--intro-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.reply-item {
    display: flex;
    gap: 10px;
}

.no-comments {
    text-align: center;
    padding: 40px 20px;
    color: var(--intro-text-muted);
}

/* 빈 상태 */
.empty-state {
    text-align: center;
    padding: 60px 30px;
    background: var(--intro-bg);
    border-radius: 16px;
    color: var(--intro-text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* 뒤로가기 */
.back-link-wrapper {
    text-align: center;
    padding: 24px;
}

.back-link {
    color: var(--intro-text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--intro-accent);
}

/* 반응형 */
@media (max-width: 768px) {
    .story-intro-page {
        max-width: 100%;
    }

    .content-wrapper {
        padding: 0 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .cover-image {
        width: 120px;
        height: 160px;
    }

    .story-title {
        font-size: 1.4rem;
    }

    .story-author {
        justify-content: center;
    }

    .story-stats {
        justify-content: center;
        flex-wrap: wrap;
    }

    .like-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    /* 캐릭터 카드 - 모바일에서도 2열 유지 */
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .card-name {
        font-size: 0.95rem;
    }

    .card-desc {
        font-size: 0.7rem;
    }

    .card-tag {
        font-size: 0.6rem;
        padding: 3px 6px;
    }

    .card-chat-btn {
        font-size: 0.7rem;
        padding: 6px 10px;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .comment-form {
        flex-direction: column;
    }

    .form-avatar {
        align-self: flex-start;
    }

    .submit-comment-btn {
        width: 100%;
    }

    .comments-section {
        padding: 16px;
        border-radius: 16px;
    }
}

@media (max-width: 400px) {
    .character-grid {
        gap: 10px;
    }

    .card-footer {
        padding: 10px;
    }

    .card-tags {
        margin-bottom: 8px;
    }

    .story-header {
        padding: 24px 16px;
    }
}

/* 라이트 모드 */
body.light-mode .story-intro-page {
    background: #f8f9fa
}



body.light-mode .story-header {
    background: #ffffff;
}

body.light-mode .header-overlay {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(248, 249, 250, 0.95) 100%);
}

body.light-mode .character-card,
body.light-mode .comments-section {
    background: #ffffff;
    border-color: #e0e0e0;
}

body.light-mode .story-title,
body.light-mode .section-title,
body.light-mode .comment-author,
body.light-mode .comment-content {
    color: #1a1a1a;
}

body.light-mode .card-name,
body.light-mode .card-desc
{
    color: #d9d9d9;
}



body.light-mode .story-desc,
body.light-mode .author-name,
body.light-mode .stat-item,
body.light-mode .comment-date {
    color: #292929;
}

body.light-mode .form-input-wrapper textarea {
    background: #f8f9fa;
    border-color: #e0e0e0;
    color: #1a1a1a;
}

body.light-mode .like-btn {
    background: #f8f9fa;
    border-color: #e0e0e0;
    color: #1a1a1a;
}
/* =========================
   🌞 Light Mode - Story Header
========================= */

body.light-mode .story-header {
    background: #f8f9fb;
    border-radius: 0 0 24px 24px;
}

/* 배경 이미지 */
body.light-mode .header-bg img {
    filter: blur(18px);
    opacity: 0.25;
}

/* 오버레이 (밝은 그라데이션) */
body.light-mode .header-overlay {
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.85) 0%,
        rgba(245, 246, 250, 0.95) 100%
    );
}

/* 헤더 콘텐츠 */
body.light-mode .header-content {
    color: #1a1a1a;
}

/* 제목 */
body.light-mode .story-title {
    color: #1a1a1a;
}

/* 작가 정보 */
body.light-mode .story-author {
    color: #555;
}

/* 작가 이름 */
body.light-mode .author-name {
    color: #555;
}

/* 작가 아바타 */
body.light-mode .author-avatar {
    background: linear-gradient(
        135deg,
        #6366f1 0%,
        #8b5cf6 100%
    );
    color: #fff;
}

/* 커버 이미지 테두리 느낌 */
body.light-mode .cover-image {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

/* 커버 placeholder */
body.light-mode .cover-placeholder {
    background: linear-gradient(
        135deg,
        #e5e7eb 0%,
        #f3f4f6 100%
    );
    color: #9ca3af;
}

/* ── 북마크 버튼 ── */
.story-bookmark-btn {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.5); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.6); transition: background .18s, color .18s, transform .18s;
}
.story-bookmark-btn:hover { background: rgba(0,0,0,.75); color: #fff; transform: scale(1.1); }
.story-bookmark-btn.bookmarked { color: #fbbf24; background: rgba(0,0,0,.65); }
