/*
 * Estilo del sitio principal de codewithferrer.dev: la portada (index.html) y las páginas interiores (contacto,
 * políticas de privacidad y de cookies). Las páginas de cada app tienen el suyo.
 *
 * Sin la plantilla antigua (base, vendor, main), sin jQuery y con las fuentes del sistema, así que no carga nada de terceros. Se adapta solo al modo claro u oscuro del sistema.
 * Cada app lleva en su tarjeta los colores de su propia web; si cambia la identidad de una, cambia aquí
 * sus variables --t-*.
 */

:root {
    color-scheme: dark light;
    --bg: #0e0e11;
    --card: #1a1a21;
    --line: rgba(255, 255, 255, 0.12);
    --fg: #f3f1ec;
    --muted: #a9a7b3;
    --accent: #ff7a6b;
    --on-accent: #1c0c0a;
    --radius: 22px;
    --max: 1120px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f6f4ef;
        --card: #ffffff;
        --line: rgba(20, 20, 30, 0.13);
        --fg: #18181b;
        --muted: #5b5967;
        --accent: #c2362c;
        --on-accent: #ffffff;
    }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--fg);
    font: 400 1rem/1.6 var(--font); -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, ul { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.6rem 1rem; border-radius: 10px; background: var(--accent); color: var(--on-accent); }
.skip:focus { top: 1rem; }

.wrap { width: min(var(--max), 100% - 2.5rem); margin-inline: auto; }

/* --- Barra superior ------------------------------------------------------------------------------------ */

.topbar {
    position: sticky; top: 0; z-index: 50; background: var(--bg);
    border-bottom: 1px solid transparent;
}
@supports (background: color-mix(in srgb, red 50%, blue)) {
    .topbar { background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.75rem; }
.brand { font: 600 1.05rem/1 var(--font); letter-spacing: -0.01em; text-decoration: none; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 1.5rem; }
.nav a { font-size: 0.95rem; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--fg); }

/* --- Cabecera ------------------------------------------------------------------------------------------ */

.hero {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center;
    gap: clamp(2rem, 5vw, 5rem); padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(1.5rem, 3vw, 2.5rem);
}
.eyebrow { font: 500 0.8rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0.8rem 0 1.1rem; font-size: clamp(2.7rem, 7.5vw, 5.2rem); line-height: 1.02; letter-spacing: -0.035em; font-weight: 700; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lead { max-width: 33rem; font-size: clamp(1.05rem, 2vw, 1.28rem); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.8rem 1.35rem; border-radius: 999px;
    border: 1px solid var(--line); background: transparent; color: var(--fg);
    font: 600 0.98rem/1 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }

.social { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.75rem; padding: 0; list-style: none; }
.social a {
    display: inline-flex; align-items: center; gap: 0.55rem; padding: 0.55rem 0.95rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--card); text-decoration: none; font-size: 0.93rem; font-weight: 500;
}
.social a:hover { border-color: var(--accent); }
.social .fa { font-size: 1.15rem; color: var(--accent); }

.portrait { margin: 0; justify-self: end; width: min(100%, 25rem); }
.portrait img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 30px; border: 1px solid var(--line); }

/* --- Secciones ----------------------------------------------------------------------------------------- */

section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.head { margin-bottom: 2rem; }
.head h2 { margin-top: 0.7rem; font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.1; letter-spacing: -0.025em; }
.head p { margin-top: 0.7rem; max-width: 34rem; color: var(--muted); font-size: 1.08rem; }

/* --- Apps (bento) -------------------------------------------------------------------------------------- */

.apps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(250px, auto); gap: 14px; }
.tile {
    --t-bg: var(--card); --t-fg: var(--fg); --t-muted: var(--muted); --t-line: var(--line); --t-tag: var(--accent);
    position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 1.5rem; overflow: hidden;
    padding: 1.35rem; border-radius: var(--radius); border: 1px solid var(--t-line);
    background: var(--t-bg); color: var(--t-fg); text-decoration: none; isolation: isolate;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
a.tile:hover { transform: translateY(-4px); border-color: var(--t-tag); }
.tile--big { grid-column: span 2; grid-row: span 2; padding: 1.75rem; }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.tile img.icon, .tile .icon { width: 64px; height: 64px; flex: none; border-radius: 22%; }
.tile--big img.icon { width: 96px; height: 96px; }
.tile h3 { font-size: 1.3rem; line-height: 1.15; letter-spacing: -0.01em; }
.tile--big h3 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); }
.tile p { margin-top: 0.5rem; font-size: 0.97rem; line-height: 1.5; color: var(--t-muted); }
.tile--big p { max-width: 30rem; font-size: 1.1rem; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 1.1rem; }
.tag { padding: 0.32rem 0.6rem; border-radius: 999px; border: 1px solid var(--t-tag); color: var(--t-tag); font: 500 0.72rem/1 var(--mono); letter-spacing: 0.04em; }
.tag.solid { background: var(--t-tag); color: var(--t-bg); }
.more { margin-left: auto; font-size: 0.9rem; font-weight: 600; color: var(--t-fg); }
.more::after { content: " →"; }

.tile--wake { --t-bg: #3f2e66; --t-fg: #ffffff; --t-muted: #ddd5f0; --t-line: #5a4690; --t-tag: #f4c98a; }
.tile--wake::before {
    content: ""; position: absolute; z-index: -1; right: -3.5rem; top: -3.5rem; width: 14rem; height: 14rem;
    border-radius: 50%; background: #f4c98a; opacity: 0.18;
}
.tile--wake::after {
    content: ""; position: absolute; z-index: -1; left: -15%; right: -15%; bottom: -34%; height: 46%;
    border-radius: 50%; background: #2d2150;
}
.tile--chess { --t-bg: #0a0a0c; --t-fg: #f8f9fa; --t-muted: #b9bbc0; --t-line: #2b2b30; --t-tag: #6dff8a; }
.tile--bricks { --t-bg: #0f0f13; --t-fg: #f4f4f8; --t-muted: #b6b6c2; --t-line: #2a2a35; --t-tag: #00f0f0; }
.tile--memory { --t-bg: #f1efe8; --t-fg: #1d1d1f; --t-muted: #55535e; --t-line: #d6d3c8; --t-tag: #1d1d1f; }
.dots { display: flex; gap: 5px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; }
.dots i:nth-child(1) { background: #ff3b3b; }
.dots i:nth-child(2) { background: #2ee86b; }
.dots i:nth-child(3) { background: #2bb8ff; }
.dots i:nth-child(4) { background: #ffd60a; }
.tile--bus .icon { display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: 1.9rem; }
.stores { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.stores a {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.8rem; border-radius: 999px;
    border: 1px solid var(--line); font-size: 0.85rem; font-weight: 600; text-decoration: none;
}
.stores a:hover { border-color: var(--accent); }

.all-apps { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 2.25rem; }
.all-apps p { margin-right: auto; color: var(--muted); }

/* --- Sobre mí ------------------------------------------------------------------------------------------ */

.about { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(2rem, 6vw, 5rem); align-items: start; }
.stat { margin-top: 1.75rem; }
.stat strong { display: block; font-size: clamp(3.6rem, 9vw, 6rem); line-height: 1; letter-spacing: -0.04em; color: var(--accent); }
.stat span { color: var(--muted); }
.timeline { margin: 0; padding: 0 0 0 0; list-style: none; border-left: 1px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.75rem 1.75rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 0.5rem; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.when { display: block; font: 500 0.8rem/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.timeline p { margin-top: 0.3rem; font-size: 1.05rem; color: var(--muted); }

/* --- Contacto ------------------------------------------------------------------------------------------ */

.contact-card {
    display: grid; gap: 1.5rem; padding: clamp(1.75rem, 5vw, 3.5rem); border-radius: 30px;
    border: 1px solid var(--line); background: var(--card);
}
.contact-card h2 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; letter-spacing: -0.03em; }
.contact-card p { max-width: 36rem; color: var(--muted); font-size: 1.1rem; }
.contact-card .social { margin-top: 0; }
.contact-card .social a { background: var(--bg); }

footer { padding: 2.5rem 0 4.5rem; border-top: 1px solid var(--line); }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem; color: var(--muted); font-size: 0.92rem; }
footer ul { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; padding: 0; list-style: none; }
footer a { text-decoration: none; }
footer a:hover { color: var(--fg); text-decoration: underline; }

/* --- Páginas interiores: contacto y políticas ---------------------------------------------------------- */

.page { padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(3rem, 7vw, 6rem); }
.page-head { max-width: 50rem; margin-bottom: 2.25rem; }
.page-head h1 { margin-top: 0.7rem; font-size: clamp(2.2rem, 6vw, 3.8rem); line-height: 1.05; letter-spacing: -0.03em; }
.page-head .sub { margin-top: 0.8rem; color: var(--muted); font-size: 1.1rem; }

/* Cada texto en sus dos idiomas: el idioma activo es <html lang> (js/site-i18n.js). Sin JavaScript se ven los dos. */
html[lang="es"] .bi > [lang="en"], html[lang="en"] .bi > [lang="es"],
html[lang="es"] .legal-text[lang="en"], html[lang="en"] .legal-text[lang="es"] { display: none; }

.legal-text { max-width: 50rem; scroll-margin-top: 5rem; font-size: 1.02rem; line-height: 1.75; }
.legal-text p { margin: 0 0 1rem; }
.legal-text h3 { margin: 2.25rem 0 0.6rem; font: 650 1rem/1.35 var(--font); letter-spacing: 0.02em; color: var(--accent); }
.legal-text h3:first-child { margin-top: 0; }
.legal-text ul { margin: 0 0 1rem; padding-left: 1.3rem; }
.legal-text li { margin-bottom: 0.4rem; }
.legal-text a { color: var(--accent); text-underline-offset: 3px; }
.legal-text em { color: var(--muted); }
.legal-text code { padding: 0.1em 0.4em; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: 0.88em var(--mono); word-break: break-all; }

.table-wrap { margin: 0 0 1rem; overflow-x: auto; }
.cookie-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; line-height: 1.5; }
.cookie-table th { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; color: var(--muted); font: 600 0.74rem/1.3 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; }
.cookie-table td { padding: 0.8rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.cookie-table code { white-space: nowrap; }

.page .contact-card { max-width: 50rem; }
.help { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; max-width: 50rem; margin-top: 2rem; }
.help p { margin-right: auto; color: var(--muted); }

/* --- Aviso de cookies ---------------------------------------------------------------------------------- */

.cookies {
    position: fixed; right: 16px; bottom: 16px; z-index: 9000; display: none; align-items: center; gap: 1rem;
    max-width: 30rem; padding: 0.9rem 1rem 0.9rem 1.15rem; border-radius: 18px;
    border: 1px solid var(--line); background: var(--card); color: var(--fg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); font-size: 0.88rem; line-height: 1.45;
}
.cookies a { color: var(--accent); }
.cookies button {
    flex: none; padding: 0.6rem 1.1rem; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--accent); color: var(--on-accent); font: 600 0.9rem/1 var(--font);
}

/* --- Pantallas estrechas ------------------------------------------------------------------------------- */

@media (max-width: 960px) {
    .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tile--big { grid-row: span 1; }
    .about { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .hero { grid-template-columns: 1fr; }
    .portrait { order: -1; justify-self: start; width: min(9.5rem, 44%); }
    .portrait img { border-radius: 22px; }
    .nav { gap: 1.1rem; }
}

@media (max-width: 640px) {
    .cookie-table thead { display: none; }
    .cookie-table, .cookie-table tbody, .cookie-table tr, .cookie-table td { display: block; width: 100%; }
    .cookie-table tr { padding: 1rem 0; border-bottom: 1px solid var(--line); }
    .cookie-table td { padding: 0.15rem 0; border: 0; }
    .cookie-table td::before { content: attr(data-label) ": "; font-weight: 700; color: var(--muted); }
}

@media (max-width: 560px) {
    .apps-grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
    .tile--big { grid-column: auto; }
    .nav a:nth-child(2) { display: none; }
    .cookies { left: 12px; right: 12px; bottom: 12px; max-width: none; }
    body.cookie-open .lang-switcher { bottom: calc(var(--cookie-h, 0px) + 24px); }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .tile { transition: none; }
    a.tile:hover { transform: none; }
}
