/* =========================================
   ARTICLE ENHANCEMENT LAYER
   =========================================
   Reading progress, emoji reactions, comments,
   related articles, floating actions, reading time.
   Shared across all guide & article pages.
   ========================================= */

/* --- READING PROGRESS BAR --- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #F59E0B, #fbbf24);
    z-index: 99999;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* --- EMOJI REACTION BAR --- */
.emoji-reaction-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    margin: 24px 0 32px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
}

.emoji-reaction-bar .reaction-label {
    font-size: 0.78rem;
    color: #52525b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 4px;
}

.emoji-reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid #27272a;
    background: rgba(255, 255, 255, 0.02);
    color: #a1a1aa;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.emoji-reaction-btn:hover {
    border-color: #52525b;
    background: rgba(255, 255, 255, 0.05);
    transform: scale(1.05);
}

.emoji-reaction-btn.reacted {
    border-color: #F59E0B;
    background: rgba(245, 158, 11, 0.1);
    color: #F59E0B;
}

.emoji-reaction-btn .emoji-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.emoji-reaction-btn .reaction-count {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 12px;
    text-align: center;
}

/* Bounce animation on react */
@keyframes emojiBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.3); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.emoji-reaction-btn.animate .emoji-icon {
    animation: emojiBounce 0.4s ease;
}

/* --- FLOATING ACTION BAR (Side) --- */
.floating-actions {
    position: fixed;
    left: max(20px, calc((100vw - 860px) / 2 - 90px));
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.3s;
    display: none; /* Hidden by default, shown only on wide screens */
}

.floating-actions.visible {
    opacity: 1;
}

.float-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(15, 15, 17, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid #27272a;
    color: #71717a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    position: relative;
}

.float-btn:hover {
    border-color: #F59E0B;
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.08);
    transform: scale(1.1);
}

.float-btn.active {
    border-color: #F59E0B;
    color: #F59E0B;
    background: rgba(245, 158, 11, 0.12);
}

.float-btn .float-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #F59E0B;
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.float-divider {
    width: 24px;
    height: 1px;
    background: #27272a;
    margin: 0 auto;
}

/* --- COMMENTS SECTION --- */
.comments-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.comments-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.comments-header h3 i {
    color: #F59E0B;
    font-size: 1rem;
}

.comment-count-badge {
    background: rgba(245, 158, 11, 0.12);
    color: #F59E0B;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50px;
}

/* Comment Input */
.comment-compose {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    align-items: flex-start;
}

.comment-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F59E0B, #f97316);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.comment-input-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment-textarea {
    width: 100%;
    min-height: 80px;
    background: #0f0f11;
    border: 1px solid #27272a;
    border-radius: 12px;
    color: #e4e4e7;
    padding: 14px 16px;
    font-size: 0.92rem;
    font-family: 'Inter', sans-serif;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    line-height: 1.6;
}

.comment-textarea:focus {
    border-color: #F59E0B;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.08);
}

.comment-textarea::placeholder {
    color: #3f3f46;
}

.comment-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.emoji-insert-bar {
    display: flex;
    gap: 4px;
}

.emoji-insert-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.15s;
    opacity: 0.5;
}

.emoji-insert-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    opacity: 1;
    transform: scale(1.15);
}

.comment-submit-btn {
    padding: 8px 20px;
    background: #F59E0B;
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.comment-submit-btn:hover {
    background: #fbbf24;
    transform: translateY(-1px);
}

.comment-submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Comment List */
.comments-list-enhanced {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.comment-item-enhanced {
    display: flex;
    gap: 14px;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.comment-item-enhanced:last-child {
    border-bottom: none;
}

.comment-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    color: #000;
    flex-shrink: 0;
}

.comment-item-body {
    flex: 1;
    min-width: 0;
}

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

.comment-item-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: #e4e4e7;
}

.comment-item-date {
    font-size: 0.75rem;
    color: #52525b;
}

.comment-item-text {
    font-size: 0.92rem;
    color: #a1a1aa;
    line-height: 1.6;
    word-break: break-word;
}

.comments-empty {
    text-align: center;
    padding: 40px 20px;
    color: #3f3f46;
}

.comments-empty i {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
    color: #27272a;
}

.comments-empty p {
    font-size: 0.9rem;
    margin: 0;
}

.comments-login-prompt {
    text-align: center;
    padding: 20px;
    background: rgba(245, 158, 11, 0.04);
    border: 1px dashed #27272a;
    border-radius: 12px;
    margin-bottom: 24px;
    color: #71717a;
    font-size: 0.9rem;
}

.comments-login-prompt a {
    color: #F59E0B;
    text-decoration: none;
    font-weight: 600;
}

/* --- RELATED ARTICLES --- */
.related-articles-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.related-articles-section h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.related-articles-section h3 i {
    color: #F59E0B;
    font-size: 1rem;
}

.related-grid-enhanced {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.related-card-enhanced {
    background: #09090b;
    border: 1px solid #1f1f23;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.related-card-enhanced:hover {
    transform: translateY(-4px);
    border-color: #3f3f46;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

.related-card-img {
    height: 140px;
    overflow: hidden;
    position: relative;
}

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

.related-card-enhanced:hover .related-card-img img {
    transform: scale(1.05);
}

.related-card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #F59E0B;
    color: #000;
}

.related-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.related-card-body h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e4e4e7;
    margin: 0 0 8px;
    line-height: 1.4;
}

.related-card-body p {
    font-size: 0.8rem;
    color: #52525b;
    line-height: 1.5;
    margin: 0 0 12px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.73rem;
    color: #3f3f46;
}

.related-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.related-card-cta {
    color: #F59E0B;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

/* --- TABLE OF CONTENTS --- */
.toc-sidebar {
    position: fixed;
    right: max(24px, calc((100vw - 860px) / 2 - 230px));
    top: 50%;
    transform: translateY(-50%);
    width: 170px;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.3s;
    display: none; /* Hidden by default, shown only on very wide screens */
}

.toc-sidebar.visible {
    opacity: 1;
}

.toc-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #3f3f46;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-list a {
    display: block;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: #52525b;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-list a:hover {
    color: #a1a1aa;
    border-left-color: #3f3f46;
}

.toc-list a.active {
    color: #F59E0B;
    border-left-color: #F59E0B;
    font-weight: 500;
}

/* --- ARTICLE BREADCRUMB --- */
.article-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: #52525b;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.article-breadcrumb a {
    color: #71717a;
    text-decoration: none;
    transition: color 0.2s;
}

.article-breadcrumb a:hover {
    color: #F59E0B;
}

.article-breadcrumb .separator {
    color: #27272a;
}

/* --- ESTIMATED READ TIME PILL --- */
.read-progress-pill {
    position: fixed;
    top: 16px;
    right: 20px;
    background: rgba(15, 15, 17, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid #27272a;
    border-radius: 50px;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: #71717a;
    z-index: 99998;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
}

.read-progress-pill.visible {
    opacity: 1;
    transform: translateY(0);
}

.read-progress-pill .progress-pct {
    color: #F59E0B;
    font-weight: 700;
}

/* --- WIDE SCREEN: Show floating elements only when there's room --- */
@media (min-width: 1500px) {
    .floating-actions {
        display: flex !important;
    }
}

@media (min-width: 1440px) {
    .toc-sidebar {
        display: block !important;
    }
}

@media (max-width: 768px) {
    .emoji-reaction-bar {
        gap: 6px;
    }

    .emoji-reaction-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .related-grid-enhanced {
        grid-template-columns: 1fr;
    }

    .comment-compose {
        flex-direction: column;
        align-items: stretch;
    }

    .comment-avatar-placeholder {
        display: none;
    }

    .read-progress-pill {
        top: auto;
        bottom: 16px;
        right: 16px;
    }
}

/* --- MOBILE FLOATING BAR (Shown on tablet-to-desktop non-ultra-wide screens) --- */
@media (min-width: 901px) and (max-width: 1499px) {
    .mobile-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(9, 9, 11, 0.95);
        backdrop-filter: blur(12px);
        border-top: 1px solid #1f1f23;
        padding: 10px 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 24px;
        z-index: 500;
    }

    .mobile-action-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        background: none;
        border: none;
        color: #71717a;
        cursor: pointer;
        font-size: 0.65rem;
        font-weight: 500;
        padding: 4px 12px;
        transition: color 0.2s;
    }

    .mobile-action-btn i {
        font-size: 1.1rem;
    }

    .mobile-action-btn.active,
    .mobile-action-btn:hover {
        color: #F59E0B;
    }

    /* Ensure content doesn't hide behind bar on tablet/desktop */
    .article-container,
    .article-wrapper {
        padding-bottom: 80px !important;
    }
}

/* On mobile: no fixed bar, sidebar is inline */
@media (max-width: 900px) {
    .mobile-action-bar {
        display: none !important;
    }

    /* No extra padding needed since nothing is fixed */
    .article-container,
    .article-wrapper {
        padding-bottom: 40px !important;
    }
}

@media (min-width: 1500px) {
    .mobile-action-bar { display: none !important; }
}
