/*
Theme Name: SmartMag Child
Description: Tema filho do SmartMag otimizado para Google Discover e Core Web Vitals
Template: smart-mag
Version: 1.0.0
*/

/* ========================================
   OTIMIZAÇÕES PARA CORE WEB VITALS
   ======================================== */

/* Melhora o Cumulative Layout Shift (CLS) */
img, video, iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Reserva espaço para imagens para evitar layout shift */
.post-thumbnail,
.featured-image {
    aspect-ratio: 16/9;
    overflow: hidden;
    background-color: #f5f5f5;
}

.post-thumbnail img,
.featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Otimizações para Largest Contentful Paint (LCP) */
.main-content {
    contain: layout style paint;
}

.post-title {
    font-display: swap;
    line-height: 1.3;
    margin: 0 0 1rem;
}

.post-content {
    line-height: 1.6;
    font-display: swap;
}

/* Melhora o First Input Delay (FID) */
button, 
input[type="submit"], 
input[type="button"],
.btn {
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Otimizações para dispositivos móveis */
@media (max-width: 768px) {
    .site-header {
        position: sticky;
        top: 0;
        z-index: 999;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .post-title {
        font-size: 1.5rem;
        line-height: 1.2;
    }
    
    .post-thumbnail {
        aspect-ratio: 4/3;
        margin-bottom: 1rem;
    }
}

/* Lazy loading placeholder */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Otimizações para fontes */
@font-face {
    font-display: swap;
}

/* Melhora a performance de animações */
.animated-element {
    will-change: transform;
    transform: translateZ(0);
}

/* Remove animações em dispositivos com preferência por movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Otimizações para impressão */
@media print {
    .site-header,
    .site-footer,
    .sidebar,
    .navigation,
    .comments-area {
        display: none !important;
    }
    
    .main-content {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* ========================================
   MELHORIAS ESPECÍFICAS PARA GOOGLE DISCOVER
   ======================================== */

/* Garante que imagens tenham qualidade adequada */
.post-thumbnail img,
.featured-image img,
.wp-post-image {
    min-width: 300px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Melhora a legibilidade dos títulos */
.post-title,
.entry-title {
    font-weight: 600;
    color: #1a1a1a;
    text-decoration: none;
    word-wrap: break-word;
    hyphens: auto;
}

.post-title:hover,
.entry-title:hover {
    color: #0073aa;
    text-decoration: none;
}

/* Melhora a apresentação do conteúdo */
.post-excerpt,
.entry-summary {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.post-meta {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.post-meta a {
    color: #0073aa;
    text-decoration: none;
}

.post-meta a:hover {
    text-decoration: underline;
}

/* Melhora a apresentação de categorias e tags */
.post-categories,
.post-tags {
    margin: 0.5rem 0;
}

.post-categories a,
.post-tags a {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #f0f0f0;
    color: #333;
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.8rem;
    margin: 0 0.25rem 0.25rem 0;
}

.post-categories a:hover,
.post-tags a:hover {
    background: #0073aa;
    color: #fff;
}

/* ========================================
   OTIMIZAÇÕES ADICIONAIS DE PERFORMANCE
   ======================================== */

/* Melhora o rendering de listas */
.post-list,
.widget ul {
    contain: layout;
}

/* Otimiza elementos com scroll */
.scrollable-content {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Melhora a performance de hover em dispositivos touch */
@media (hover: hover) {
    .hover-effect:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
}

/* Otimizações para dark mode */
@media (prefers-color-scheme: dark) {
    .auto-dark {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .auto-dark .post-title,
    .auto-dark .entry-title {
        color: #fff;
    }
    
    .auto-dark .post-excerpt,
    .auto-dark .entry-summary {
        color: #ccc;
    }
}

/* Melhora a acessibilidade */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles melhorados */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Melhora a performance de grid layouts */
.grid-layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (max-width: 768px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }
}

/* Otimizações para carregamento de conteúdo */
.loading-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

/* Melhora a performance de transições */
.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Otimizações para elementos sticky */
.sticky-element {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* ========================================
   UTILITIES PARA PERFORMANCE
   ======================================== */

/* Classes utilitárias para otimização */
.contain-layout { contain: layout; }
.contain-style { contain: style; }
.contain-paint { contain: paint; }
.contain-size { contain: size; }
.contain-strict { contain: strict; }

.will-change-transform { will-change: transform; }
.will-change-opacity { will-change: opacity; }
.will-change-scroll { will-change: scroll-position; }

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Otimizações para imagens responsivas */
.responsive-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
}

/* Melhora a performance de elementos flexbox */
.flex-optimized {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.flex-optimized > * {
    flex: 1 1 300px;
    min-width: 0;
}

/* ========================================
   CRITICAL CSS INLINE
   ======================================== */

/* CSS crítico que deve ser carregado inline */
.critical-above-fold {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
}

.critical-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 1rem 0;
}

.critical-content {
    flex: 1;
    padding: 2rem 0;
}

.critical-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 1rem;
    color: #1a1a1a;
}

.critical-excerpt {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #666;
    margin: 0 0 1.5rem;
}

/* Responsive design otimizado */
@media (max-width: 1200px) {
    .critical-title { font-size: 1.8rem; }
}

@media (max-width: 768px) {
    .critical-title { font-size: 1.5rem; }
    .critical-excerpt { font-size: 1rem; }
    .critical-content { padding: 1rem 0; }
}

@media (max-width: 480px) {
    .critical-title { font-size: 1.3rem; }
    .critical-header { padding: 0.5rem 0; }
}

