/* =========================================================
   STORY READER – Unified CSS (vC)
   Includes: Reader UI + Media + Highlight + Popup + Animation
   Author: Coach Henry X-Huy
   ========================================================= */


/* ========== 1. BASE LAYOUT ========== */
.story-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    line-height: 1.7;
    font-family: 'Inter', sans-serif;
    color: #222;
}

/* ========== 2. TEXT & HIGHLIGHT ========== */
.story-paragraph {
    position: relative;
    transition: background 0.3s ease, color 0.3s ease;
}
.story-paragraph.active {
    background: rgba(255, 230, 150, 0.45);
    border-radius: 6px;
}
.story-paragraph.highlight {
    background: rgba(230, 245, 255, 0.5);
}

/* === Story Content Typography === */
.story-content {
    font-size: 18px;      /* tăng từ 16px lên 18px */
    line-height: 1.8;     /* khoảng cách dòng dễ đọc hơn */
    color: #222;          /* màu chữ đậm nhẹ hơn */
    font-family: "Noto Sans", "Open Sans", sans-serif;
}

/* Nếu có đoạn in nghiêng, trích dẫn, v.v. */
.story-content p {
    margin-bottom: 1.2em;
}

.story-content strong {
    font-weight: 600;
}


/* ========== 3. AUDIO / TTS CONTROLS ========== */
.story-audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    margin: 20px 0;
    padding-right: 5px;
}

/* ===== FIX: WAVEFORM BACKGROUND & BAR STYLE ===== */
.story-waveform {
    background: #f5f5f5; /* nền xám nhạt nhẹ cho vùng sóng */
    border-radius: 6px;
    padding: 6px 8px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 2px;

    width: 240px;
    height: 46px;
    margin-top: 6px;
}

.story-bar {
    width: 5px;
    height: 3px;
    background: #F8C947; /* vàng đồng bộ nút Play */
    border-radius: 5px;
    transition: height 0.2s ease, background 0.25s ease;
}

.story-bar.active {
    background: #F6B900; /* vàng đậm hơn khi có nhịp */
}


/* Audio Buttons */
.story-reader-btn {
    background: #e63946;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 500;
}
.story-reader-btn:hover {
    background: #d62839;
    transform: scale(1.05);
}
.story-reader-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.story-play-btn .play-icon {
    font-size: 1.1em; /* chỉ tăng kích thước icon */
    line-height: 1;    /* đảm bảo icon căn giữa */
}


/* ===== FIX: PLAY STORY BUTTON ===== */
.story-play-btn {
    background-color: #F8C947; /* vàng đặc trưng */
    color: #000;
    border: none;
    border-radius: 10;
    width: 140px;
    height: 60px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.story-play-btn:hover {
    background-color: #F6B900; /* vàng đậm hơn khi hover */
    transform: scale(1.1);
}



.story-play-btn:hover {
    transform: scale(1.1); /* hover to hơn */
}

/* ========== 4. MEDIA ELEMENTS (IMG / VIDEO) ========== */


.story-media {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    margin: 24px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.story-media img, 
.story-media video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: inherit;
}
.story-media .caption {
    font-size: 0.9em;
    text-align: center;
    color: #666;
    margin-top: 8px;
}

/* ========== 5. POPUP / OVERLAY ========== */
.story-popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}
.story-popup.active {
    opacity: 1;
    pointer-events: auto;
}
.story-popup-content {
    background: #fff;
    padding: 28px;
    border-radius: 16px;
    max-width: 520px;
    width: 90%;
    text-align: center;
    animation: popIn 0.3s ease;
}
@keyframes popIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ========== 6. DYNAMIC STATES ========== */
body.story-has-audio .story-reader-controls { display: flex; }
body.story-has-video .story-media video { border: 2px solid #e63946; }
body.story-reading .story-paragraph.active { background: rgba(255, 240, 200, 0.7); }
body.story-paused .story-paragraph.active { background: rgba(230, 230, 230, 0.5); }
body.popup-active { overflow: hidden; }

/* ========== 7. HEADER + TITLE ===================== */
.story-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: #f9f9f9;
    border-bottom: 1px solid #ddd;
    gap: 12px;
    margin-bottom: 30px; /* thêm khoảng cách xuống title */
}

.story-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.story-author-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.author-line {
    font-size: 1em;
    color: #000; /* text Author màu đen */
}

/* Tách dòng Date và Category */
.date-category-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 26px;
    margin-top: 4px;
    font-size: 0.85em;
    color: #666;
}

.story-stats {
    margin-left: auto;
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 3px;
}

.story-love-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center; /* canh số love với icon */
}

.story-love-count {
    display: inline-block;
    vertical-align: middle; /* đảm bảo đứng giữa */
    margin-left: 4px; /* khoảng cách nhỏ nếu cần */
}

.story-created {
    font-style: normal; /* in nghiêng */
    color: #555;
}

.story-category-link {
    text-decoration: none;
    color: #00518B; /* màu link category */
    font-weight: 500;
}

.story-category-link:hover {
    text-decoration: underline;
}

.story-title {
    color: #00518B;
    font-size:40px;
    font-weight: 600;
    margin: 16px 0 12px 0;
    font-family: "Libre Baskerville", serif; /* tuỳ gu "Libre Baskerville", serif; */
}

/* Header meta container */
.story-author-meta .date-category-line {
    display: flex;
    flex-wrap: wrap; /* nếu quá hẹp thì xuống dòng */
    align-items: center; /* canh dọc cùng hàng */
    justify-content: space-between; /* cate + date bên trái, stats bên phải */
    gap: 6px;
}

/* ===== Responsive mobile fix ===== */
@media (max-width: 600px) {
    .story-author-meta .date-category-line {
        flex-wrap: wrap;
        gap: 4px;
    }

    .story-stats {
        margin: 0; /* xóa margin top thừa */
        text-align: right;
        font-size: 16px;
        display: flex;
        align-items: center; 
        gap: 1px;
                /* thêm để ép sang phải */
        margin-left: auto; 
    }
}

/* ================= FOOTER ===================== */
.story-footer {
    margin-top: 32px;
    border-top: 1px solid #ddd;
    padding-top: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
}

.story-hashtags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.story-hashtag {
    background: #eef6ff;
    color: #00518B;
    font-size: 0.85em;
    padding: 4px 8px;
    gap: 2px;
    border-radius: 12px;
}

.story-next-btn {
    height: 45px;  /* ví dụ nút .story-cta cao 32px */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px; 
    margin-right: 2px;
    background-color: #1A72B6;
    border: 1px solid #1A72B6;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    font-family: inherit;
    line-height: normal; /* để không nhân với height */
    cursor: pointer;
    gap: 3px;
    text-decoration: none;
    text-transform: uppercase;
    transition: background-color 0.2s, border-color 0.2s;
}


.story-next-btn:hover {
    background-color: #155a96;
    border-color: #155a96;
}

/* ===== Responsive mobile fix ===== */
@media (max-width: 600px) {
    .story-next-btn {
        height: 52px; 
    }
}


/* ========== 8. RESPONSIVE ≤768px ===================== */
@media (max-width: 768px) {
    .story-wrapper { padding: 16px; }
    .story-reader-btn { padding: 8px 14px; font-size: 1em; }
    .story-popup-content { padding: 20px; }

    .story-audio-player .story-play-btn,
    .story-audio-player .story-reader-btn {
          flex: 0 0 80%;
          max-width: 80%;
    }
    .story-audio-player {
        display: flex;
        align-items: flex-end;
        gap: 2px; /* hoặc 8px */
    }

    .story-header {
        padding: 10px 12px;
    }
    .story-header .story-avatar {
        width: 40px;
        height: 40px;
    }
    .story-header .story-author-info h4 {
        font-size: 0.95em;
    }
    .story-header .story-author-info p {
        font-size: 0.75em;
    }
    .story-title {
        font-size: 32px;
        font-family: "Libre Baskerville", serif;
    }

    .story-waveform {
        display: flex;
        align-items: center; /* căn giữa so với nút */
        justify-content: flex-start;
        gap: 3px;
        height: 36px;
    }
    .story-bar {
        width: 4px;
        height: 6px;
    }
}

/* ================= Story Footer Buttons ================= */
/* Footer layout */
.story-footer {
    display: flex;
    justify-content: space-between; /* chia trái / phải */
    align-items: flex-start; /* căn top để bên trái wrap */
    flex-wrap: nowrap; /* footer chính không wrap */
    padding: 15px 15px;
    border-top: 1px solid #ddd;
    gap: 10px;
    background-color: #F9F9F9;
}

/* Left meta */
.story-footer-meta-wrapper {
    flex: 1; /* chiếm không gian còn lại */
    min-width: 0; /* bắt buộc để flex item wrap nội dung bên trong */
}

.story-footer-meta {
    display: flex;
    flex-wrap: wrap; /* pill bên trái tự wrap xuống */
    gap: 5px;
}

.story-footer-meta .story-footer-pill {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid #666;
    border-radius: 1px; /* pill vuông nhẹ */
    font-size: 14px;
    color: #333;
    text-decoration: none;
}

.story-footer-meta .story-footer-pill:hover {
    background-color: #f0f0f0;
}

/* Hashtags riêng 1 hàng */
.story-footer-hashtags {
    margin-top: 4px; /* khoảng cách so với các pill trên */
    display: flex;
    flex-wrap: wrap;
    gap: 6px; /* khoảng cách giữa các hashtag */
}

/* Right CTA buttons */
.story-cta {
    display: flex;
    flex-wrap: nowrap; /* luôn trên 1 hàng */
    gap: 1px; /* khoảng cách giữa 3 nút */
    white-space: nowrap; /* tránh xuống dòng */
}

.story-cta button {
    background-color: #1A72B6;
    border: 1px solid #1A72B6;
    color: #fff;
    border-radius: 4px;
    padding: 5px 10px;
    margin-right: 2px; 
    gap: 3px;
    cursor: pointer;
    font-size: 14px;
}

.story-cta button:hover {
    background-color: #155a96;
    border-color: #155a96;
}

/* Responsive Mobile */
@media screen and (max-width: 768px) {
    .story-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .story-cta {
        margin-top: 8px;
        display: flex;
        flex-wrap: wrap; /* mobile mới wrap */
    }
    .story-cta button {
        min-width: 0;       /* tránh overflow */
        padding: 8px 12px;     /* tăng chiều cao nút */
        font-size: 14px;    
    }    
}

/* All Stories pill */
.all-stories-pill {
    background-color: #1B72B6 !important;
    color: #fff !important;
    border-color: #1B72B6 !important;
}
.all-stories-pill:hover {
    background-color: #155a90 !important;
    border-color: #155a90 !important;
}


/* ================= Story Share Buttons ================= */
/* ===== SHARE POPUP STYLING ===== */
.story-share-popup {
    display: none;
    position: absolute;
    width: 200px;
    margin-top: 15px;
    bottom: 70px;
    right: 0;
    background: #e0e0e0; /* nền xám nhẹ */
    border-color: #1B72B6;
    border-radius: 8px;
    padding: 12px;
    flex-direction: column;
    gap: 2px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 100;
}

.story-share-popup.show {
    display: flex !important;
    flex-direction: column;
}


/* Style cho từng nút bên trong popup */
.story-share-popup .share-item {
    color: #000; /* Màu chữ đen */
    background: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    margin: 1px !important;
}

/* Hover effect cho đẹp hơn */
.story-share-popup .share-item:hover {
    background: #61BF5D;
}

/* ===== Go Top Button - Simple WordPress Style ===== */
#go-top {
    display: none;
    position: fixed;
    bottom: 70px;
    right: 5px; /* sát lề phải */
    z-index: 999;
    background: #E7E7E7; /* màu nút WP */
    color: #0073aa;
    border: none;
    padding: 6px 12px; /* size nhỏ vừa phải */
    border-radius: 50px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

#go-top:hover {
    background: #006799;
    transform: translateY(-2px);
}

.story-audio-player {
    display: flex;
    align-items: center; /* căn giữa theo trục ngang */
    gap: 2px;
}

/* ===== Nút 🔊 ===== */

/* TTS emoji và popup */
.story-waveform-wrapper {
    position: relative;
}

.tts-emoji {
    position: absolute;
    right: -23px;      /* sát bên phải waveform */
    bottom: -5px;       /* ngang đáy waveform */
    cursor: pointer;
    font-size: 18px;
}

.tts-info-popup {
    display: none;
    position: absolute;
    left: 110%;        /* bắt đầu từ cạnh phải emoji */
    bottom: 0;         /* ngang đáy emoji */
    width: 200px;
    background: #98E691;
    color: #3F3F3F;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: normal;
    z-index: 10;
}

/* Hiển thị popup khi active */
.tts-emoji.active + .tts-info-popup {
    display: block;
}

/* Responsive */
@media (max-width: 600px) {
    .tts-emoji {
        right: auto;
        left: 0;       /* emoji sát lề trái */
        bottom: auto;
        top: -18px;        /* nằm ngang đỉnh waveform */
    }

    .tts-info-popup {
        right: auto;
        left: auto;         /* không tính từ trái */
        top: -22px;             /* ngang emoji */
        transform: translateX(-100%); /* xổ qua trái emoji */
        width: 240px;
        height: 90px;
        background-color: #98E691;
        border-color: #CFCFCF;
        font-size: 15px;
        white-space: normal;
    }
}

