/* =========================================================================
   base.css — Fuentes locales, variables de diseño, reset y utilidades.
   Paleta: azul noche, azul eléctrico, índigo y cian como luz de acento.
   ========================================================================= */

@font-face { font-family: "Inter"; src: url("../fonts/Inter-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Medium.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-SemiBold.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../fonts/InterDisplay-ExtraBold.woff") format("woff"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../fonts/InterDisplay-Black.woff") format("woff"); font-weight: 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/JetBrainsMono-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }

:root {
    --bg: #050914;
    --bg-2: #070c1a;
    --bg-3: #0a1224;
    --surface: color-mix(in srgb, var(--ink-3) 62%, transparent);
    --surface-solid: #0c1428;
    --glass: color-mix(in srgb, var(--ink-2) 74%, transparent);

    --line: rgba(148, 163, 184, 0.12);
    --line-2: rgba(148, 163, 184, 0.22);
    --line-blue: rgba(96, 165, 250, 0.4);

    --text: #f5f8ff;
    --text-soft: #c9d4e5;
    --muted: #8c9ab3;

    --blue: #3b82f6;
    --blue-strong: #2563eb;
    --blue-deep: #1d4ed8;
    --blue-pale: #93c5fd;
    --blue-ice: #dbeafe;
    --indigo: #6366f1;
    --cyan: #22d3ee;
    --green: #22c55e;

    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --display: "Inter Display", "Inter", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --shell: 1240px;
    --gutter: clamp(18px, 4.5vw, 48px);
    --header-h: 72px;
    --section-y: clamp(76px, 8vw, 120px);

    --r-md: 16px;
    --r-lg: 24px;
    --r-xl: 32px;

    /* Superficies y estados (cambian con el tema) */
    --ink: #050914;
    --ink-2: #080d1c;
    --ink-3: #0d152a;
    --panel: color-mix(in srgb, var(--ink-3) 66%, transparent);
    --panel-solid: #0b1326;
    --panel-2: color-mix(in srgb, var(--ink) 55%, transparent);
    --chip: rgba(255, 255, 255, 0.035);
    --chip-hover: rgba(59, 130, 246, 0.12);
    --code-bg: rgba(4, 8, 18, 0.7);
    --code-text: #d6e0f0;
    --accent-text: #93c5fd;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --shadow: rgba(0, 0, 0, 0.6);
    --glow: rgba(37, 99, 235, 0.55);
    --title-soft-a: #93c5fd;
    --title-soft-b: #6c86b8;

    --focus: #60a5fa;
    --focus-soft: rgba(59, 130, 246, 0.22);

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --fast: 180ms;
    --mid: 340ms;
}

/* Tema claro: gris azulado suave, misma identidad azul y contraste adecuado. */
:root[data-theme="light"] {
    /* Tema claro diseñado aparte: blancos suaves, grises neutros apenas azulados,
       texto oscuro y el azul eléctrico solo como acento. */
    --bg: #f5f7fa;
    --bg-2: #eef2f6;
    --bg-3: #e6ebf1;
    --surface: #ffffff;
    --surface-solid: #ffffff;
    --glass: rgba(255, 255, 255, 0.88);

    --line: #e1e7ef;
    --line-2: #d3dce8;
    --line-blue: rgba(37, 99, 235, 0.38);

    --text: #142139;
    --text-soft: #33435c;
    --muted: #5d6b81;

    --blue: #2563eb;
    --blue-strong: #1d4ed8;
    --blue-deep: #1e40af;
    --blue-pale: #2563eb;
    --blue-ice: #1e3a8a;
    --indigo: #4f46e5;
    --cyan: #0e7490;
    --green: #15803d;

    --ink: #ffffff;
    --ink-2: #ffffff;
    --ink-3: #ffffff;
    --panel: #ffffff;
    --panel-solid: #ffffff;
    --panel-2: #eef2f6;
    --chip: #f1f4f8;
    --chip-hover: #e8effb;
    --code-bg: #f4f6f9;
    --code-text: #1f2a3d;
    --accent-text: #1d4ed8;
    --ok: #15803d;
    --warn: #b45309;
    --err: #dc2626;
    --shadow: rgba(20, 33, 57, 0.16);
    --glow: rgba(20, 33, 57, 0.18);
    --title-soft-a: #2563eb;
    --title-soft-b: #64748b;
    --focus: #2563eb;
    --focus-soft: rgba(37, 99, 235, 0.16);

    color-scheme: light;
}

/* Transición suave de colores al cambiar de tema (solo durante el cambio). */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition: background-color 420ms ease, border-color 420ms ease, color 420ms ease, fill 420ms ease, stroke 420ms ease, box-shadow 420ms ease !important;
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scrollbar-color: rgba(96, 165, 250, 0.45) var(--bg);
    scrollbar-width: thin;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
    border: 3px solid var(--bg);
    border-radius: 99px;
    background: linear-gradient(180deg, #3b82f6, #6366f1);
}
::-webkit-scrollbar-thumb:hover { background: #60a5fa; }

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text-soft);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
    overflow: hidden;
}

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

ul, ol {
    padding: 0;
    list-style: none;
}

h1, h2, h3, h4 {
    color: var(--text);
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

p { text-wrap: pretty; }

a {
    color: inherit;
    text-decoration: none;
}

img, svg, canvas, picture {
    display: block;
    max-width: 100%;
}

img { height: auto; }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

::selection {
    background: rgba(59, 130, 246, 0.5);
    color: #fff;
}

/* Enfoque unificado: un solo anillo visible para teclado. Los campos de formulario
   no dibujan contorno: lo sustituyen su borde y un halo suave (ver .is-field). */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

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

/* Controles dentro de grupos segmentados: el anillo se dibuja hacia dentro */
[role="tablist"] > button:focus-visible,
[role="radiogroup"] > button:focus-visible { outline-offset: -2px; }

/* Los títulos de sección quedan visibles bajo el encabezado fijo. */
section[id] {
    scroll-margin-top: calc(var(--header-h) + 28px - var(--section-y));
}

#inicio { scroll-margin-top: 0; }

/* ------------------------------- Utilidades ------------------------------- */
.shell {
    width: 100%;
    max-width: calc(var(--shell) + var(--gutter) * 2);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.i {
    width: 1em;
    height: 1em;
    flex: none;
    fill: currentColor;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 400;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--blue-strong);
    color: #fff;
    font-weight: 600;
    transform: translateY(-200%);
    transition: transform var(--mid) var(--ease);
}

.skip-link:focus { transform: none; }

/* Fondo global: profundidad con luz muy tenue (estático, sin coste de CPU). */
.page-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(1100px 700px at 100% 0%, rgba(37, 99, 235, 0.10), transparent 60%),
        radial-gradient(900px 600px at 0% 45%, rgba(99, 102, 241, 0.07), transparent 60%),
        radial-gradient(900px 600px at 100% 100%, rgba(34, 211, 238, 0.05), transparent 60%),
        var(--bg);
}

/* Fondo claro: un único brillo muy sutil y una retícula casi imperceptible */
[data-theme="light"] .page-bg {
    background:
        radial-gradient(1200px 700px at 85% -10%, rgba(37, 99, 235, 0.05), transparent 65%),
        var(--bg);
}

[data-theme="light"] .page-bg::after {
    background-image:
        linear-gradient(rgba(20, 33, 57, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 33, 57, 0.035) 1px, transparent 1px);
}

[data-theme="light"] ::selection { background: rgba(37, 99, 235, 0.22); color: var(--text); }

.page-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
}

/* --------------------------- Elementos comunes --------------------------- */
.section {
    position: relative;
    padding-block: var(--section-y);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: var(--blue-pale);
    font-family: var(--mono);
    font-size: 0.76rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow b {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: var(--blue);
    font-weight: 400;
}

.eyebrow b::after {
    content: "";
    width: 36px;
    height: 1px;
    background: linear-gradient(90deg, var(--blue), transparent);
}

.section-title {
    margin-top: 18px;
    font-family: var(--display);
    font-size: clamp(2.3rem, 1.4rem + 3.4vw, 4.4rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.section-title--md {
    font-size: clamp(2rem, 1.3rem + 2.4vw, 3.4rem);
}

/* Segunda parte del título: sólida, en azul atenuado (el contorno queda solo para el apellido). */
.section-title .soft {
    background: linear-gradient(100deg, var(--title-soft-a) 0%, var(--title-soft-b) 70%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.section-lead {
    max-width: 58ch;
    margin-top: 18px;
    color: var(--muted);
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
}

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 52px;
    padding: 14px 24px;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: transform var(--mid) var(--ease), border-color var(--fast) ease, background-color var(--fast) ease, box-shadow var(--mid) ease;
}

.btn .i {
    transition: transform var(--mid) var(--ease);
}

.btn--primary {
    background: linear-gradient(135deg, #4f8ff8, var(--blue-strong) 55%, var(--blue-deep));
    color: #fff;
    box-shadow: 0 14px 40px -14px rgba(37, 99, 235, 0.9), inset 0 1px rgba(255, 255, 255, 0.25);
}

/* Barrido de luz en el botón principal */
.btn--primary::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 800ms var(--ease);
}

.btn--primary:hover::before { transform: translateX(120%); }
.btn--primary:hover .i { transform: translateX(4px); }

.btn--ghost {
    border-color: var(--line-2);
    background: var(--chip);
    color: var(--text);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.btn--ghost:hover {
    border-color: var(--line-blue);
    background: rgba(59, 130, 246, 0.12);
}

.btn--ghost:hover .i { transform: translate(3px, -3px); }

.btn--sm {
    min-height: 42px;
    padding: 10px 18px;
    font-size: 0.87rem;
}

.btn:active { transform: scale(0.97); }

.live-dot {
    position: relative;
    display: inline-block;
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16), 0 0 10px rgba(34, 197, 94, 0.6);
}

/* ------------------------------ Selector de tema ------------------------------ */
.theme-toggle {
    display: grid;
    flex: none;
    width: 58px;
    height: 34px;
    place-items: center;
    border-radius: 999px;
}

.tt-track {
    position: relative;
    display: block;
    width: 54px;
    height: 30px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    background:
        radial-gradient(circle at 70% 40%, rgba(147, 197, 253, 0.25) 0 1px, transparent 1.5px),
        radial-gradient(circle at 82% 66%, rgba(147, 197, 253, 0.35) 0 1px, transparent 1.5px),
        radial-gradient(circle at 60% 72%, rgba(147, 197, 253, 0.25) 0 0.8px, transparent 1.3px),
        linear-gradient(135deg, #0b1430, #111c3d);
    transition: background 500ms ease, border-color var(--fast) ease;
}

.theme-toggle:hover .tt-track { border-color: var(--line-blue); }

.tt-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a, #312e81);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), inset 0 1px rgba(255, 255, 255, 0.15);
    transition: transform 520ms var(--ease), background 500ms ease;
}

/* Luna (creciente) → sol con rayos */
.tt-icon {
    position: relative;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset -4px -2px 0 0 #dbeafe;
    transform: rotate(-20deg);
    transition: box-shadow 500ms ease, background-color 500ms ease, transform 600ms var(--ease);
}

.tt-icon::before {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    background: repeating-conic-gradient(from 0deg, #f59e0b 0 10deg, transparent 10deg 45deg);
    -webkit-mask: radial-gradient(circle, transparent 7px, #000 7.5px);
    mask: radial-gradient(circle, transparent 7px, #000 7.5px);
    opacity: 0;
    transform: scale(0.4) rotate(-60deg);
    transition: opacity 400ms ease, transform 600ms var(--ease);
}

[data-theme="light"] .tt-track {
    border-color: var(--line-2);
    background: linear-gradient(135deg, #eef2f6, #e2e8f0);
}

[data-theme="light"] .tt-knob {
    background: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 110, 0.3);
    transform: translateX(24px);
}

[data-theme="light"] .tt-icon {
    width: 9px;
    height: 9px;
    background: #f59e0b;
    box-shadow: 0 0 0 0 #f59e0b;
    transform: rotate(90deg);
}

[data-theme="light"] .tt-icon::before { opacity: 1; transform: scale(1) rotate(0); }

@media (prefers-reduced-motion: reduce) {
    .tt-knob, .tt-icon, .tt-icon::before { transition: none; }
}

/* Tecnologías con color de marca casi blanco: en tema claro usan un gris pizarra legible. */
[data-theme="light"] [style*="#e8edf5"] { --c: #334155 !important; }
