/* ════════════════════════════════════════
   FANTABET — ENGAGEMENT STYLES
   Exit intent · Sticky bar · Reading progress · Autolink
   ════════════════════════════════════════ */

/* ─── EXIT INTENT POPUP ─── */
#fantabet-exit-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.eip-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.eip-box {
    position: relative;
    z-index: 1;
    background: var(--surface, #fff);
    border-radius: 18px;
    padding: 36px 32px 28px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
    animation: eipSlideIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
    border-top: 4px solid var(--red-accent, #c8410a);
}

@keyframes eipSlideIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.eip-close {
    position: absolute;
    top: 12px; right: 14px;
    background: none; border: none;
    font-size: 16px; color: var(--muted, #8a8078);
    cursor: pointer; padding: 4px 8px;
    border-radius: 4px; line-height: 1;
    transition: all 0.15s;
}
.eip-close:hover { background: var(--bg2, #ede9e0); color: var(--ink, #1a1612); }

.eip-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(200,65,10,0.08);
    border: 1px solid rgba(200,65,10,0.2);
    color: var(--red-accent, #c8410a);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.eip-logo {
    width: 60px; height: 60px;
    border-radius: 14px;
    background: var(--bg2, #ede9e0);
    border: 1px solid var(--border, #d4cfc5);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    margin: 0 auto 12px;
    overflow: hidden;
}
.eip-logo-img { width: 100%; height: 100%; object-fit: contain; }

.eip-title {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 20px;
    font-weight: 900;
    color: var(--ink, #1a1612);
    margin-bottom: 8px;
    line-height: 1.2;
}

.eip-amount {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 36px;
    font-weight: 900;
    color: var(--red-accent, #c8410a);
    line-height: 1;
    margin-bottom: 6px;
}

.eip-desc {
    font-size: 13px;
    color: var(--muted, #8a8078);
    margin-bottom: 20px;
    line-height: 1.4;
}

.eip-ctas {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.eip-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 20px;
    border-radius: 9px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.eip-btn--sport {
    background: linear-gradient(135deg, #c8410a, #e8a020);
    color: #ffffff !important;
    box-shadow: 0 4px 20px rgba(200,65,10,0.3);
}
.eip-btn--sport:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(200,65,10,0.45); color: #fff !important; }

.eip-btn--casino {
    background: linear-gradient(135deg, #92570a, #e8a020);
    color: #1a1612 !important;
    box-shadow: 0 4px 16px rgba(232,160,32,0.25);
}
.eip-btn--casino:hover { opacity: 0.9; transform: translateY(-1px); color: #1a1612 !important; }

.eip-skip {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--muted, #8a8078);
    cursor: pointer;
    text-decoration: underline;
    padding: 6px;
    font-family: inherit;
    transition: color 0.15s;
    width: 100%;
}
.eip-skip:hover { color: var(--ink, #1a1612); }

.eip-note {
    font-size: 10px;
    color: var(--muted, #8a8078);
    text-align: center;
}

/* Dark mode popup */
[data-theme="dark"] .eip-box {
    background: #1a1e2a;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
[data-theme="dark"] .eip-title { color: #f5f2eb; }
[data-theme="dark"] .eip-close:hover { background: rgba(255,255,255,0.08); color: #f5f2eb; }


/* ─── STICKY BOTTOM BAR ─── */
#fantabet-sticky-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 9000;
    display: none;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    background: var(--nav-bg, #12100e);
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.25);
    /* Solo su mobile */
}

#fantabet-sticky-bar.fsb-visible { transform: translateY(0); }

.fsb-inner {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.fsb-text { flex: 1; min-width: 0; }
.fsb-text strong { display: block; font-size: 13px; font-weight: 700; color: #f5f2eb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsb-text span    { font-size: 11px; color: rgba(245,242,235,0.5); }

.fsb-btn {
    background: linear-gradient(135deg, #c8410a, #e8a020);
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: 7px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s;
    box-shadow: 0 2px 12px rgba(200,65,10,0.3);
}
.fsb-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(200,65,10,0.45); color: #fff !important; }

/* Mostra sticky bar solo su mobile */
@media (min-width: 769px) {
    #fantabet-sticky-bar { display: none !important; }
}


/* ─── AUTOLINK BOOKMAKER ─── */
a.fantabet-bm-autolink {
    color: var(--red-accent, #c8410a);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    transition: opacity 0.15s;
}
a.fantabet-bm-autolink:hover { opacity: 0.75; }


/* ─── READING PROGRESS (già in wp_head inline, qui per debug) ─── */
#fantabet-reading-bar {
    position: fixed;
    top: 62px; left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #c8410a, #e8a020);
    z-index: 9999;
    transition: width 0.1s linear;
    pointer-events: none;
}


/* ════════════════════════════════════════
   SOMMARIO (TOC)
   ════════════════════════════════════════ */
.fantabet-toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--red-accent, #c8410a);
    border-radius: 10px;
    padding: 16px 20px;
    margin: 28px 0;
    transition: background 0.3s;
}

.toc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    user-select: none;
}

.toc-icon  { font-size: 16px; }

.toc-title {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    flex: 1;
}

.toc-toggle {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    font-family: inherit;
}
.toc-toggle:hover    { background: var(--bg2); color: var(--ink); }
.toc-toggle.collapsed { transform: rotate(-90deg); }

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.toc-list.hidden { max-height: 0 !important; }

.toc-item { display: block; }

.toc-item--sub { padding-left: 18px; }

.toc-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink2);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 5px;
    transition: all 0.15s;
    line-height: 1.4;
}

.toc-link::before {
    content: '→';
    color: var(--red-accent, #c8410a);
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.toc-link:hover {
    background: rgba(200,65,10,0.06);
    color: var(--red-accent, #c8410a);
}
.toc-link:hover::before { opacity: 1; }

.toc-item--sub .toc-link::before { content: '›'; }

/* Highlight heading attivo durante lo scroll */
.toc-link.active {
    color: var(--red-accent, #c8410a);
    background: rgba(200,65,10,0.07);
    font-weight: 700;
}

[data-theme="dark"] .fantabet-toc { background: var(--surface2, #141b2a); }


/* ════════════════════════════════════════
   ARTICOLI CORRELATI CONTESTUALI
   ════════════════════════════════════════ */
.related-posts--contextual {
    background: var(--bg2);
    padding: 56px 0;
    border-top: 1px solid var(--border);
    transition: background 0.3s;
}

.related-posts--contextual .related-posts-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 48px;
}

.related-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.related-header .related-title {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 24px;
    font-weight: 900;
    color: var(--ink);
    margin: 0;
}

.related-subtitle {
    font-size: 13px;
    color: var(--muted);
}

/* Griglia correlati */
.related-grid { display: grid; gap: 18px; }
.related-grid--3 { grid-template-columns: repeat(3, 1fr); }
.related-grid--4 { grid-template-columns: repeat(4, 1fr); }
.related-grid--6 { grid-template-columns: repeat(3, 1fr); } /* 2 righe × 3 col */

/* Card arricchita */
.related-card--rich {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    animation: fadeUp 0.5s ease both;
}

.related-card--rich:hover {
    border-color: rgba(200,65,10,0.25);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.related-card--rich .related-thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.related-card--rich .related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.related-card--rich:hover .related-thumb img { transform: scale(1.04); }

.related-cat {
    position: absolute;
    top: 10px; left: 10px;
    background: var(--red-accent, #c8410a);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.related-card--rich .related-card-body {
    padding: 16px 18px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.related-card--rich .related-card-title {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.related-card-excerpt {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.related-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 6px;
}

.related-date,
.related-rt {
    font-size: 11px;
    color: var(--muted);
}

.related-card-cta {
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
    color: var(--red-accent, #c8410a);
    text-align: right;
    transition: background 0.15s;
}

.related-card--rich:hover .related-card-cta {
    background: rgba(200,65,10,0.04);
}


/* ════════════════════════════════════════
   BACK TO TOP BUTTON
   ════════════════════════════════════════ */
#fantabet-back-top {
    position: fixed;
    bottom: 28px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--red-accent, #c8410a);
    color: white;
    border: none;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    z-index: 8000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 4px 16px rgba(200,65,10,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#fantabet-back-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#fantabet-back-top:hover {
    background: #a33508;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(200,65,10,0.5);
}

/* Su mobile sposta il bottone in alto (lascia spazio alla sticky bar) */
@media (max-width: 768px) {
    #fantabet-back-top { bottom: 70px; right: 16px; width: 42px; height: 42px; }
}


/* ════════════════════════════════════════
   BANNER "HAI FINITO? LEGGI ANCHE"
   ════════════════════════════════════════ */
#fantabet-next-article {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 8500;
    background: var(--nav-bg, #12100e);
    border-top: 2px solid var(--red-accent, #c8410a);
    box-shadow: 0 -4px 32px rgba(0,0,0,0.35);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}

#fantabet-next-article.visible { transform: translateY(0); }

.fna-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.fna-text-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.fna-label {
    font-size: 11px;
    font-weight: 700;
    color: rgba(245,242,235,0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.fna-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.fna-title {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 14px;
    font-weight: 700;
    color: #f5f2eb;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s;
    flex: 1;
}
.fna-title:hover { color: var(--gold-accent, #e8a020); }

.fna-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.fna-btn {
    background: linear-gradient(135deg, #c8410a, #e8a020);
    color: white !important;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 20px;
    border-radius: 7px;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
    box-shadow: 0 2px 12px rgba(200,65,10,0.3);
}
.fna-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(200,65,10,0.45); color: white !important; }

.fna-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(245,242,235,0.5);
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    font-family: inherit;
}
.fna-close:hover { background: rgba(255,255,255,0.12); color: #f5f2eb; }

/* Responsive */
@media (max-width: 640px) {
    .fna-inner    { padding: 10px 16px; flex-wrap: nowrap; }
    .fna-label    { display: none; }
    .fna-thumb    { display: none; }
    .fna-title    { font-size: 12px; }
    .fna-btn      { font-size: 12px; padding: 8px 14px; }
    
    .related-posts--contextual .related-posts-inner { padding: 0 16px; }
    .related-grid--3, .related-grid--6 { grid-template-columns: 1fr; }
    .related-grid--4 { grid-template-columns: 1fr 1fr; }
    .related-posts--contextual { padding: 40px 0; }
}

@media (max-width: 768px) {
    .related-grid--3, .related-grid--6 { grid-template-columns: repeat(2, 1fr); }
    .related-posts--contextual .related-posts-inner { padding: 0 20px; }
}
