/* ============================================
   OVERLAY MODALS
   ============================================
   Recent stories modal + story stats card/modal + demographics card/modal.
   Each modal pairs with a JS file under public/js/modals/. Loaded after
   styles.css.
   ============================================ */

/* ============================================
   RECENT STORIES BUTTON & MODAL
   ============================================ */

.recent-stories-btn {
    position: fixed;
    bottom: 98px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: var(--bg-primary);
    cursor: pointer;
    z-index: 300;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.recent-stories-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.6);
}

.recent-stories-btn:active {
    transform: scale(0.95);
}

.recent-stories-btn.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.recent-stories-btn svg {
    width: 18px;
    height: 18px;
}

/* Recent stories modal */
.recent-stories-modal {
    max-width: 520px;
}

.recent-stories-modal__body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.recent-story {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    border-radius: var(--radius-xs);
}

.recent-story:last-child {
    border-bottom: none;
}

.recent-story:hover {
    background: rgba(255, 255, 255, 0.04);
}

.recent-story__body {
    flex: 1;
    min-width: 0;
}

.recent-story__snippet {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recent-story__location {
    color: rgba(255, 255, 255, 0.9);
}

.recent-story__meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 2px;
}

.recent-story__right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.recent-story__emoji {
    font-size: 18px;
}

.recent-story__hearts {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

@media (max-width: 640px) {
    .recent-stories-btn {
        bottom: 98px;
    }

    .recent-stories-modal {
        max-width: 100%;
    }

    .recent-story__snippet {
        font-size: 12px;
    }
}

/* ============================================
   STORY STATS CARD & MODAL
   ============================================ */

/* Small stats card above demographics card */
.story-stats-card {
    position: fixed;
    bottom: 84px;
    left: 10px;
    z-index: 300;
    padding: 8px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-family);
    opacity: 0;
    transform: translateY(10px);
    animation: demoCardFadeIn 0.5s ease forwards;
    animation-delay: 1.5s;
    transition: opacity 0.4s ease, transform 0.2s ease;
    width: 150px;
    box-sizing: border-box;
}

.story-stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.story-stats-card__icon {
    color: var(--text-primary);
    flex-shrink: 0;
}

.story-stats-card__flags {
    font-size: 14px;
    letter-spacing: 1px;
}

/* Story stats modal */
.story-stats-modal {
    max-width: 520px;
}

.story-stats-modal__body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-section__title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.stats-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.stats-row__name {
    flex: 1;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.stats-row__bar {
    flex: 1;
    height: 16px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.stats-row__bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
    width: 0;
}

.stats-row--clickable {
    cursor: pointer;
    border-radius: var(--radius-xs);
    padding: 4px 6px;
    margin: 0 -6px;
}

.stats-row--clickable:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Underline the name in clickable rows so users see it's a link.
   Subtle by default, brighter on hover. */
.stats-row--clickable .stats-row__name {
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.25);
    text-underline-offset: 3px;
    transition: text-decoration-color var(--transition-fast);
}

.stats-row--clickable:hover .stats-row__name {
    text-decoration-color: rgba(255, 255, 255, 0.7);
}

.stats-row__emoji {
    font-size: 16px;
    flex-shrink: 0;
}

.stats-row__bar-fill--region { background: var(--primary-color); }
.stats-row__bar-fill--country { background: #74c0fc; }

.stats-row__count {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    width: 32px;
    text-align: right;
    flex-shrink: 0;
}

/* Region with top countries */
.stats-region {
    margin-bottom: 4px;
}

.stats-region__top {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    padding-left: 2px;
    margin-top: 2px;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .story-stats-card {
        bottom: 78px;
        left: 8px;
        padding: 7px 7px;
    }

    .story-stats-modal {
        max-width: 100%;
    }

    .stats-row__name {
        font-size: 13px;
    }
}

/* ============================================
   DEMOGRAPHICS CARD & MODAL
   ============================================ */

/* Small stats card at bottom-left */
.demo-card {
    position: fixed;
    bottom: 40px;
    left: 10px;
    z-index: 300;
    padding: 8px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-family);
    opacity: 0;
    transform: translateY(10px);
    animation: demoCardFadeIn 0.5s ease forwards;
    animation-delay: 1s;
    transition: opacity 0.4s ease, transform 0.2s ease;
    width: 150px;
    box-sizing: border-box;
}

@keyframes demoCardFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.demo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.demo-card__stat {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.demo-card__icon {
    color: var(--text-primary);
    flex-shrink: 0;
}

/* Demographics modal */
.demo-modal {
    max-width: 520px;
}

.demo-modal__body {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 8px;
}

.demo-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.demo-section__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-section__highlight {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: auto;
}

.demo-section__bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.demo-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.demo-bar__label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 90px;
    text-align: right;
    text-transform: capitalize;
    flex-shrink: 0;
}

.demo-bar__track {
    flex: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-xs);
    overflow: hidden;
    position: relative;
}

.demo-bar__fill {
    height: 100%;
    border-radius: var(--radius-xs);
    width: 0;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.demo-bar__value {
    font-size: 11px;
    color: var(--text-secondary);
    width: 32px;
    text-align: left;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Bar colors per section */
.demo-section--belief .demo-bar__fill { background: rgba(212, 175, 55, 0.7); }
.demo-section--gender .demo-bar__fill { background: rgba(116, 192, 252, 0.7); }
.demo-section--orientation .demo-bar__fill { background: rgba(255, 105, 180, 0.7); }
.demo-section--age .demo-bar__fill { background: rgba(169, 227, 75, 0.7); }
.demo-section--decade .demo-bar__fill { background: rgba(255, 169, 77, 0.7); }
.demo-section--ageleft .demo-bar__fill { background: rgba(218, 119, 242, 0.7); }

/* "no response" bars are always gray */
.demo-bar--no-response .demo-bar__fill { background: rgba(255, 255, 255, 0.15) !important; }
.demo-bar--no-response .demo-bar__label { opacity: 0.5; }
.demo-bar--no-response .demo-bar__value { opacity: 0.5; }

/* Mobile responsive */
@media (max-width: 640px) {
    .demo-card {
        bottom: 36px;
        left: 8px;
        padding: 8px 14px;
    }

    .demo-card__stat {
        font-size: 13px;
    }

    .demo-modal {
        max-width: 100%;
    }

    .demo-bar__label {
        min-width: 70px;
        font-size: 11px;
    }

    .demo-bar__value {
        font-size: 10px;
        width: 28px;
    }
}

@media (max-width: 380px) {
    .demo-bar__label {
        min-width: 56px;
        font-size: 10px;
    }
}