/* ==========================================================================
   alb1183 — hoja de estilos única (mobile-first)
   ========================================================================== */

:root {
	--accent: #34495e;
	--accent-soft: #e8edf2;
	--bg-1: #17171b;
	--bg-2: #28282f;
	--card: #ffffff;
	--card-alt: #f6f7f9;
	--text: #2b2f36;
	--text-soft: #5f6670;
	--text-faint: #8a9099;
	--line: #e6e8ec;
	--radius: 14px;
	--shadow: 0 10px 30px rgba(0, 0, 0, .25);
	--nav-h: 64px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--accent: #8fb3d6;
		--accent-soft: #2a323c;
		--card: #1f2026;
		--card-alt: #26272e;
		--text: #e7e9ec;
		--text-soft: #b3b8c0;
		--text-faint: #868c95;
		--line: #33353d;
		--shadow: 0 10px 30px rgba(0, 0, 0, .45);
		color-scheme: dark;
	}
}

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

html {
	background: var(--bg-1);
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.65;
	color: var(--text);
	background: var(--bg-1);
	background: linear-gradient(to bottom right, var(--bg-1), var(--bg-2)) fixed;
	min-height: 100vh;
	padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

img { max-width: 100%; display: block; }

[hidden] { display: none !important; }

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

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

h1, h2, h3 { line-height: 1.3; margin: 0; }

/* ---------- Fondo animado ---------- */

.bg-squares {
	position: fixed;
	inset: 0;
	z-index: -1;
	overflow: hidden;
	pointer-events: none;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bg-squares li {
	position: absolute;
	bottom: -160px;
	width: 80px;
	height: 80px;
	border-radius: 6px;
	background: rgba(255, 255, 255, .025);
	animation: rise 50s linear infinite;
}

.bg-squares li:nth-child(1) { left: 8%; }
.bg-squares li:nth-child(2) { left: 22%; width: 40px; height: 40px; animation-delay: -8s; animation-duration: 38s; }
.bg-squares li:nth-child(3) { left: 40%; width: 120px; height: 120px; animation-delay: -20s; }
.bg-squares li:nth-child(4) { left: 58%; width: 50px; height: 50px; animation-delay: -4s; animation-duration: 44s; }
.bg-squares li:nth-child(5) { left: 74%; animation-delay: -30s; }
.bg-squares li:nth-child(6) { left: 88%; width: 140px; height: 140px; animation-delay: -14s; animation-duration: 60s; }

@keyframes rise {
	to { transform: translateY(-120vh) rotate(600deg); }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	.bg-squares li { animation: none; display: none; }
}

/* ---------- Layout ---------- */

.layout {
	max-width: 1180px;
	margin: 0 auto;
	padding: 16px;
	display: grid;
	gap: 16px;
}

.card {
	background: var(--card);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px 20px;
	scroll-margin-top: 16px;
}

/* ---------- Perfil ---------- */

.profile {
	text-align: center;
	padding-top: 25px;
}

.profile-photo {
	width: 70%;
	max-width: 200px;
	height: auto;
	border-radius: 10%;
	margin: 0 auto 16px;
	box-shadow: 0 2px 15px rgba(0, 0, 0, .2);
}

.profile h1 { font-size: 1.5rem; font-weight: 600; }

.profile .job {
	margin: 4px 0 0;
	color: var(--text-soft);
	font-size: .92rem;
}

.socials {
	display: flex;
	justify-content: center;
	gap: 10px;
	margin-top: 16px;
}

.socials a {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	background: var(--accent-soft);
	color: var(--accent);
	font-size: 1.05rem;
	transition: background .2s, color .2s, transform .2s;
}

.socials a:hover {
	background: var(--accent);
	color: var(--card);
	text-decoration: none;
	transform: translateY(-2px);
}

/* ---------- Navegación ---------- */

/* Móvil: barra inferior fija */
.nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 50;
	background: var(--card);
	border-top: 1px solid var(--line);
	box-shadow: 0 -6px 20px rgba(0, 0, 0, .15);
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav ul {
	display: flex;
	margin: 0;
	padding: 0;
	list-style: none;
}

.nav li { flex: 1; }

.nav a {
	height: var(--nav-h);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	font-size: .7rem;
	color: var(--text-faint);
	text-decoration: none;
	transition: color .2s;
}

.nav a i { font-size: 1.1rem; }

.nav a.active,
.nav a:hover { color: var(--accent); }

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

.section-title {
	font-size: 1.2rem;
	font-weight: 600;
	margin-bottom: 20px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.section-title::after {
	content: "";
	flex: 1;
	height: 2px;
	background: var(--line);
}

.subsection-title {
	font-size: 1rem;
	font-weight: 600;
	margin: 0 0 14px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.subsection-title i {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	background: var(--accent);
	color: var(--card);
	font-size: .85rem;
	flex-shrink: 0;
}

.block + .block { margin-top: 32px; }

.lead { margin: 0 0 12px; color: var(--text-soft); }
.lead strong { color: var(--text); }
.lead:last-child { margin-bottom: 0; }

/* Líneas de investigación y docencia */
.topics {
	display: grid;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.topics li {
	display: flex;
	gap: 14px;
	align-items: flex-start;
	padding: 14px 16px;
	border-radius: 12px;
	background: var(--card-alt);
}

.topics i {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	background: var(--accent);
	color: var(--card);
	font-size: .85rem;
	flex-shrink: 0;
}

.topics strong { display: block; font-size: .92rem; font-weight: 600; }
.topics span { display: block; font-size: .84rem; color: var(--text-soft); line-height: 1.5; }

.tags em { font-style: normal; opacity: .7; }

/* Filtro de publicaciones */
.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 14px;
}

.filters button {
	font: inherit;
	font-size: .8rem;
	font-weight: 500;
	padding: 5px 14px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: transparent;
	color: var(--text-soft);
	cursor: pointer;
	transition: background .2s, color .2s, border-color .2s;
}

.filters button:hover { border-color: var(--accent); color: var(--accent); }
.filters button.active { background: var(--accent); border-color: var(--accent); color: var(--card); }

.more { margin: 18px 0 0; text-align: center; }

.btn.btn-solid {
	background: var(--accent);
	color: var(--card);
	padding: 8px 18px;
	font-size: .85rem;
}

.btn.btn-solid:hover { opacity: .9; }

/* Servicios */
.services {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}

.service {
	background: var(--card-alt);
	border-radius: 12px;
	padding: 18px 10px;
	text-align: center;
	font-size: .85rem;
	font-weight: 500;
	transition: transform .2s;
}

.service:hover { transform: translateY(-3px); }

.service img {
	width: 44px;
	height: 44px;
	margin: 0 auto 10px;
}

/* Habilidades */
.skills-grid { display: grid; gap: 24px; }

.skill-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.skill-list li {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 9px 0;
	border-bottom: 1px dashed var(--line);
	font-size: .92rem;
}

.skill-list li:last-child { border-bottom: 0; }

.level {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: .75rem;
	color: var(--text-faint);
	white-space: nowrap;
}

.dots { display: flex; gap: 3px; }

.dots span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--line);
}

.dots[data-n="1"] span:nth-child(-n+1),
.dots[data-n="2"] span:nth-child(-n+2),
.dots[data-n="3"] span:nth-child(-n+3),
.dots[data-n="4"] span:nth-child(-n+4),
.dots[data-n="5"] span:nth-child(-n+5) { background: var(--accent); }

/* Etiquetas */
.tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tags li {
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent);
	font-size: .8rem;
	font-weight: 500;
}

/* Línea temporal */
.timeline-grid { display: grid; gap: 32px; }

.timeline {
	margin: 0;
	padding: 0 0 0 16px;
	list-style: none;
	border-left: 2px solid var(--line);
	margin-left: 16px;
}

.timeline li {
	position: relative;
	padding: 0 0 20px 18px;
}

.timeline li:last-child { padding-bottom: 0; }

.timeline li::before {
	content: "";
	position: absolute;
	left: -24px;
	top: 6px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--card);
	border: 2px solid var(--accent);
}

.timeline h4 {
	margin: 0;
	font-size: .95rem;
	font-weight: 600;
	line-height: 1.4;
}

.timeline .date {
	display: inline-block;
	margin: 4px 0 6px;
	font-size: .75rem;
	font-weight: 500;
	color: var(--accent);
	background: var(--accent-soft);
	padding: 1px 10px;
	border-radius: 999px;
}

.timeline p {
	margin: 0;
	font-size: .87rem;
	color: var(--text-soft);
}

.timeline p + p { margin-top: 6px; }

details { margin-top: 8px; font-size: .87rem; color: var(--text-soft); }

summary {
	cursor: pointer;
	color: var(--accent);
	font-weight: 500;
	list-style: none;
}

summary::-webkit-details-marker { display: none; }
summary::before { content: "\25B8"; display: inline-block; margin-right: 6px; transition: transform .2s; }
details[open] summary::before { transform: rotate(90deg); }

details ul {
	margin: 8px 0 0;
	padding-left: 18px;
	list-style: disc;
}

.timeline details li { padding: 1px 0; }
.timeline details li::before { content: none; }

/* Publicaciones */
.pubs {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 14px;
}

.pub {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 4px 14px;
	padding: 16px;
	border-radius: 12px;
	background: var(--card-alt);
}

.pub .year {
	grid-row: span 3;
	font-weight: 700;
	font-size: .85rem;
	color: var(--card);
	background: var(--accent);
	border-radius: 8px;
	padding: 4px 8px;
	height: fit-content;
}

.pub h3 { font-size: .95rem; font-weight: 600; }

.pub .authors { font-size: .82rem; color: var(--text-soft); }
.pub .authors strong { color: var(--text); font-weight: 600; }

.pub .meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	font-size: .8rem;
	color: var(--text-faint);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	border: 1px solid var(--accent);
	color: var(--accent);
	font-size: .78rem;
	font-weight: 500;
	transition: background .2s, color .2s;
}

.btn:hover { background: var(--accent); color: var(--card); text-decoration: none; }

/* Contacto */
.contact-list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 10px;
}

.contact-list a {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 14px 16px;
	border-radius: 12px;
	background: var(--card-alt);
	color: var(--text);
	font-weight: 500;
	word-break: break-word;
	transition: transform .2s;
}

.contact-list a:hover { transform: translateX(4px); text-decoration: none; }

.contact-list i {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	background: var(--accent);
	color: var(--card);
	flex-shrink: 0;
}

.contact-list small { display: block; color: var(--text-faint); font-weight: 400; font-size: .75rem; }

.footer {
	text-align: center;
	color: rgba(255, 255, 255, .45);
	font-size: .8rem;
	padding: 8px 0 4px;
}

/* ---------- Reproductor ---------- */

.player-toggle {
	position: fixed;
	right: 16px;
	bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
	z-index: 60;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 0;
	background: #393939;
	color: #eee;
	font-size: 1.05rem;
	cursor: pointer;
	box-shadow: var(--shadow);
	transition: background .2s;
}

.player-toggle:hover { background: #515151; }
.player-toggle.playing { background: var(--accent); color: #fff; }

.player {
	position: fixed;
	right: 16px;
	left: 16px;
	bottom: calc(var(--nav-h) + 76px + env(safe-area-inset-bottom, 0px));
	z-index: 60;
	max-width: 380px;
	margin-left: auto;
	background: #2a2a30;
	color: #eee;
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
	transform-origin: bottom right;
	transition: opacity .2s, transform .2s;
}

.player[hidden] { display: block !important; opacity: 0; transform: scale(.9); pointer-events: none; visibility: hidden; }

.player-now {
	font-size: .85rem;
	font-weight: 500;
	margin-bottom: 10px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.player-bar {
	width: 100%;
	accent-color: #8fb3d6;
	margin: 0 0 8px;
}

.player-controls {
	display: flex;
	justify-content: center;
	gap: 8px;
}

.player-controls button {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 0;
	background: transparent;
	color: #eee;
	cursor: pointer;
	font-size: .95rem;
}

.player-controls button:hover { background: rgba(255, 255, 255, .1); }
.player-controls .main { background: #eee; color: #2a2a30; }
.player-controls .main:hover { background: #fff; }

.playlist {
	margin: 12px 0 0;
	padding: 8px 0 0;
	list-style: none;
	border-top: 1px solid rgba(255, 255, 255, .1);
	max-height: 180px;
	overflow-y: auto;
}

.playlist button {
	width: 100%;
	text-align: left;
	border: 0;
	background: transparent;
	color: #bbb;
	font: inherit;
	font-size: .78rem;
	padding: 6px 8px;
	border-radius: 6px;
	cursor: pointer;
}

.playlist button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.playlist button.current { color: #fff; font-weight: 600; }

/* ==========================================================================
   Tablet
   ========================================================================== */

@media (min-width: 600px) {
	.card { padding: 32px; }
	.services { grid-template-columns: repeat(3, 1fr); }
	.topics { grid-template-columns: 1fr 1fr; }
	.skills-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
	.skill-list li {
		flex-direction: column;
		align-items: flex-start;
		gap: 2px;
		padding: 8px 0;
		font-size: .9rem;
	}
	.skill-list .level {
		margin-left: 0;
		flex-direction: row-reverse;
	}

}

/* ==========================================================================
   Escritorio: barra lateral fija
   ========================================================================== */

@media (min-width: 992px) {
	body { padding-bottom: 0; }

	.layout {
		grid-template-columns: 280px 1fr;
		align-items: start;
		padding: 48px 24px;
		gap: 24px;
	}

	.sidebar {
		position: sticky;
		top: 24px;
	}

	.content { display: grid; gap: 24px; }

	.nav {
		position: static;
		box-shadow: none;
		border-top: 1px solid var(--line);
		background: transparent;
		margin: 24px -32px -32px;
		padding: 8px 0;
	}

	.nav ul { flex-direction: column; }

	.nav a {
		height: auto;
		flex-direction: row;
		justify-content: flex-start;
		gap: 14px;
		padding: 12px 32px;
		font-size: .9rem;
		color: var(--text-soft);
		border-left: 3px solid transparent;
	}

	.nav a i { width: 18px; text-align: center; font-size: .95rem; }

	.nav a.active {
		color: var(--accent);
		background: var(--card-alt);
		border-left-color: var(--accent);
		font-weight: 500;
	}

	.timeline-grid { grid-template-columns: 1fr 1fr; gap: 32px 40px; }

	.player-toggle { bottom: 24px; right: 24px; }
	.player { bottom: 84px; right: 24px; left: auto; width: 380px; }

	.footer { grid-column: 2; }
}

/* Título vacío que alinea la 2ª columna de lenguajes; en móvil sobra */
@media (max-width: 599px) {
	.subsection-title.spacer { display: none; }
	.skills-grid > div:nth-child(2) { margin-top: -24px; }
}

/* Publicaciones en móvil: el año encima para dejar todo el ancho al título */
@media (max-width: 599px) {
	.pub { grid-template-columns: 1fr; }
	.pub .year { grid-row: auto; justify-self: start; }
}

/* Espaciado entre bloques que no son .block + .block */
.lead + .block { margin-top: 32px; }

/* Con número impar de tarjetas, la última ocupa todo el ancho */
@media (min-width: 600px) {
	.topics li:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

.profile .job { text-wrap: balance; }
