/*
 * Yoangel Gómez — Shared Base v8 · Flat Dark Minimal
 * Design tokens, page surface, preloader, reveal engine, scroll progress,
 * floating nav and shared primitives. Loaded by every page.
 */

/* ── Design tokens ─────────────────────────────── */
:root {
    color-scheme: dark;

    /* Surfaces */
    --bg-0: #07070b;
    --bg-1: #0d0d12;
    --bg-2: #12121a;
    --line-0: rgba(255, 255, 255, 0.08);
    --line-1: rgba(255, 255, 255, 0.15);

    /* Text */
    --tx-0: #f4f5f8;
    --tx-1: #b8bcc7;
    --tx-2: #7a7f8d;

    /* Accent */
    --accent: #38bdf8;
    --accent-2: #818cf8;
    --accent-soft: rgba(56, 189, 248, 0.1);
    --grad: linear-gradient(92deg, #38bdf8 10%, #818cf8 90%);
    --glow: rgba(56, 189, 248, 0.35);

    /* Type */
    --font-title: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Motion & shape */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --r-lg: 18px;
    --r-md: 12px;
    --container: 1120px;
}

/* ── Reset & base ──────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

html,
body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1100px 520px at 50% -220px, rgba(255, 255, 255, 0.05), transparent 70%),
        radial-gradient(900px 460px at 88% -5%, rgba(56, 189, 248, 0.07), transparent 65%),
        radial-gradient(820px 520px at -12% 32%, rgba(129, 140, 248, 0.055), transparent 65%),
        var(--bg-0);
    background-attachment: fixed;
    color: var(--tx-1);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: -0.005em;
    -webkit-tap-highlight-color: transparent;
}

::selection {
    background: var(--accent);
    color: #06121b;
}

/* Slim scrollbar */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg-0);
}
::-webkit-scrollbar-thumb {
    background: #26262f;
    border-radius: 6px;
    border: 2px solid var(--bg-0);
}
::-webkit-scrollbar-thumb:hover {
    background: #35353f;
}

:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ── Scroll progress ───────────────────────────── */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 3000;
    transform-origin: 0 50%;
    transform: scaleX(0);
    background: var(--grad);
    pointer-events: none;
}

/* ── Preloader ─────────────────────────────────── */
.preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    transition: opacity 0.5s var(--ease), visibility 0.5s;
}

.preloader__ring {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--line-1);
    border-top-color: var(--accent);
    border-right-color: var(--accent-2);
    animation: ringRotate 0.9s linear infinite;
}

@keyframes ringRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.preloader__logo {
    font-family: var(--font-title);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    color: var(--tx-0);
}

.preloader__status {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--tx-2);
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── Scroll reveal engine ────────────────────────
   Hidden state only applies when JS is running (html.js).
   Without JS — or if the script fails — content stays visible. */
html.js [data-aos] {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}

html.js [data-aos].aos-animate {
    opacity: 1;
    transform: none;
}

html.js [data-aos][data-aos-delay="100"] { transition-delay: 60ms; }
html.js [data-aos][data-aos-delay="150"] { transition-delay: 90ms; }
html.js [data-aos][data-aos-delay="200"] { transition-delay: 120ms; }
html.js [data-aos][data-aos-delay="250"] { transition-delay: 150ms; }
html.js [data-aos][data-aos-delay="300"] { transition-delay: 180ms; }
html.js [data-aos][data-aos-delay="350"] { transition-delay: 210ms; }
html.js [data-aos][data-aos-delay="400"] { transition-delay: 240ms; }
html.js [data-aos][data-aos-delay="450"] { transition-delay: 270ms; }
html.js [data-aos][data-aos-delay="500"] { transition-delay: 300ms; }

/* ── Navigation: floating pill ─────────────────── */
.nav-contact {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: calc(100vw - 1.5rem);
    z-index: 1000;
}

.nav-contact__inner {
    background: rgba(10, 10, 14, 0.62);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid var(--line-1);
    border-radius: 100px;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    transition: background 0.4s var(--ease), border-color 0.4s var(--ease),
                box-shadow 0.4s var(--ease);
}

.nav-contact.scrolled .nav-contact__inner {
    background: rgba(10, 10, 14, 0.88);
    border-color: var(--line-1);
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
}

.nav-contact__links {
    display: flex;
    gap: 0.2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-contact__links a {
    position: relative;
    color: var(--tx-2);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0.5rem 0.85rem;
    border-radius: 100px;
    transition: color 0.3s var(--ease), background 0.3s var(--ease);
    white-space: nowrap;
}

.nav-contact__links a:hover {
    color: var(--tx-0);
}

.nav-contact__links a.active,
.nav-contact__links a[aria-current="page"] {
    color: var(--tx-0);
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.14), rgba(129, 140, 248, 0.1));
}

/* ── Footer primitives ─────────────────────────── */
.footer-contact {
    margin-top: 5rem;
    padding: 3.2rem 5% 2.6rem;
    text-align: center;
    border-top: 1px solid var(--line-0);
}

.footer-copyright {
    font-size: 0.66rem;
    color: var(--tx-2);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 0;
}

/* ── Shared typography primitives ──────────────── */
.section-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.24em;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
}

.section-label::before {
    content: '';
    width: 2rem;
    height: 1px;
    background: var(--grad);
    opacity: 0.8;
}

/* ── Buttons ───────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.8rem;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.35s var(--ease), color 0.35s var(--ease),
                border-color 0.35s var(--ease), transform 0.35s var(--ease),
                box-shadow 0.35s var(--ease);
}

.btn--primary {
    background: linear-gradient(92deg, #38bdf8, #818cf8);
    color: #05070d;
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 34px rgba(56, 189, 248, 0.28);
}

.btn--ghost {
    border-color: var(--line-1);
    color: var(--tx-1);
    background: transparent;
}

.btn--ghost:hover {
    border-color: var(--accent);
    color: var(--tx-0);
    background: var(--accent-soft);
    transform: translateY(-2px);
}

/* ── Responsive nav ────────────────────────────── */
@media (max-width: 640px) {
    .nav-contact {
        top: 0.7rem;
        max-width: calc(100vw - 1rem);
    }

    .nav-contact__inner {
        padding: 0.32rem 0.4rem;
    }

    .nav-contact__links {
        gap: 0;
    }

    .nav-contact__links a {
        font-size: 0.56rem;
        letter-spacing: 0.07em;
        padding: 0.5rem 0.55rem;
    }
}

@media (max-width: 380px) {
    .nav-contact__links a {
        font-size: 0.52rem;
        padding: 0.5rem 0.42rem;
        letter-spacing: 0.03em;
    }
}

/* ── Reduced motion ────────────────────────────── */
@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;
    }

    html.js [data-aos] {
        opacity: 1 !important;
        transform: none !important;
    }
}
