/* ============================================================
   DESIGN SYSTEM — BASE
   Reset, body, tipografía base, focus, scrollbar.
   ============================================================ */

/* ---- Box sizing universal ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ---- Reset de margenes ---- */
html, body, h1, h2, h3, h4, h5, h6, p,
ul, ol, li, dl, dd, blockquote, figure {
    margin: 0;
    padding: 0;
}

/* ---- HTML & Body ---- */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--bg-page);
    min-height: 100vh;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ---- Tipografía base de encabezados ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

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

p {
    color: var(--text-secondary);
    line-height: var(--leading-normal);
}

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

a:hover {
    color: var(--primary-600);
    text-decoration: underline;
}

/* ---- Listas: respetar la semántica pero limpiar estilos por defecto ---- */
ul, ol {
    padding-left: var(--space-5);
}

/* ---- Imágenes responsive por defecto ---- */
img, svg, video {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ---- Form elements: heredan tipografía ---- */
button, input, select, textarea {
    font: inherit;
    color: inherit;
}

/* ---- Tablas ---- */
table {
    border-collapse: collapse;
    width: 100%;
}

/* ---- Code & pre ---- */
code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

/* ---- Focus visible: solo cuando navega por teclado (no al click) ---- */
:focus {
    outline: none;
}

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

/* ---- Selección de texto ---- */
::selection {
    background-color: var(--primary-200);
    color: var(--primary-900);
}

html[data-theme="dark"] ::selection,
html:not([data-theme="light"]) ::selection {
    background-color: var(--primary-700);
    color: var(--neutral-0);
}

/* ---- Scrollbar (WebKit/Blink) ---- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--neutral-300);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-page);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-400);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb,
html:not([data-theme="light"]) ::-webkit-scrollbar-thumb {
    background: var(--neutral-700);
    border-color: var(--bg-page);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
html:not([data-theme="light"]) ::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-600);
}

/* ---- Scrollbar (Firefox) ---- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--neutral-300) var(--bg-page);
}

html[data-theme="dark"] *,
html:not([data-theme="light"]) * {
    scrollbar-color: var(--neutral-700) var(--bg-page);
}

/* ---- Bootstrap Icons: tamaño base y alineación ---- */
i.bi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--icon-md);
    line-height: 1;
    vertical-align: -2px;
}

/* ---- Hr ---- */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-6) 0;
}

/* ---- Respeto de animaciones reducidas ---- */
@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;
    }
}
