/* ============================================================
   AI Homepage Enhancements — dalatmilkshop.com
   Features: Smart Greeting, Social Proof Counters, AI Quiz,
             Content-visibility, Lazy iframe, View Transitions
   ============================================================ */

/* --- Performance: content-visibility for below-fold sections --- */
.b2b-solutions,
.faq-section,
.testimonials-section,
.blog-section,
.promo-subscribe,
.ai-quiz-section {
    content-visibility: auto;
    contain-intrinsic-size: auto 600px;
}

/* --- AI Smart Greeting --- */
.ai-greeting {
    background: linear-gradient(135deg, #005A9C 0%, #0077CC 50%, #FF6B35 100%);
    color: #fff;
    text-align: center;
    padding: 0.75rem 1rem;
    font-size: 1.08rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    animation: greetSlideIn 0.6s cubic-bezier(.4,0,.2,1);
    position: relative;
    overflow: hidden;
}
.ai-greeting::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.08) 0%, transparent 70%);
    animation: greetShimmer 4s ease-in-out infinite;
}
.ai-greeting span {
    position: relative;
    z-index: 1;
}
@keyframes greetSlideIn {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes greetShimmer {
    0%, 100% { transform: translateX(-30%); }
    50% { transform: translateX(30%); }
}

/* --- Social Proof Counter Bar --- */
.social-proof-bar {
    background: #f8fafc;
    padding: 1.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}
.proof-stat {
    text-align: center;
    min-width: 140px;
}
.proof-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #005A9C;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.proof-label {
    display: block;
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 2px;
}
@media (max-width: 600px) {
    .social-proof-bar .container {
        gap: 1rem !important;
    }
    .proof-stat { min-width: 100px; }
    .proof-number { font-size: 1.5rem; }
    .proof-label { font-size: 0.78rem; }
}

/* --- AI Product Recommendation Quiz --- */
.ai-quiz-section {
    padding: 3rem 0;
    background: linear-gradient(180deg, #f0f7ff 0%, #fff 100%);
}
.quiz-subtitle {
    color: #64748b;
    font-size: 1.05rem;
    margin-bottom: 2rem;
}
.ai-quiz-container {
    max-width: 680px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,90,156,0.08);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}
.quiz-step {
    display: none;
    animation: quizFadeIn 0.4s cubic-bezier(.4,0,.2,1);
}
.quiz-step.active {
    display: block;
}
@keyframes quizFadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
.quiz-question {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1.5rem;
    text-align: center;
}
.quiz-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}
.quiz-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 0.95rem;
    font-weight: 500;
    color: #334155;
    min-width: 120px;
    font-family: inherit;
}
.quiz-option:hover {
    border-color: #005A9C;
    background: #f0f7ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,90,156,0.12);
}
.quiz-option:active {
    transform: scale(0.97);
}
.quiz-option.selected {
    border-color: #005A9C;
    background: #005A9C;
    color: #fff;
}
.quiz-option.selected .quiz-emoji {
    filter: none;
}
.quiz-emoji {
    font-size: 1.8rem;
    line-height: 1;
}

/* Quiz progress bar */
.quiz-progress {
    height: 4px;
    background: #e2e8f0;
    border-radius: 4px;
    margin-top: 1.5rem;
    overflow: hidden;
}
.quiz-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #005A9C, #FF6B35);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

/* Quiz result */
.quiz-result-card {
    text-align: center;
    padding: 1rem 0;
}
.quiz-thinking {
    padding: 2rem;
}
.thinking-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 1rem;
}
.thinking-dots span {
    width: 12px;
    height: 12px;
    background: #005A9C;
    border-radius: 50%;
    animation: thinkBounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
.quiz-recommendation {
    text-align: left;
}
.quiz-rec-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #005A9C;
    margin-bottom: 0.5rem;
}
.quiz-rec-subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}
.quiz-rec-products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.quiz-rec-product {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #f8fafc;
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}
.quiz-rec-product:hover {
    border-color: #005A9C;
    box-shadow: 0 2px 12px rgba(0,90,156,0.1);
    transform: translateY(-2px);
}
.quiz-rec-product-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}
.quiz-rec-product-reason {
    font-size: 0.82rem;
    color: #64748b;
}
.quiz-rec-product-price {
    font-size: 0.9rem;
    font-weight: 600;
    color: #FF6B35;
    margin-top: 0.4rem;
}
.quiz-rec-cta {
    display: inline-block;
    background: #FF6B35;
    color: #fff;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.quiz-rec-cta:hover {
    background: #E55A2B;
    transform: translateY(-1px);
}
.quiz-restart {
    display: inline-block;
    margin-top: 1rem;
    background: none;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    color: #64748b;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
}
.quiz-restart:hover {
    border-color: #005A9C;
    color: #005A9C;
}

@media (max-width: 600px) {
    .ai-quiz-container { padding: 1.25rem; }
    .quiz-option { min-width: 100px; padding: 0.75rem 0.75rem; font-size: 0.85rem; }
    .quiz-emoji { font-size: 1.4rem; }
    .quiz-question { font-size: 1.1rem; }
    .quiz-rec-products { grid-template-columns: 1fr; }
}

/* --- Lazy iframe placeholder --- */
.iframe-lazy-placeholder {
    background: #f0f4f8;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    cursor: pointer;
    transition: background 0.3s;
    border: 2px dashed #cbd5e1;
}
.iframe-lazy-placeholder:hover {
    background: #e2e8f0;
}
.iframe-lazy-placeholder span {
    color: #64748b;
    font-size: 1rem;
    font-weight: 500;
}

/* --- View Transitions (for supported browsers) --- */
@view-transition {
    navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.25s;
}
.header { view-transition-name: header; }
.hero-section { view-transition-name: hero; }

/* --- Smart notification toast --- */
.ai-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 9999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}
.ai-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
