/* ========================================
   VERCEL DESIGN GUIDELINES IMPLEMENTATION
   UX/UI Enhancements - World-class Standards
   ======================================== */

/* ==========================================
   1. ACCESSIBILITY & FOCUS STATES
   ========================================== */

/* Focus-visible para evitar distraer usuarios de mouse/touch */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #59329F;
    outline-offset: 4px;
    border-radius: 4px;
}

/* Focus states específicos para botones y links */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #59329F;
    outline-offset: 4px;
    box-shadow: 0 0 0 6px rgba(89, 50, 159, 0.15);
}

.button:focus-visible,
.header-cta:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25),
                0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ==========================================
   2. HIT TARGETS & TOUCH OPTIMIZATION
   ========================================== */

/* Mínimo 44px para elementos interactivos en móvil */
@media (max-width: 768px) {
    a, button, input, select, textarea,
    [role="button"], [tabindex]:not([tabindex="-1"]) {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .button, .header-cta {
        min-height: 48px;
        padding: 12px 24px;
    }
}

/* Hit targets generosos - "forgiving interactions" */
a, button, [role="button"] {
    position: relative;
}

a::before,
button::before,
[role="button"]::before {
    content: '';
    position: absolute;
    inset: -8px;
    z-index: -1;
}

/* Prevenir double-tap zoom en controles */
button, input, select, textarea, a {
    touch-action: manipulation;
}

/* ==========================================
   3. TYPOGRAPHY ENHANCEMENTS
   ========================================== */

/* Prevenir viudas y huérfanas */
h1, h2, h3, h4, h5, h6, p {
    text-wrap: pretty;
    orphans: 2;
    widows: 2;
}

/* Números tabulares para comparaciones */
.toc-chapter-number,
.price,
.stat-number {
    font-variant-numeric: tabular-nums;
}

/* Kerning óptimo */
h1, h2, h3, h4, h5, h6 {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   4. CONTRAST & INTERACTIVE STATES
   ========================================== */

/* Aumentar contraste en interacciones */
.button:hover,
.header-cta:hover {
    filter: brightness(1.1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.button:active,
.header-cta:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

a:hover {
    opacity: 0.85;
}

/* Estados visuales claros para cards */
.testimonial-card,
.toc-item {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.testimonial-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

/* ==========================================
   5. ANIMATIONS & MOTION
   ========================================== */

/* Respetar prefers-reduced-motion */
@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;
    }

    .button:hover,
    .header-cta:hover,
    .testimonial-card:hover {
        transform: none !important;
    }
}

/* Animaciones optimizadas con GPU */
.button,
.header-cta,
.testimonial-card,
.toc-item {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Transiciones suaves y naturales */
.button,
.header-cta,
a,
.testimonial-card,
.toc-item {
    transition-property: transform, box-shadow, opacity, filter;
    transition-duration: 0.25s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================
   6. VISUAL DESIGN REFINEMENTS
   ========================================== */

/* Sombras en capas (layered shadows) */
.testimonial-card {
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.06);
}

.button, .header-cta {
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(89, 50, 159, 0.2);
}

/* Bordes nítidos con sub-pixel rendering */
.testimonial-card,
.toc-item,
.button,
.header-cta,
input,
textarea {
    border-radius: 12px;
    transform: translateZ(0);
}

/* Radios concéntricos anidados */
.testimonial-avatar {
    border-radius: 50%;
}

.testimonial-avatar img {
    border-radius: 50%;
}

/* ==========================================
   7. LAYOUT & SPACING OPTIMIZATION
   ========================================== */

/* Alineamiento óptico */
.section-intro h2,
.toc-header h2,
.final-cta-card h2 {
    margin-block-start: -0.1em; /* Compensa espacio visual del tipo */
}

/* Balance de contraste en elementos lado a lado */
.toc-grid {
    gap: clamp(24px, 4vw, 48px);
}

.top-cards-row {
    gap: clamp(20px, 3vw, 40px);
}

/* Layouts flexibles y responsivos */
.toc-grid,
.top-cards-row,
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

/* ==========================================
   8. SAFE AREAS & RESPONSIVE DESIGN
   ========================================== */

/* Respetar safe areas para notches/insets */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

header {
    padding-top: max(1rem, env(safe-area-inset-top));
}

/* ==========================================
   9. COLOR SYSTEM ENHANCEMENTS
   ========================================== */

/* Consistencia de matiz */
:root {
    --primary-hue: 270;
    --primary-sat: 50%;
    --primary-light: 40%;

    --color-primary: hsl(var(--primary-hue), var(--primary-sat), var(--primary-light));
    --color-primary-dark: hsl(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) - 10%));
    --color-primary-light: hsl(var(--primary-hue), var(--primary-sat), calc(var(--primary-light) + 10%));
}

/* Indicadores de estado redundantes (no solo color) */
.testimonial-rating i {
    position: relative;
}

.testimonial-rating i::before {
    content: attr(aria-label);
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================
   10. PERFORMANCE OPTIMIZATIONS
   ========================================== */

/* GPU-accelerated properties */
.button,
.header-cta,
.testimonial-card {
    transform: translate3d(0, 0, 0);
}

/* Optimizar repaint en scroll */
.hero-section,
.cards-section,
.toc-section,
.authors-section,
.final-cta-section {
    contain: layout style paint;
}

/* Contenido above-the-fold crítico */
.hero-section img {
    content-visibility: auto;
}

img[loading="lazy"] {
    content-visibility: auto;
    contain-intrinsic-size: 1px 400px;
}
