/* Modern Purple Tech - CSS Ultra-Otimizado para Mobile Performance */

:root {
  --primary-purple: #8B5CF6;
  --light-purple: #A78BFA;
  --dark-purple: #6D28D9;
  --bg-purple: #F3F4F6;
  --text-dark: #1F2937;
  --text-light: #6B7280;
  --white: #FFFFFF;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
  
  /* Dimensões fixas para evitar CLS */
  --card-min-height: 140px;
  --card-padding: 20px;
  --title-height: 2.8rem;
  --meta-height: 1.2rem;
  --excerpt-height: 3.6rem;
  --badge-height: 1.5rem;
  --button-height: 2.5rem;
}

/* MOBILE FIRST: Desabilitar animações por padrão */
@media (max-width: 767px) {
  * {
    animation: none !important;
    transition: none !important;
  }
  
  /* Apenas permitir animações essenciais */
  .essential-animation {
    animation: fadeIn 0.3s ease !important;
  }
}

/* Performance Optimizations */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Desabilitar smooth scrolling em mobile */
@media (max-width: 767px) {
  html {
    scroll-behavior: auto;
  }
}

/* Layout Principal */
.tech-home {
  background: transparent;
  min-height: 100vh;
  padding: 0;
  contain: layout;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Grid Mobile First */
.sections-grid {
  display: block; /* Simples block layout para mobile */
  margin-bottom: 40px;
}

@media (min-width: 768px) {
  .sections-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
}

/* Seções simplificadas para mobile */
.cpt-section {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: var(--card-padding);
  box-shadow: var(--shadow);
  border: 1px solid rgba(139, 92, 246, 0.1);
  min-height: 280px;
  margin-bottom: 20px;
  /* Remover will-change para mobile */
}

@media (min-width: 768px) {
  .cpt-section {
    margin-bottom: 0;
    will-change: transform;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .cpt-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
}

/* Headers das Seções */
.section-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(139, 92, 246, 0.1);
  min-height: 56px;
}

.section-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-purple), var(--light-purple));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  color: white;
  font-weight: bold;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.section-title {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
  line-height: 1.3;
  flex: 1;
}

/* Container de Posts */
.posts-container {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cards dos Posts - Mobile First */
.post-card {
  background: #FEFEFE;
  border-radius: 10px;
  padding: 0;
  border-left: 4px solid var(--primary-purple);
  border: 1px solid rgba(139, 92, 246, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: var(--card-min-height);
  /* Remover transform e will-change para mobile */
}

@media (min-width: 768px) {
  .post-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
    transform: translateZ(0);
  }
  
  .post-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
    border-left-color: var(--dark-purple);
  }
}

/* Variações de cores - apenas para desktop */
@media (min-width: 768px) {
  .post-card--urgent:hover {
    border-left-color: #DC2626;
  }
  
  .post-card--crypto:hover {
    border-left-color: #D97706;
  }
  
  .post-card--lottery:hover {
    border-left-color: #059669;
  }
}

.post-card--urgent {
  border-left-color: #EF4444;
}

.post-card--crypto {
  border-left-color: #F59E0B;
}

.post-card--lottery {
  border-left-color: #10B981;
}

.post-card--blog {
  border-left-color: var(--primary-purple);
}

/* Conteúdo do Post */
.post-content {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(var(--card-min-height) - 2px);
}

/* Título otimizado */
.post-title {
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
  min-height: var(--title-height);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-title-text {
  display: block;
  text-overflow: ellipsis;
  overflow: hidden;
  hyphens: auto;
  word-wrap: break-word;
}

.post-title a,
.post-link {
  color: var(--text-dark);
  text-decoration: none;
  display: block;
  height: 100%;
  /* Remover transition para mobile */
}

@media (min-width: 768px) {
  .post-title a,
  .post-link {
    transition: color 0.2s ease;
  }
  
  .post-title a:hover,
  .post-title a:focus {
    color: var(--primary-purple);
  }
}

/* Meta informações */
.post-meta {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 8px;
  line-height: 1.3;
  min-height: var(--meta-height);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.post-author::after {
  content: ' • ';
  margin: 0 4px;
}

/* Excerpt */
.post-excerpt {
  color: var(--text-light);
  font-size: 0.85rem;
  line-height: 1.5;
  min-height: var(--excerpt-height);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 8px;
}

.post-excerpt p {
  margin: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  hyphens: auto;
  word-wrap: break-word;
}

/* Badge simplificado para mobile */
.urgent-badge {
  background: #EF4444; /* Gradiente removido para mobile */
  color: white;
  padding: 3px 8px;
  border-radius: 16px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  height: var(--badge-height);
  line-height: calc(var(--badge-height) - 6px);
}

@media (min-width: 768px) {
  .urgent-badge {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    animation: pulse 2s infinite;
  }
}

/* Containers de preços */
.crypto-price-container,
.lottery-numbers-container {
  min-height: 28px;
  display: flex;
  align-items: center;
  margin-top: auto;
}

.crypto-price,
.lottery-numbers {
  background: var(--primary-purple); /* Gradiente removido para mobile */
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@media (min-width: 768px) {
  .crypto-price,
  .lottery-numbers {
    background: linear-gradient(135deg, var(--primary-purple), var(--dark-purple));
    transition: transform 0.3s ease;
  }
  
  .crypto-price:hover,
  .lottery-numbers:hover {
    transform: scale(1.05);
  }
}

/* Placeholders otimizados */
.crypto-price--placeholder,
.lottery-numbers--placeholder {
  background: #E5E7EB;
  color: transparent;
  min-width: 80px;
  height: 20px;
}

@media (min-width: 768px) {
  .crypto-price--placeholder,
  .lottery-numbers--placeholder {
    animation: shimmer 2s infinite;
  }
}

/* Footer das seções */
.section-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(139, 92, 246, 0.1);
  min-height: calc(var(--button-height) + 32px);
  display: flex;
  align-items: center;
}

.section-footer--center {
  justify-content: center;
}

/* Botões simplificados para mobile */
.view-all-btn {
  display: inline-block;
  background: var(--primary-purple); /* Gradiente removido para mobile */
  color: white;
  padding: 8px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  height: var(--button-height);
  line-height: calc(var(--button-height) - 16px);
  white-space: nowrap;
  min-width: 120px;
  position: relative;
  overflow: hidden;
}

@media (min-width: 768px) {
  .view-all-btn {
    background: linear-gradient(135deg, var(--primary-purple), var(--dark-purple));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .view-all-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
  }
  
  .view-all-btn:hover::before {
    left: 100%;
  }
  
  .view-all-btn:hover,
  .view-all-btn:focus {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    color: white;
  }
}

/* Seção de Posts do Blog */
.posts-section {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: var(--card-padding);
  box-shadow: var(--shadow);
  border: 1px solid rgba(139, 92, 246, 0.1);
  min-height: 400px;
}

.posts-grid {
  display: block; /* Block layout para mobile */
  margin-top: 16px;
  min-height: 280px;
}

@media (min-width: 768px) {
  .posts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .posts-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
}

/* Placeholders simplificados */
.post-card--placeholder {
  background: #F9FAFB;
  pointer-events: none;
  user-select: none;
  opacity: 0.6;
}

.placeholder-title,
.placeholder-meta,
.placeholder-excerpt {
  background: #E5E7EB;
  border-radius: 4px;
  color: transparent;
  display: block;
}

@media (min-width: 768px) {
  .placeholder-title,
  .placeholder-meta,
  .placeholder-excerpt {
    background: linear-gradient(90deg, #E5E7EB 25%, #D1D5DB 50%, #E5E7EB 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
  }
}

.placeholder-title {
  height: 1.1rem;
  margin-bottom: 8px;
  width: 85%;
}

.placeholder-meta {
  height: 0.8rem;
  width: 60%;
  margin-bottom: 8px;
}

.placeholder-meta--author {
  width: 40%;
}

.placeholder-meta--date {
  width: 30%;
}

.placeholder-excerpt {
  height: 0.85rem;
  width: 95%;
  margin-bottom: 4px;
}

.placeholder-badge {
  height: var(--badge-height);
  width: 60px;
  background: #FCA5A5;
  border-radius: 16px;
  margin-bottom: 8px;
}

@media (min-width: 768px) {
  .placeholder-badge {
    background: linear-gradient(90deg, #FCA5A5 25%, #F87171 50%, #FCA5A5 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
  }
}

/* Animações apenas para desktop */
@media (min-width: 768px) {
  @keyframes shimmer {
    0% {
      background-position: -200% 0;
    }
    100% {
      background-position: 200% 0;
    }
  }
  
  @keyframes pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.8;
    }
  }
}

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

/* Floating Thumbnail - Desabilitado para mobile */
@media (max-width: 767px) {
  #floating-thumbnail-preview {
    display: none !important;
  }
}

#floating-thumbnail-preview {
  position: fixed;
  top: var(--y, 0);
  left: var(--x, 0);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  border: 1px solid rgba(139, 92, 246, 0.1);
  max-width: 200px;
  will-change: transform, opacity;
}

#floating-thumbnail-preview.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#floating-thumbnail-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  transition: opacity 0.2s ease;
}

#floating-thumbnail-preview img:not([src]) {
  opacity: 0;
}

/* Lazy Loading otimizado */
img[loading="lazy"] {
  opacity: 0;
}

@media (min-width: 768px) {
  img[loading="lazy"] {
    transition: opacity 0.3s ease;
  }
}

img[loading="lazy"].loaded {
  opacity: 1;
}

/* Responsive Design - Mobile First */
@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }
  
  .sections-grid {
    gap: 24px;
  }
  
  .posts-grid {
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .sections-grid {
    gap: 32px;
  }
  
  .posts-grid {
    gap: 24px;
  }
  
  .container {
    padding: 0 32px;
  }
}

/* Ocultação de containers vazios */
.lottery-numbers-container:empty,
.crypto-price-container:empty {
  visibility: hidden;
}

.lottery-numbers-container > .lottery-numbers.lottery-numbers--placeholder,
.crypto-price-container > .crypto-price.crypto-price--placeholder {
  visibility: hidden;
}

/* Containment otimizado */
@media (min-width: 768px) {
  .post-card,
  .cpt-section {
    contain: layout;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --primary-purple: #4C1D95;
    --text-dark: #000000;
    --text-light: #374151;
  }
  
  .post-card {
    border: 2px solid var(--primary-purple);
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-purple: #1F2937;
    --white: #111827;
    --text-dark: #F9FAFB;
    --text-light: #D1D5DB;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  }
  
  .post-card {
    background: #1F2937;
    border-color: rgba(139, 92, 246, 0.3);
  }
  
  .cpt-section {
    background: #1F2937;
    border-color: rgba(139, 92, 246, 0.3);
  }
  
  .posts-section {
    background: #1F2937;
    border-color: rgba(139, 92, 246, 0.3);
  }
  
  #floating-thumbnail-preview {
    background: #1F2937;
    border-color: rgba(139, 92, 246, 0.3);
  }
}

/* Print Styles */
@media print {
  .view-all-btn,
  #floating-thumbnail-preview {
    display: none !important;
  }
  
  .post-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .sections-grid,
  .posts-grid {
    display: block;
  }
  
  .cpt-section {
    margin-bottom: 20px;
    page-break-inside: avoid;
  }
}

/* Focus Styles */
.post-link:focus,
.view-all-btn:focus {
  outline: 2px solid var(--primary-purple);
  outline-offset: 2px;
}

/* Loading States */
.posts-container:empty::before {
  content: 'Carregando posts...';
  display: block;
  text-align: center;
  color: var(--text-light);
  padding: 40px;
  font-style: italic;
}

/* Error States */
.posts-container.error::before {
  content: 'Erro ao carregar posts. Tente novamente mais tarde.';
  display: block;
  text-align: center;
  color: #EF4444;
  padding: 40px;
  font-style: italic;
}

/* Smooth Scrolling apenas para desktop */
@media (min-width: 768px) {
  html {
    scroll-behavior: smooth;
  }
}

/* Selection Styles */
::selection {
  background: var(--light-purple);
  color: white;
}

::-moz-selection {
  background: var(--light-purple);
  color: white;
}

/* Ocultar headers problemáticos */
.cs-entry__header.cs-entry__header-split {
  display: none !important;
}

/* OTIMIZAÇÕES ESPECÍFICAS PARA MOBILE PERFORMANCE */

/* Reduzir repaints em mobile */
@media (max-width: 767px) {
  .post-card,
  .cpt-section,
  .view-all-btn {
    backface-visibility: hidden;
    perspective: 1000px;
  }
  
  /* Simplificar box-shadows para mobile */
  .post-card,
  .cpt-section,
  .view-all-btn {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  /* Remover border-radius complexos em mobile */
  .post-card,
  .cpt-section {
    border-radius: 8px;
  }
  
  /* Simplificar gradientes */
  .section-icon {
    background: var(--primary-purple);
  }
  
  /* Otimizar tipografia */
  .post-title,
  .section-title {
    text-rendering: optimizeSpeed;
  }
  
  /* Reduzir complexidade de clamps */
  .post-title {
    font-size: 1rem;
  }
  
  .section-title {
    font-size: 1.2rem;
  }
}

/* Otimizações de GPU para mobile */
@media (max-width: 767px) {
  .post-card,
  .cpt-section {
    transform: translate3d(0, 0, 0);
  }
}