@tailwind base;
@tailwind components;
@tailwind utilities;

/* ==============================
   Calcala-News Custom Styles
   Beyond Tailwind utilities
   ============================== */


/* --- Hide scrollbar on hot-updates panel --- */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- Modal overlay & content transitions --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    border-radius: 6px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(30px) scale(0.95);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* --- Mobile menu drawer --- */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 45;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: #fff;
    z-index: 46;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.mobile-menu-drawer.active {
    transform: translateX(0);
}

/* --- Bottom sticky bar entrance --- */
@keyframes slide-in-from-bottom {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-in-bottom {
    animation: slide-in-from-bottom 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- Newsletter success toast --- */
.newsletter-toast {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.newsletter-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- Quiz modal progress bar --- */
.quiz-progress-bar {
    height: 5px;
    background: #E2E8F0;
    border-radius: 9999px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(to left, #dc2626, #b91c1c);
    border-radius: 9999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   QUIZ MODAL — CRO-OPTIMISED REDESIGN
   ========================================== */

/* Desktop: centered card */
#quiz-modal {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#quiz-modal.hidden {
    display: none !important;
}

/* The inner card */
#quiz-modal > div {
    border-radius: 1.25rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: quiz-modal-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes quiz-modal-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Option buttons — CRO polish */
.quiz-option-btn {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.18s ease;
}

.quiz-option-btn:active {
    transform: scale(0.98);
}

.quiz-option-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(220, 38, 38, 0.06);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.quiz-option-btn:hover::after {
    opacity: 1;
}

/* Pulse animation for primary CTA */
@keyframes cta-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50%        { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.quiz-cta-pulse {
    animation: cta-pulse 2s ease-in-out 1s infinite;
}

/* Trust badge row */
.quiz-trust-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.72rem;
    color: #6b7280;
    flex-wrap: wrap;
}

.quiz-trust-row span {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    white-space: nowrap;
}

/* Headline hook bar */
.quiz-hook-bar {
    background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%);
    padding: 1.1rem 1.5rem 0.9rem;
    border-radius: 1.25rem 1.25rem 0 0;
    text-align: center;
    color: white;
}

.quiz-hook-bar .hook-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 9999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 0.5rem;
}

.quiz-hook-bar .hook-title {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 0.1rem;
}

.quiz-hook-bar .hook-sub {
    font-size: 0.8rem;
    opacity: 0.85;
}

/* Step counter pill */
.quiz-step-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 9999px;
    padding: 0.2rem 0.75rem;
    margin-bottom: 1rem;
}

/* Selected option styling */
.quiz-option-btn.selected {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    font-weight: 700;
}

/* --- Body scroll lock --- */
body.modal-open {
    overflow: hidden;
}

/* --- Market data flash animation --- */
@keyframes flash-green {

    0%,
    100% {
        background: transparent;
    }

    50% {
        background: rgba(16, 185, 129, 0.1);
    }
}

@keyframes flash-red {

    0%,
    100% {
        background: transparent;
    }

    50% {
        background: rgba(239, 68, 68, 0.1);
    }
}

.flash-up {
    animation: flash-green 0.6s ease;
}

.flash-down {
    animation: flash-red 0.6s ease;
}

/* Article body prose styles */
.prose {
    max-width: 65ch;
    color: #374151;
    line-height: 1.75;
}

.prose h2 {
    font-size: 1.5em;
    font-weight: 700;
    color: #111827;
    margin-top: 2em;
    margin-bottom: 1em;
    line-height: 1.3333333;
}

.prose h3 {
    font-size: 1.25em;
    font-weight: 600;
    color: #111827;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
    line-height: 1.6;
}

.prose p {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
}

.prose img {
    margin-top: 2em;
    margin-bottom: 2em;
    border-radius: 0.375rem;
}

.prose ul,
.prose ol {
    margin-top: 1.25em;
    margin-bottom: 1.25em;
    padding-right: 1.625em;
    list-style-type: disc;
}

.prose li {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.prose a {
    color: #2563eb;
    text-decoration: underline;
    font-weight: 500;
}

.prose a:hover {
    color: #1d4ed8;
}

.prose strong {
    font-weight: 600;
    color: #111827;
}

.prose blockquote {
    font-weight: 500;
    font-style: italic;
    color: #111827;
    border-right-width: 0.25rem;
    border-right-color: #2563eb;
    quotes: "“" "”" "‘" "’";
    margin-top: 1.6em;
    margin-bottom: 1.6em;
    padding-right: 1em;
}

/* Mobile-specific fixes */
@media (max-width: 768px) {

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    /* Hero article responsive */
    #hero-article .relative {
        height: 280px !important;
        /* Reduce hero height on mobile */
    }

    /* Article grid - single column on mobile */
    #articles-grid .grid {
        grid-template-columns: 1fr !important;
    }

    /* Quiz modal — bottom sheet on mobile */
    #quiz-modal {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    #quiz-modal > div {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 92vh !important;
        height: auto !important;
        margin: 0 !important;
        border-radius: 1.25rem 1.25rem 0 0 !important;
        animation: quiz-sheet-up 0.38s cubic-bezier(0.34, 1.2, 0.64, 1) forwards !important;
    }

    .quiz-hook-bar {
        border-radius: 1.25rem 1.25rem 0 0 !important;
    }

    @keyframes quiz-sheet-up {
        from {
            opacity: 0;
            transform: translateY(60px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Entry hook buttons - stack on mobile if too cramped */
    #article-inline-cta .grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Market widget - allow horizontal scroll */
    #market-data-widget {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ticker - smaller text on mobile */
    #ticker-content {
        font-size: 0.875rem !important;
    }

    /* Bottom sticky bar - reduce height */
    .fixed.bottom-0 {
        padding: 0.75rem 1rem !important;
    }

    /* Article body - better readability */
    #article-body {
        font-size: 1.125rem !important;
        line-height: 1.75 !important;
    }

    /* Related articles - single column */
    #related-articles {
        grid-template-columns: 1fr !important;
    }

    /* Admin sidebar - hide on mobile, show hamburger */
    aside.fixed {
        transform: translateX(100%);
        transition: transform 0.3s;
    }

    aside.fixed.mobile-open {
        transform: translateX(0);
    }
}