/* ---------- Reset ---------------------------------------------------- */

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol {
    margin: 0;
    padding: 0;
}

ul[class], ol[class] { list-style: none; }

img, picture, svg, video {
    display: block;
    max-width: 100%;
    height: auto;
}

input, button, textarea, select { font: inherit; color: inherit; }

table {
    border-collapse: collapse;
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Documento ------------------------------------------------ */

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

/* ---------- Tipografia ----------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
    line-height: var(--leading-tight);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    text-wrap: balance;
}

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-base); }

@media (max-width: 767px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
}

p { max-width: 70ch; }

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

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

/* ---------- Enlaces --------------------------------------------------- */

a {
    color: var(--color-text-link);
    text-decoration: underline;
    text-underline-offset: 2px;
    border-radius: var(--radius-sm);
}

a:hover { color: var(--color-primary-active); }

/* ---------- Foco ----------------------------------------------------- */

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

:focus:not(:focus-visible) { outline: none; }

/* ---------- Skip link ------------------------------------------------ */

.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-toast);
    padding: var(--space-3) var(--space-4);
    background-color: var(--color-primary);
    color: var(--color-on-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: var(--weight-semibold);
    transform: translateY(-200%);
    transition: transform var(--duration-fast) var(--ease);
}

.skip-link:focus {
    transform: translateY(0);
    color: var(--color-on-primary);
}

/* ---------- Utilidades de 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;
}

.sr-only-focusable:focus,
.sr-only-focusable:focus-within {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

[hidden] { display: none !important; }

/* ---------- Layout base ------------------------------------------------ */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--space-4);
}

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

@media (min-width: 768px) {
    .container { padding-inline: var(--space-6); }
}

.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Helpers de flujo ------------------------------------------- */

.stack > * + * { margin-block-start: var(--space-4); }
.stack--sm > * + * { margin-block-start: var(--space-2); }
.stack--lg > * + * { margin-block-start: var(--space-8); }

.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}

.grid-auto {
    display: grid;
    gap: var(--space-6);
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}
