/* Custom CSS for VelocidadLectora */

/* Font Imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* CSS Variables for consistent theming */
:root {
  --primary-color: #2563eb;
  --secondary-color: #1e40af;
  --accent-color: #f59e0b;
  --reading-color: #10b981;
  --success-color: #059669;
  --warning-color: #d97706;
  --error-color: #dc2626;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 300ms ease-in-out;
  --border-radius: 0.75rem;
}

/* Dark mode variables */
[data-theme="dark"] {
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --border-color: #374151;
}

/* Base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  scroll-behavior: smooth;
}

/* Reading font optimization */
.font-reading {
  font-family: 'Crimson Text', Georgia, 'Times New Roman', serif;
  line-height: 1.8;
  letter-spacing: 0.01em;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Reading text styles */
#readingText {
  font-size: 1.125rem;
  line-height: 2;
  color: var(--text-primary);
  max-width: none;
  text-align: justify;
  hyphens: auto;
  word-spacing: 0.1em;
}

#readingText p {
  margin-bottom: 1.5rem;
  text-indent: 2rem;
}

#readingText p:first-child {
  text-indent: 0;
}

/* Timer styles */
#timer {
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* Button animations */
.btn-pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .7;
  }
}

/* Card hover effects */
.text-card {
  transition: all var(--transition-normal);
  cursor: pointer;
}

.text-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Progress animation */
.progress-bar {
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color) 100%);
  height: 8px;
  border-radius: 4px;
  transition: width var(--transition-normal);
}

/* Modal animations */
.modal-enter {
  animation: modalEnter 0.3s ease-out;
}

.modal-exit {
  animation: modalExit 0.3s ease-in;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalExit {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
  }
}

/* Results animation */
.result-card {
  animation: slideInUp 0.6s ease-out;
}

.result-card:nth-child(2) {
  animation-delay: 0.1s;
}

.result-card:nth-child(3) {
  animation-delay: 0.2s;
}

.result-card:nth-child(4) {
  animation-delay: 0.3s;
}

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

/* Number counter animation */
.counter {
  font-variant-numeric: tabular-nums;
}

/* Loading spinner */
.spinner {
  border: 4px solid var(--bg-secondary);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Text difficulty badges */
.difficulty-easy {
  background-color: #d1fae5;
  color: #065f46;
}

.difficulty-intermedio {
  background-color: #fef3c7;
  color: #92400e;
}

.difficulty-avanzado {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Dark mode difficulty badges */
.dark .difficulty-easy {
  background-color: #064e3b;
  color: #a7f3d0;
}

.dark .difficulty-intermedio {
  background-color: #78350f;
  color: #fcd34d;
}

.dark .difficulty-avanzado {
  background-color: #7f1d1d;
  color: #fca5a5;
}

/* Category badges */
.category-badge {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  white-space: nowrap;
}

/* Chart container */
.chart-container {
  position: relative;
  height: 300px;
  margin: 1rem 0;
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .bg-gray-50, .bg-gray-800 {
    background: white !important;
  }
}

/* Mobile optimizations */
@media (max-width: 768px) {
  #readingText {
    font-size: 1rem;
    line-height: 1.75;
  }
  
  .timer {
    font-size: 2rem;
  }
  
  .modal-content {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
  }
}

/* Focus styles for accessibility */
button:focus,
select:focus,
input:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-secondary: #000000;
  }
  
  [data-theme="dark"] {
    --border-color: #ffffff;
    --text-secondary: #ffffff;
  }
}

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

/* Text selection */
::selection {
  background-color: var(--primary-color);
  color: white;
}

/* Custom utilities */
.text-gradient {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-effect {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.dark .glass-effect {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* AdSense optimization */
.adsense-container {
  margin: 2rem 0;
  text-align: center;
}

.adsense-container ins {
  display: inline-block;
  text-decoration: none;
}

/* Performance optimizations */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* GPU acceleration for smooth animations */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}
