/* ==========================================================
   PLANTILLA E-COMMERCE — Estilos Base
   Reset, tipografía, elementos HTML fundamentales
   ========================================================== */

/* ── Reset y box-sizing ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* ── Tipografía ── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-text-heading);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p {
    margin-bottom: var(--space-md);
    line-height: var(--line-height-relaxed);
}

a {
    color: var(--color-accent-dark);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent);
}

a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

strong, b {
    font-weight: var(--font-weight-semibold);
}

small {
    font-size: var(--text-sm);
}

/* ── Imágenes ── */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Listas ── */
ul, ol {
    list-style: none;
}

/* ── Formularios ── */
input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

input:focus, textarea:focus, select:focus {
    outline: none;
}

/* ── Selección de texto ── */
::selection {
    background-color: var(--color-accent-soft);
    color: var(--color-primary);
}

/* ── Scrollbar personalizado ── */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

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

/* ── Utilidades de texto ── */
.text-accent { color: var(--color-accent); }
.text-muted { color: var(--color-text-light); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-uppercase { text-transform: uppercase; letter-spacing: var(--letter-spacing-wider); }
.text-italic { font-style: italic; }

.font-heading { font-family: var(--font-heading); }
.font-body { font-family: var(--font-body); }

/* ── Utilidades de espaciado ── */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mt-5 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.mb-5 { margin-bottom: var(--space-xl); }

/* ── Contenedor ── */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
}

.container-narrow {
    max-width: var(--container-md);
}

.container-wide {
    max-width: var(--container-2xl);
}

/* ── Sección ── */
.section {
    padding: var(--space-3xl) 0;
}

.section-sm {
    padding: var(--space-2xl) 0;
}

.section-warm {
    background-color: var(--color-bg-warm);
}

.section-dark {
    background-color: var(--color-bg-dark);
    color: var(--color-text-on-dark);
}

/* ── Título de sección ── */
.section-title {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.section-title h2 {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-sm);
    position: relative;
    display: inline-block;
}

.section-title h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background-color: var(--color-accent);
}

.section-title p {
    color: var(--color-text-light);
    font-size: var(--text-md);
    max-width: 600px;
    margin: var(--space-md) auto 0;
}

/* ── Visualmente oculto (accesibilidad) ── */
.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;
}

/* ── Lazy loading de imágenes ── */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity var(--transition-slow);
}

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

/* Fix para que las imágenes lazy carguen sin JS */
img[loading="lazy"] {
    opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
    h4 { font-size: var(--text-lg); }
    
    .section {
        padding: var(--space-2xl) 0;
    }
    
    .container {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }
}

@media (max-width: 480px) {
    html {
        font-size: 15px;
    }
    
    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }
}
