/* =========================================================
   Base · Reset · Tipografía · Estilo global para KIVOR
   ========================================================= */

/* Fuente display sobria y legible (Urbanist) */
@import url('https://fonts.googleapis.com/css2?family=Urbanist:wght@400;500;600;700;800&display=swap');

/* ---------------- Reset moderno (inspirado en moderncss.dev) ---------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html:focus-within {
    scroll-behavior: smooth;
}

html,
body {
    height: 100%;
    overflow-x: hidden;
}

/* Mejora de colorimetría de scrollbars nativa cuando el UA lo soporte */
:root {
    color-scheme: light dark;
}

/* ---------------- Body / tipografía ---------------- */
body {
    font-family: 'Urbanist', var(--font-sans);
    font-size: var(--step-0);
    line-height: 1.65;
    letter-spacing: 0.005em;
    color: var(--text-900);
    background: var(--surface-0);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    hyphens: auto;
    position: relative;
    z-index: 0;
}

/* Medios */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

svg {
    fill: currentColor;
}

/* Formularios básicos (se estilizan en components.css) */
input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
    background-color: transparent;
    border: none;
    outline: none;
}

/* ---------------- Enlaces ---------------- */
a {
    color: var(--brand-500);
    text-decoration: underline;
    text-underline-offset: .18em;
    text-decoration-thickness: .06em;
    transition: color var(--speed) var(--ease), text-decoration-color var(--speed) var(--ease);
}

a:hover {
    color: var(--brand-300);
    text-decoration-color: currentColor;
}

/* ---------------- Focus visible (accesible) ---------------- */
/* Recomendación de WAI/TPGI: indicadores de foco claros y consistentes */
:focus-visible {
    outline: 3px solid color-mix(in oklab, var(--brand-600) 72%, white);
    outline-offset: 3px;
    border-radius: .35rem;
}

/* ---------------- Texto / títulos ---------------- */
p,
ul,
ol,
dl,
blockquote,
pre,
table,
figure {
    margin-block: 1rem;
}

h1,
.h1 {
    font-size: var(--step-5);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.02em;
    margin-block: 0 0.35em;
}

h2,
.h2 {
    font-size: var(--step-3);
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-block: 1.1em .4em;
}

h3,
.h3 {
    font-size: var(--step-2);
    font-weight: 700;
    line-height: 1.22;
    margin-block: 1.2em .45em;
}

h4,
.h4 {
    font-size: var(--step-1);
    font-weight: 650;
}

h5,
.h5 {
    font-size: 1.05rem;
    font-weight: 600;
}

.display {
    font-size: clamp(3rem, 5vw + 1rem, 6rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

/* Estado muted y helpers */
.muted {
    color: var(--text-500);
}

.center {
    display: grid;
    place-items: center;
    text-align: center;
}

.readable {
    max-width: 75ch;
    margin-inline: auto;
}

.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;
}

/* ---------------- Selección de texto (sobria y con contraste) ---------------- */
:root {
    --selection-bg: color-mix(in oklab, var(--brand-600) 22%, white);
    --selection-fg: var(--surface-text);
}

:root[data-theme="dark"] {
    --selection-bg: color-mix(in oklab, var(--brand-300) 35%, black);
    --selection-fg: white;
}

::selection {
    background: var(--selection-bg);
    color: var(--selection-fg);
}

/* Marcadores de lista más integrados */
::marker {
    color: color-mix(in oklab, var(--brand-600) 45%, var(--text-700));
}

/* ---------------- Citas, código y tablas base ---------------- */
blockquote {
    padding: .8rem 1rem;
    border-left: 4px solid color-mix(in oklab, var(--brand-600) 45%, var(--surface-border));
    background: color-mix(in oklab, var(--brand-600) 8%, var(--surface-1));
    border-radius: .5rem;
}

code,
kbd,
samp {
    font-family: var(--font-mono);
    font-size: .95em;
    background: color-mix(in oklab, var(--brand-600) 8%, var(--surface-1));
    padding: .15em .35em;
    border-radius: .35rem;
    border: 1px solid var(--surface-border);
}

pre {
    background: var(--surface-1);
    border: 1px solid var(--surface-border);
    padding: 1rem;
    border-radius: .75rem;
    overflow: auto;
}

/* Tablas neutrales */
table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--surface-border);
}

th {
    text-align: left;
    color: var(--text-700);
    font-weight: 700;
}

/* HR sobrio */
hr {
    border: 0;
    border-top: 1px solid var(--surface-border);
    margin-block: 1.25rem;
    opacity: .9;
}

/* ---------------- Scrollbar (discreto) ---------------- */
* {
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: color-mix(in oklab, var(--brand-600) 22%, var(--surface-2)) color-mix(in oklab, var(--brand-600) 6%, var(--surface-0));
}

::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

::-webkit-scrollbar-track {
    background: color-mix(in oklab, var(--brand-600) 6%, var(--surface-0));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: color-mix(in oklab, var(--brand-600) 22%, var(--surface-2));
    border: 2px solid color-mix(in oklab, var(--brand-600) 6%, var(--surface-0));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: color-mix(in oklab, var(--brand-600) 30%, var(--surface-2));
}

/* ---------------- Sombras utilitarias ---------------- */
.shadow-sm {
    box-shadow: var(--shadow-sm);
}

.shadow-md {
    box-shadow: var(--shadow-md);
}

.shadow-lg {
    box-shadow: var(--shadow-lg);
}

/* ---------------- Skiplink ---------------- */
.skiplink {
    position: absolute;
    left: -9999px;
}

.skiplink:focus {
    left: var(--container-pad);
    top: var(--container-pad);
    z-index: 9999;
    background: var(--brand-600);
    color: white;
    padding: .5rem 1rem;
    border-radius: .5rem;
}

/* ---------------- Animaciones base ---------------- */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes shimmer {
    100% {
        background-position: -200% 0;
    }
}

@keyframes scale-reveal {
    from {
        clip-path: circle(0 at 50% 50%);
    }

    to {
        clip-path: circle(140% at 50% 50%);
    }
}

.motion-safe {
    animation: fade-up var(--speed-slow) var(--ease) both;
}

/* ---------------- Background decorativo sutil ---------------- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(1000px 800px at 55% 35%, rgba(255, 255, 255, .07), transparent 70%);
    mix-blend-mode: overlay;
    opacity: .16;
}

/* ---------------- Reduced motion (accesibilidad) ---------------- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    body::before {
        display: none;
    }
}