:root {
    --bg: #0b1220;
    --bg-alt: #0f172a;
    --card: #111a2e;
    --border: #1f2a44;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #6366f1;
    --primary-2: #22d3ee;
    --danger: #ef4444;
    --ok: #22c55e;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); letter-spacing: -.01em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }
code { background: #1e293b; padding: .1rem .35rem; border-radius: 6px; font-size: .9em; }

.container { width: min(1140px, 92%); margin: 0 auto; }
.narrow { max-width: 720px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.eyebrow {
    color: var(--primary-2);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .8rem;
    margin-bottom: .5rem;
}

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .8rem 1.4rem;
    border-radius: 10px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff; font-weight: 600; font-size: 1rem;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(99, 102, 241, .35); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); box-shadow: none; }
.btn-danger { background: transparent; border-color: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: #7f1d1d; color: #fff; box-shadow: none; }
.btn-sm { padding: .45rem .9rem; font-size: .88rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--primary-2); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Barra superior ---------- */
.topbar, .admin-bar {
    position: sticky; top: 0; z-index: 10;
    background: rgba(11, 18, 32, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner, .admin-bar-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 1rem; }
.logo { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; }
.logo:hover { text-decoration: none; }
.logo-mark {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; font-size: .9rem;
}
.nav { display: flex; align-items: center; gap: 1.4rem; }
.nav a:not(.btn) { color: var(--muted); font-weight: 500; }
.nav a:not(.btn):hover { color: var(--text); text-decoration: none; }

/* ---------- Hero ---------- */
.hero {
    padding: 6rem 0 5rem;
    background:
        radial-gradient(800px 400px at 85% 10%, rgba(99, 102, 241, .22), transparent 60%),
        radial-gradient(600px 300px at 10% 90%, rgba(34, 211, 238, .12), transparent 60%);
}
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem; align-items: center; }
.hero h1 {
    background: linear-gradient(90deg, #fff, #c7d2fe);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-title { font-size: 1.35rem; font-weight: 600; color: var(--primary-2); margin-bottom: .6rem; }
.hero-lead { font-size: 1.15rem; color: var(--muted); max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1.8rem 0 2.4rem; }
.hero-stats { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 2rem; }
.hero-stats li { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.8rem; }
.hero-stats span { color: var(--muted); font-size: .88rem; max-width: 11rem; }

.hero-card { background: #0a0f1c; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.code-head { display: flex; align-items: center; gap: .4rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); background: #0d1424; }
.code-head span { width: 11px; height: 11px; border-radius: 50%; background: #ef4444; }
.code-head span:nth-child(2) { background: #f59e0b; }
.code-head span:nth-child(3) { background: #22c55e; }
.code-head em { margin-left: .6rem; color: var(--muted); font-style: normal; font-size: .85rem; }
.code { margin: 0; padding: 1.2rem 1.3rem; font: .92rem/1.7 Consolas, "Cascadia Code", monospace; color: #cbd5e1; overflow-x: auto; }
.code .k { color: #c084fc; }
.code .t { color: #22d3ee; }
.code .s { color: #fbbf24; }

/* ---------- Secciones ---------- */
.section { padding: 5rem 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { max-width: 640px; margin-bottom: 2.6rem; }

.grid { display: grid; gap: 1.3rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.6rem;
    transition: border-color .2s, transform .2s;
}
.card:hover { border-color: #334366; }
.card-icon { font-size: 1.8rem; margin-bottom: .8rem; }

.project { display: flex; flex-direction: column; }
.project .tags { margin-top: auto; padding-top: 1rem; }
.tag-cat { color: var(--primary-2); font-size: .8rem; font-weight: 600; margin-bottom: .4rem; }

.checks { list-style: none; padding: 0; margin: 0 0 1rem; }
.checks li { position: relative; padding-left: 1.6rem; margin-bottom: .45rem; color: #cbd5e1; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }

.tags { display: flex; flex-wrap: wrap; gap: .45rem; }
.tag {
    display: inline-block; padding: .2rem .65rem; border-radius: 999px;
    background: rgba(99, 102, 241, .12); border: 1px solid rgba(99, 102, 241, .3);
    color: #c7d2fe; font-size: .8rem; font-weight: 500;
}

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.3rem; margin-top: 3rem; }
.step { padding: 1.2rem; border-left: 2px solid var(--primary); }
.step span {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: rgba(99, 102, 241, .18); color: #c7d2fe; font-weight: 700; margin-bottom: .7rem;
}
.step h4 { font-size: 1.05rem; }

/* ---------- Contacto / formularios ---------- */
.contact { display: grid; grid-template-columns: .8fr 1.2fr; gap: 3rem; align-items: start; }

.form { display: flex; flex-direction: column; gap: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-size: .92rem; }
.form label > span { color: #cbd5e1; font-weight: 500; }
.form input, .form select, .form textarea, .search input {
    width: 100%;
    padding: .75rem .9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0b1324;
    color: var(--text);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.form textarea { resize: vertical; min-height: 120px; }
.form input:focus, .form select:focus, .form textarea:focus, .search input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .25);
}
.form .invalid { border-color: var(--danger); }
.validation-message { color: #fca5a5; font-size: .82rem; }
.form label.check { flex-direction: row; align-items: flex-start; gap: .6rem; color: var(--muted); }
.form label.check input { width: auto; margin-top: .3rem; accent-color: var(--primary); }

/* Honeypot: fuera de la vista, sin display:none para que los bots lo vean. */
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

.alert { padding: .8rem 1rem; border-radius: 10px; font-size: .92rem; }
.alert-error { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4); color: #fecaca; }
.alert-ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .4); color: #bbf7d0; }

.success-icon {
    display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 1.2rem;
    border-radius: 50%; background: rgba(34, 197, 94, .15); color: var(--ok); font-size: 2rem; font-weight: 700;
}
.prose h3 { margin-top: 1.6rem; }
.prose p { color: #cbd5e1; }

/* ---------- Pie ---------- */
.footer { border-top: 1px solid var(--border); padding: 1.8rem 0; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }

/* ---------- Panel privado ---------- */
.admin-main { padding: 2rem 0 4rem; }
.admin-bar-actions { display: flex; align-items: center; gap: 1.2rem; font-size: .92rem; }
.admin-bar-actions form { margin: 0; }

.login-box { max-width: 420px; margin: 4rem auto; }
.login-box h1 { font-size: 1.6rem; margin-bottom: 1.2rem; }
.login-box .alert { margin-bottom: 1rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
    display: flex; flex-direction: column; padding: 1rem 1.2rem; border-radius: var(--radius);
    background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.stat:hover { text-decoration: none; border-color: #334366; }
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.stat strong { font-size: 1.7rem; }
.stat span { color: var(--muted); font-size: .88rem; }

.search { display: flex; gap: .6rem; margin-bottom: 1.5rem; }

.msg-list { display: flex; flex-direction: column; gap: .8rem; }
.msg { padding: 1.1rem 1.3rem; display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; }
.msg.unread { border-left: 3px solid var(--primary); }
.msg-main { flex: 1; color: var(--text); min-width: 0; }
.msg-main:hover { text-decoration: none; }
.msg-main:hover strong { color: #c7d2fe; }
.msg-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.msg-top time { margin-left: auto; color: var(--muted); font-size: .85rem; }
.msg-meta { color: var(--muted); font-size: .88rem; margin: .2rem 0 .5rem; }
.msg-preview { color: #cbd5e1; margin: 0; font-size: .95rem; overflow-wrap: anywhere; }
.msg-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.msg-actions form { margin: 0; }

.badge { background: var(--primary); color: #fff; border-radius: 999px; padding: .05rem .55rem; font-size: .72rem; font-weight: 600; }
.badge-muted { background: #334155; }

.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); }

.detail-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.detail-head h1 { font-size: 1.8rem; }
.detail h3 { margin-top: 1.6rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 0; }
.fields dt { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.fields dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.msg-body { white-space: pre-wrap; background: #0b1324; border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.2rem; overflow-wrap: anywhere; }
.detail .form { margin-top: .6rem; align-items: flex-start; }
.tech { margin-top: 1.6rem; overflow-wrap: anywhere; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .hero-inner, .contact { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .steps { grid-template-columns: repeat(2, 1fr); }
    .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .nav a:not(.btn) { display: none; }
    .grid-2, .grid-3, .form-row, .steps { grid-template-columns: 1fr; }
    .hero { padding: 4rem 0 3rem; }
    .section { padding: 3.5rem 0; }
    .msg { flex-direction: column; }
    .msg-actions { justify-content: flex-start; }
}

/* ---------- Contacto directo ---------- */
.contact-direct { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.8rem; }
.contact-direct p { margin-bottom: .2rem; }
.contact-item {
    display: flex; align-items: center; gap: .9rem;
    padding: .8rem 1rem; border-radius: 12px;
    background: var(--card); border: 1px solid var(--border); color: var(--text);
    transition: border-color .2s, transform .2s, background .2s;
}
.contact-item:hover { text-decoration: none; border-color: var(--primary); transform: translateX(4px); background: #131d35; }
.contact-icon {
    display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 10px; background: rgba(99, 102, 241, .14); font-size: 1.15rem;
}
.contact-item strong { display: block; font-size: .95rem; }
.contact-item em { font-style: normal; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* ---------- Animaciones (sutiles) ---------- */

/* Entrada del hero al cargar */
@keyframes subir {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}
.anim-in { animation: subir .7s cubic-bezier(.2, .7, .2, 1) both; animation-delay: var(--d, 0ms); }

/* Elementos que aparecen al hacer scroll (solo si hay JavaScript) */
.js .reveal {
    opacity: 0; transform: translateY(18px);
    transition: opacity .6s ease, transform .6s cubic-bezier(.2, .7, .2, 1), border-color .2s;
    transition-delay: var(--d, 0ms), var(--d, 0ms), 0ms;
}
.js .reveal.visible { opacity: 1; transform: none; }

/* Brillo de fondo del hero que se mueve muy lento */
.hero { position: relative; overflow: hidden; }
.hero::before {
    content: ""; position: absolute; inset: -20%; z-index: 0; pointer-events: none;
    background: radial-gradient(500px 300px at 70% 30%, rgba(139, 92, 246, .14), transparent 70%);
    animation: deriva 18s ease-in-out infinite alternate;
}
.hero-inner { position: relative; z-index: 1; }
@keyframes deriva {
    from { transform: translate(-4%, -2%); }
    to { transform: translate(4%, 3%); }
}

/* Tarjeta de código flotando suavemente + cursor parpadeando */
.hero-card { animation: subir .7s cubic-bezier(.2, .7, .2, 1) both, flotar 7s ease-in-out 1s infinite; animation-delay: var(--d, 0ms), 1s; }
@keyframes flotar {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.cursor {
    display: inline-block; width: .55em; height: 1.1em; margin-left: 2px;
    vertical-align: text-bottom; background: var(--primary-2); opacity: .8;
    animation: parpadeo 1.1s steps(1) infinite;
}
@keyframes parpadeo { 50% { opacity: 0; } }

/* Tarjetas: se elevan un poco al pasar el mouse */
.card { transition: border-color .25s, transform .25s, box-shadow .25s, opacity .6s, background .25s; }
.section .card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(0, 0, 0, .28); }
.js .section .card.reveal.visible:hover { transform: translateY(-3px); }
.card-icon { transition: transform .3s; display: inline-block; }
.card:hover .card-icon { transform: scale(1.12) rotate(-4deg); }
.tag { transition: background .2s, border-color .2s; }
.card:hover .tag { border-color: rgba(99, 102, 241, .5); }
.step span { transition: background .25s, transform .25s; }
.step:hover span { background: var(--primary); color: #fff; transform: scale(1.08); }

/* Botón principal con un brillo que cruza al pasar el mouse */
.btn { position: relative; overflow: hidden; }
.btn:not(.btn-ghost):not(.btn-danger)::after {
    content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .25), transparent);
    transform: skewX(-20deg); transition: left .6s ease;
}
.btn:not(.btn-ghost):not(.btn-danger):hover::after { left: 140%; }

/* Subrayado animado en el menú */
.nav a:not(.btn) { position: relative; }
.nav a:not(.btn)::after {
    content: ""; position: absolute; left: 0; bottom: -4px; width: 100%; height: 2px;
    background: var(--primary-2); transform: scaleX(0); transform-origin: left; transition: transform .25s;
}
.nav a:not(.btn):hover::after { transform: scaleX(1); }

/* Barra superior con sombra al bajar */
.topbar { transition: box-shadow .3s, background .3s; }
.topbar.scrolled { box-shadow: 0 6px 20px rgba(0, 0, 0, .35); background: rgba(11, 18, 32, .95); }

/* Palomita de "gracias" */
.success-icon { animation: aparecerIcono .6s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes aparecerIcono { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: none; } }

/* Respeta la preferencia de "reducir movimiento" del sistema */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .js .reveal { opacity: 1; transform: none; }
}

/* Ubicación */
.hero-location { color: var(--muted); font-size: 1rem; margin: -.2rem 0 .9rem; }
.contact-static:hover { transform: none; border-color: var(--border); background: var(--card); }
